@@ -203,7 +203,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
203203 . ok_or ( ErrorKind :: ResolutionFailure ) ?;
204204
205205 if let Some ( prim) = is_primitive ( & path, TypeNS ) {
206- let did = primitive_impl ( cx, & path) . ok_or ( ErrorKind :: ResolutionFailure ) ?;
206+ let did =
207+ utils:: primitive_path_impl ( cx, & path) . ok_or ( ErrorKind :: ResolutionFailure ) ?;
207208 return cx
208209 . tcx
209210 . associated_items ( did)
@@ -888,50 +889,10 @@ fn handle_variant(
888889 Ok ( ( parent_def, Some ( format ! ( "{}.v" , variant. ident. name) ) ) )
889890}
890891
891- const PRIMITIVES : & [ ( & str , Res ) ] = & [
892- ( "u8" , Res :: PrimTy ( hir:: PrimTy :: Uint ( syntax:: ast:: UintTy :: U8 ) ) ) ,
893- ( "u16" , Res :: PrimTy ( hir:: PrimTy :: Uint ( syntax:: ast:: UintTy :: U16 ) ) ) ,
894- ( "u32" , Res :: PrimTy ( hir:: PrimTy :: Uint ( syntax:: ast:: UintTy :: U32 ) ) ) ,
895- ( "u64" , Res :: PrimTy ( hir:: PrimTy :: Uint ( syntax:: ast:: UintTy :: U64 ) ) ) ,
896- ( "u128" , Res :: PrimTy ( hir:: PrimTy :: Uint ( syntax:: ast:: UintTy :: U128 ) ) ) ,
897- ( "usize" , Res :: PrimTy ( hir:: PrimTy :: Uint ( syntax:: ast:: UintTy :: Usize ) ) ) ,
898- ( "i8" , Res :: PrimTy ( hir:: PrimTy :: Int ( syntax:: ast:: IntTy :: I8 ) ) ) ,
899- ( "i16" , Res :: PrimTy ( hir:: PrimTy :: Int ( syntax:: ast:: IntTy :: I16 ) ) ) ,
900- ( "i32" , Res :: PrimTy ( hir:: PrimTy :: Int ( syntax:: ast:: IntTy :: I32 ) ) ) ,
901- ( "i64" , Res :: PrimTy ( hir:: PrimTy :: Int ( syntax:: ast:: IntTy :: I64 ) ) ) ,
902- ( "i128" , Res :: PrimTy ( hir:: PrimTy :: Int ( syntax:: ast:: IntTy :: I128 ) ) ) ,
903- ( "isize" , Res :: PrimTy ( hir:: PrimTy :: Int ( syntax:: ast:: IntTy :: Isize ) ) ) ,
904- ( "f32" , Res :: PrimTy ( hir:: PrimTy :: Float ( syntax:: ast:: FloatTy :: F32 ) ) ) ,
905- ( "f64" , Res :: PrimTy ( hir:: PrimTy :: Float ( syntax:: ast:: FloatTy :: F64 ) ) ) ,
906- ( "str" , Res :: PrimTy ( hir:: PrimTy :: Str ) ) ,
907- ( "bool" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
908- ( "char" , Res :: PrimTy ( hir:: PrimTy :: Char ) ) ,
909- ] ;
910-
911892fn is_primitive ( path_str : & str , ns : Namespace ) -> Option < Res > {
912- if ns == TypeNS { PRIMITIVES . iter ( ) . find ( |x| x. 0 == path_str) . map ( |x| x. 1 ) } else { None }
913- }
914-
915- fn primitive_impl ( cx : & DocContext < ' _ > , path_str : & str ) -> Option < DefId > {
916- let tcx = cx. tcx ;
917- match path_str {
918- "u8" => tcx. lang_items ( ) . u8_impl ( ) ,
919- "u16" => tcx. lang_items ( ) . u16_impl ( ) ,
920- "u32" => tcx. lang_items ( ) . u32_impl ( ) ,
921- "u64" => tcx. lang_items ( ) . u64_impl ( ) ,
922- "u128" => tcx. lang_items ( ) . u128_impl ( ) ,
923- "usize" => tcx. lang_items ( ) . usize_impl ( ) ,
924- "i8" => tcx. lang_items ( ) . i8_impl ( ) ,
925- "i16" => tcx. lang_items ( ) . i16_impl ( ) ,
926- "i32" => tcx. lang_items ( ) . i32_impl ( ) ,
927- "i64" => tcx. lang_items ( ) . i64_impl ( ) ,
928- "i128" => tcx. lang_items ( ) . i128_impl ( ) ,
929- "isize" => tcx. lang_items ( ) . isize_impl ( ) ,
930- "f32" => tcx. lang_items ( ) . f32_impl ( ) ,
931- "f64" => tcx. lang_items ( ) . f64_impl ( ) ,
932- "str" => tcx. lang_items ( ) . str_impl ( ) ,
933- "bool" => tcx. lang_items ( ) . bool_impl ( ) ,
934- "char" => tcx. lang_items ( ) . char_impl ( ) ,
935- _ => None ,
893+ if ns == TypeNS {
894+ utils:: PRIMITIVES . iter ( ) . find ( |x| x. 0 == path_str) . map ( |x| x. 1 )
895+ } else {
896+ None
936897 }
937898}
0 commit comments