@@ -305,26 +305,19 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
305
305
Res :: Def ( DefKind :: AssocFn | DefKind :: AssocConst , _) => {
306
306
if ns != ValueNS {
307
307
return Err ( ResolutionFailure :: WrongNamespace ( res, ns) . into ( ) ) ;
308
- } else {
309
- // In case this is a trait item, skip the
310
- // early return and try looking for the trait.
311
308
}
309
+ // Fall through: In case this is a trait item, skip the
310
+ // early return and try looking for the trait.
312
311
}
313
312
Res :: Def ( DefKind :: AssocTy , _) => {
314
- if ns == ValueNS {
313
+ if ns != TypeNS {
315
314
return Err ( ResolutionFailure :: WrongNamespace ( res, ns) . into ( ) ) ;
316
- } else {
317
- // In case this is a trait item, skip the
318
- // early return and try looking for the trait.
319
315
}
316
+ // Fall through: In case this is a trait item, skip the
317
+ // early return and try looking for the trait.
320
318
}
321
319
Res :: Def ( DefKind :: Variant , _) => {
322
- if extra_fragment. is_some ( ) {
323
- return Err ( ErrorKind :: AnchorFailure (
324
- AnchorFailure :: RustdocAnchorConflict ( res) ,
325
- ) ) ;
326
- }
327
- return handle_variant ( cx, res) ;
320
+ return handle_variant ( cx, res, extra_fragment) ;
328
321
}
329
322
// Not a trait item; just return what we found.
330
323
Res :: PrimTy ( ty) => {
@@ -581,7 +574,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
581
574
current_item : & Option < String > ,
582
575
extra_fragment : & Option < String > ,
583
576
) -> Option < Res > {
584
- // resolve can't be used for macro namespace
577
+ // resolve() can't be used for macro namespace
585
578
let result = match ns {
586
579
Namespace :: MacroNS => self . macro_resolve ( path_str, module_id) . map_err ( ErrorKind :: from) ,
587
580
Namespace :: TypeNS | Namespace :: ValueNS => self
@@ -1946,9 +1939,13 @@ fn privacy_error(
1946
1939
fn handle_variant (
1947
1940
cx : & DocContext < ' _ > ,
1948
1941
res : Res ,
1942
+ extra_fragment : & Option < String > ,
1949
1943
) -> Result < ( Res , Option < String > ) , ErrorKind < ' static > > {
1950
1944
use rustc_middle:: ty:: DefIdTree ;
1951
1945
1946
+ if extra_fragment. is_some ( ) {
1947
+ return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( res) ) ) ;
1948
+ }
1952
1949
cx. tcx . parent ( res. def_id ( ) ) . map_or_else (
1953
1950
|| Err ( ResolutionFailure :: NoParentItem . into ( ) ) ,
1954
1951
|parent| {
@@ -1980,7 +1977,9 @@ const PRIMITIVES: &[(&str, Res)] = &[
1980
1977
] ;
1981
1978
1982
1979
fn is_primitive ( path_str : & str , ns : Namespace ) -> Option < ( & ' static str , Res ) > {
1983
- if ns == TypeNS { PRIMITIVES . iter ( ) . find ( |x| x. 0 == path_str) . copied ( ) } else { None }
1980
+ is_bool_value ( path_str, ns) . or_else ( || {
1981
+ if ns == TypeNS { PRIMITIVES . iter ( ) . find ( |x| x. 0 == path_str) . copied ( ) } else { None }
1982
+ } )
1984
1983
}
1985
1984
1986
1985
fn is_bool_value ( path_str : & str , ns : Namespace ) -> Option < ( & ' static str , Res ) > {
0 commit comments