@@ -238,7 +238,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
238238 fn resolve_primitive_associated_item (
239239 & self ,
240240 prim_ty : hir:: PrimTy ,
241- prim : Res ,
242241 ns : Namespace ,
243242 module_id : DefId ,
244243 item_name : Symbol ,
@@ -263,7 +262,12 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
263262 ty:: AssocKind :: Const => "associatedconstant" ,
264263 ty:: AssocKind :: Type => "associatedtype" ,
265264 } )
266- . map ( |out| ( prim, Some ( format ! ( "{}#{}.{}" , prim_ty. name( ) , out, item_str) ) ) )
265+ . map ( |out| {
266+ (
267+ Res :: PrimTy ( prim_ty) ,
268+ Some ( format ! ( "{}#{}.{}" , prim_ty. name( ) , out, item_str) ) ,
269+ )
270+ } )
267271 } )
268272 . ok_or_else ( || {
269273 debug ! (
@@ -274,7 +278,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
274278 ) ;
275279 ResolutionFailure :: NotResolved {
276280 module_id,
277- partial_res : Some ( prim ) ,
281+ partial_res : Some ( Res :: PrimTy ( prim_ty ) ) ,
278282 unresolved : item_str. into ( ) ,
279283 }
280284 . into ( )
@@ -328,10 +332,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
328332 } ) ;
329333 debug ! ( "{} resolved to {:?} in namespace {:?}" , path_str, result, ns) ;
330334 match result. map ( |( _, res) | res) {
331- Ok ( Res :: Err ) | Err ( ( ) ) => is_bool_value ( path_str, ns) . map ( |( _, res) | res) ,
332-
333335 // resolver doesn't know about true and false so we'll have to resolve them
334336 // manually as bool
337+ Ok ( Res :: Err ) | Err ( ( ) ) => is_bool_value ( path_str, ns) . map ( |( _, res) | res) ,
335338 Ok ( res) => Some ( res. map_id ( |_| panic ! ( "unexpected node_id" ) ) ) ,
336339 }
337340 }
@@ -406,6 +409,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
406409 }
407410 } ) ?;
408411
412+ // FIXME: are these both necessary?
409413 let ty_res = if let Some ( ty_res) = is_primitive ( & path_root, TypeNS )
410414 . map ( |( _, res) | res)
411415 . or_else ( || self . resolve_path ( & path_root, TypeNS , module_id) )
@@ -426,9 +430,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
426430 } ;
427431
428432 let res = match ty_res {
429- Res :: PrimTy ( prim) => Some ( self . resolve_primitive_associated_item (
430- prim, ty_res , ns, module_id, item_name, item_str,
431- ) ) ,
433+ Res :: PrimTy ( prim) => Some (
434+ self . resolve_primitive_associated_item ( prim, ns, module_id, item_name, item_str) ,
435+ ) ,
432436 Res :: Def ( DefKind :: Struct | DefKind :: Union | DefKind :: Enum | DefKind :: TyAlias , did) => {
433437 debug ! ( "looking for associated item named {} for item {:?}" , item_name, did) ;
434438 // Checks if item_name belongs to `impl SomeItem`
@@ -1086,7 +1090,7 @@ impl LinkCollector<'_, '_> {
10861090 return None ;
10871091 }
10881092 res = prim;
1089- fragment = Some ( ( * path. as_str ( ) ) . to_owned ( ) ) ;
1093+ fragment = Some ( path. as_str ( ) . to_string ( ) ) ;
10901094 } else {
10911095 // `[char]` when a `char` module is in scope
10921096 let candidates = vec ! [ res, prim] ;
@@ -1943,14 +1947,14 @@ fn handle_variant(
19431947 if extra_fragment. is_some ( ) {
19441948 return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( res) ) ) ;
19451949 }
1946- cx. tcx . parent ( res . def_id ( ) ) . map_or_else (
1947- || Err ( ResolutionFailure :: NoParentItem . into ( ) ) ,
1948- |parent| {
1950+ cx. tcx
1951+ . parent ( res . def_id ( ) )
1952+ . map ( |parent| {
19491953 let parent_def = Res :: Def ( DefKind :: Enum , parent) ;
19501954 let variant = cx. tcx . expect_variant_res ( res) ;
1951- Ok ( ( parent_def, Some ( format ! ( "variant.{}" , variant. ident. name) ) ) )
1952- } ,
1953- )
1955+ ( parent_def, Some ( format ! ( "variant.{}" , variant. ident. name) ) )
1956+ } )
1957+ . ok_or_else ( || ResolutionFailure :: NoParentItem . into ( ) )
19541958}
19551959
19561960// FIXME: At this point, this is basically a copy of the PrimitiveTypeTable
@@ -1977,7 +1981,9 @@ const PRIMITIVES: &[(Symbol, Res)] = &[
19771981fn is_primitive ( path_str : & str , ns : Namespace ) -> Option < ( Symbol , Res ) > {
19781982 is_bool_value ( path_str, ns) . or_else ( || {
19791983 if ns == TypeNS {
1980- PRIMITIVES . iter ( ) . find ( |x| x. 0 . as_str ( ) == path_str) . copied ( )
1984+ // FIXME: this should be replaced by a lookup in PrimitiveTypeTable
1985+ let maybe_primitive = Symbol :: intern ( path_str) ;
1986+ PRIMITIVES . iter ( ) . find ( |x| x. 0 == maybe_primitive) . copied ( )
19811987 } else {
19821988 None
19831989 }
0 commit comments