diff options
| author | bors <bors@rust-lang.org> | 2022-09-15 02:58:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-15 02:58:21 +0000 |
| commit | c3f59295fecb9a7cb067bc4a5b50f779e159a55b (patch) | |
| tree | bc845f26382216050a94d93722977212c00e0f88 /src | |
| parent | 2cb9a65684dba47c52de8fa938febf97a73e70a9 (diff) | |
| parent | 0965a337794738a7af188be480e17601933494f8 (diff) | |
| download | rust-c3f59295fecb9a7cb067bc4a5b50f779e159a55b.tar.gz rust-c3f59295fecb9a7cb067bc4a5b50f779e159a55b.zip | |
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`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 395f213ca87..135c0fe7910 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -491,30 +491,14 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { use DefKind::*; debug!("register_res({:?})", res); - let (did, kind) = match res { - // These should be added to the cache using `record_extern_fqn`. + let (kind, did) = match res { Res::Def( kind @ (AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct | Union | Mod | ForeignTy | Const | Static(_) | Macro(..) | TraitAlias), - i, - ) => (i, kind.into()), - // This is part of a trait definition or trait impl; document the trait. - Res::SelfTy { trait_: Some(trait_def_id), alias_to: _ } => (trait_def_id, ItemType::Trait), - // This is an inherent impl or a type definition; it doesn't have its own page. - Res::SelfTy { trait_: None, alias_to: Some((item_def_id, _)) } => return item_def_id, - Res::SelfTy { trait_: None, alias_to: None } - | Res::PrimTy(_) - | Res::ToolMod - | Res::SelfCtor(_) - | Res::Local(_) - | Res::NonMacroAttr(_) - | Res::Err => return res.def_id(), - Res::Def( - TyParam | ConstParam | Ctor(..) | ExternCrate | Use | ForeignMod | AnonConst - | InlineConst | OpaqueTy | ImplTraitPlaceholder | Field | LifetimeParam | GlobalAsm - | Impl | Closure | Generator, - id, - ) => return id, + did, + ) => (kind.into(), did), + + _ => panic!("register_res: unexpected {:?}", res), }; if did.is_local() { return did; |
