@@ -305,26 +305,19 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
305305 Res :: Def ( DefKind :: AssocFn | DefKind :: AssocConst , _) => {
306306 if ns != ValueNS {
307307 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.
311308 }
309+ // Fall through: In case this is a trait item, skip the
310+ // early return and try looking for the trait.
312311 }
313312 Res :: Def ( DefKind :: AssocTy , _) => {
314- if ns == ValueNS {
313+ if ns != TypeNS {
315314 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.
319315 }
316+ // Fall through: In case this is a trait item, skip the
317+ // early return and try looking for the trait.
320318 }
321319 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) ;
328321 }
329322 // Not a trait item; just return what we found.
330323 Res :: PrimTy ( ty) => {
@@ -581,7 +574,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
581574 current_item : & Option < String > ,
582575 extra_fragment : & Option < String > ,
583576 ) -> Option < Res > {
584- // resolve can't be used for macro namespace
577+ // resolve() can't be used for macro namespace
585578 let result = match ns {
586579 Namespace :: MacroNS => self . macro_resolve ( path_str, module_id) . map_err ( ErrorKind :: from) ,
587580 Namespace :: TypeNS | Namespace :: ValueNS => self
@@ -1946,9 +1939,13 @@ fn privacy_error(
19461939fn handle_variant (
19471940 cx : & DocContext < ' _ > ,
19481941 res : Res ,
1942+ extra_fragment : & Option < String > ,
19491943) -> Result < ( Res , Option < String > ) , ErrorKind < ' static > > {
19501944 use rustc_middle:: ty:: DefIdTree ;
19511945
1946+ if extra_fragment. is_some ( ) {
1947+ return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( res) ) ) ;
1948+ }
19521949 cx. tcx . parent ( res. def_id ( ) ) . map_or_else (
19531950 || Err ( ResolutionFailure :: NoParentItem . into ( ) ) ,
19541951 |parent| {
@@ -1980,7 +1977,9 @@ const PRIMITIVES: &[(&str, Res)] = &[
19801977] ;
19811978
19821979fn 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+ } )
19841983}
19851984
19861985fn is_bool_value ( path_str : & str , ns : Namespace ) -> Option < ( & ' static str , Res ) > {
0 commit comments