@@ -514,7 +514,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
514514 Res :: Def ( DefKind :: AssocFn | DefKind :: AssocConst , _) => assert_eq ! ( ns, ValueNS ) ,
515515 Res :: Def ( DefKind :: AssocTy , _) => assert_eq ! ( ns, TypeNS ) ,
516516 Res :: Def ( DefKind :: Variant , _) => {
517- return handle_variant ( self . cx , res, extra_fragment) ;
517+ if extra_fragment. is_some ( ) {
518+ // NOTE: `res` can never be a primitive since this match arm means
519+ // `tcx.def_kind(res) == DefKind::Variant`.
520+ return Err ( ErrorKind :: AnchorFailure (
521+ AnchorFailure :: RustdocAnchorConflict ( res) ,
522+ ) ) ;
523+ }
524+ return handle_variant ( self . cx , res) ;
518525 }
519526 // Not a trait item; just return what we found.
520527 _ => return Ok ( ( res, extra_fragment. clone ( ) ) ) ,
@@ -2272,14 +2279,9 @@ fn privacy_error(cx: &DocContext<'_>, diag_info: &DiagnosticInfo<'_>, path_str:
22722279fn handle_variant (
22732280 cx : & DocContext < ' _ > ,
22742281 res : Res ,
2275- extra_fragment : & Option < UrlFragment > ,
22762282) -> Result < ( Res , Option < UrlFragment > ) , ErrorKind < ' static > > {
22772283 use rustc_middle:: ty:: DefIdTree ;
22782284
2279- if extra_fragment. is_some ( ) {
2280- // NOTE: `res` can never be a primitive since this function is only called when `tcx.def_kind(res) == DefKind::Variant`.
2281- return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( res) ) ) ;
2282- }
22832285 cx. tcx
22842286 . parent ( res. def_id ( cx. tcx ) )
22852287 . map ( |parent| {
0 commit comments