Skip to content

Commit c3f5929

Browse files
committed
Auto merge of #101830 - nnethercote:streamline-register_res, r=jyn514
Streamline `register_res`. Turns out it's only ever passed a `Res::Def`. r? `@jyn514`
2 parents 2cb9a65 + 0965a33 commit c3f5929

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/librustdoc/clean/utils.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -491,30 +491,14 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
491491
use DefKind::*;
492492
debug!("register_res({:?})", res);
493493

494-
let (did, kind) = match res {
495-
// These should be added to the cache using `record_extern_fqn`.
494+
let (kind, did) = match res {
496495
Res::Def(
497496
kind @ (AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
498497
| Union | Mod | ForeignTy | Const | Static(_) | Macro(..) | TraitAlias),
499-
i,
500-
) => (i, kind.into()),
501-
// This is part of a trait definition or trait impl; document the trait.
502-
Res::SelfTy { trait_: Some(trait_def_id), alias_to: _ } => (trait_def_id, ItemType::Trait),
503-
// This is an inherent impl or a type definition; it doesn't have its own page.
504-
Res::SelfTy { trait_: None, alias_to: Some((item_def_id, _)) } => return item_def_id,
505-
Res::SelfTy { trait_: None, alias_to: None }
506-
| Res::PrimTy(_)
507-
| Res::ToolMod
508-
| Res::SelfCtor(_)
509-
| Res::Local(_)
510-
| Res::NonMacroAttr(_)
511-
| Res::Err => return res.def_id(),
512-
Res::Def(
513-
TyParam | ConstParam | Ctor(..) | ExternCrate | Use | ForeignMod | AnonConst
514-
| InlineConst | OpaqueTy | ImplTraitPlaceholder | Field | LifetimeParam | GlobalAsm
515-
| Impl | Closure | Generator,
516-
id,
517-
) => return id,
498+
did,
499+
) => (kind.into(), did),
500+
501+
_ => panic!("register_res: unexpected {:?}", res),
518502
};
519503
if did.is_local() {
520504
return did;

0 commit comments

Comments
 (0)