@@ -238,7 +238,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
238
238
fn resolve_primitive_associated_item (
239
239
& self ,
240
240
prim_ty : hir:: PrimTy ,
241
- prim : Res ,
242
241
ns : Namespace ,
243
242
module_id : DefId ,
244
243
item_name : Symbol ,
@@ -263,7 +262,12 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
263
262
ty:: AssocKind :: Const => "associatedconstant" ,
264
263
ty:: AssocKind :: Type => "associatedtype" ,
265
264
} )
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
+ } )
267
271
} )
268
272
. ok_or_else ( || {
269
273
debug ! (
@@ -274,7 +278,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
274
278
) ;
275
279
ResolutionFailure :: NotResolved {
276
280
module_id,
277
- partial_res : Some ( prim ) ,
281
+ partial_res : Some ( Res :: PrimTy ( prim_ty ) ) ,
278
282
unresolved : item_str. into ( ) ,
279
283
}
280
284
. into ( )
@@ -328,10 +332,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
328
332
} ) ;
329
333
debug ! ( "{} resolved to {:?} in namespace {:?}" , path_str, result, ns) ;
330
334
match result. map ( |( _, res) | res) {
331
- Ok ( Res :: Err ) | Err ( ( ) ) => is_bool_value ( path_str, ns) . map ( |( _, res) | res) ,
332
-
333
335
// resolver doesn't know about true and false so we'll have to resolve them
334
336
// manually as bool
337
+ Ok ( Res :: Err ) | Err ( ( ) ) => is_bool_value ( path_str, ns) . map ( |( _, res) | res) ,
335
338
Ok ( res) => Some ( res. map_id ( |_| panic ! ( "unexpected node_id" ) ) ) ,
336
339
}
337
340
}
@@ -406,6 +409,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
406
409
}
407
410
} ) ?;
408
411
412
+ // FIXME: are these both necessary?
409
413
let ty_res = if let Some ( ty_res) = is_primitive ( & path_root, TypeNS )
410
414
. map ( |( _, res) | res)
411
415
. or_else ( || self . resolve_path ( & path_root, TypeNS , module_id) )
@@ -426,9 +430,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
426
430
} ;
427
431
428
432
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
+ ) ,
432
436
Res :: Def ( DefKind :: Struct | DefKind :: Union | DefKind :: Enum | DefKind :: TyAlias , did) => {
433
437
debug ! ( "looking for associated item named {} for item {:?}" , item_name, did) ;
434
438
// Checks if item_name belongs to `impl SomeItem`
@@ -1086,7 +1090,7 @@ impl LinkCollector<'_, '_> {
1086
1090
return None ;
1087
1091
}
1088
1092
res = prim;
1089
- fragment = Some ( ( * path. as_str ( ) ) . to_owned ( ) ) ;
1093
+ fragment = Some ( path. as_str ( ) . to_string ( ) ) ;
1090
1094
} else {
1091
1095
// `[char]` when a `char` module is in scope
1092
1096
let candidates = vec ! [ res, prim] ;
@@ -1943,14 +1947,14 @@ fn handle_variant(
1943
1947
if extra_fragment. is_some ( ) {
1944
1948
return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( res) ) ) ;
1945
1949
}
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| {
1949
1953
let parent_def = Res :: Def ( DefKind :: Enum , parent) ;
1950
1954
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 ( ) )
1954
1958
}
1955
1959
1956
1960
// FIXME: At this point, this is basically a copy of the PrimitiveTypeTable
@@ -1977,7 +1981,9 @@ const PRIMITIVES: &[(Symbol, Res)] = &[
1977
1981
fn is_primitive ( path_str : & str , ns : Namespace ) -> Option < ( Symbol , Res ) > {
1978
1982
is_bool_value ( path_str, ns) . or_else ( || {
1979
1983
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 ( )
1981
1987
} else {
1982
1988
None
1983
1989
}
0 commit comments