diff options
| author | Michael Howell <michael@notriddle.com> | 2024-08-30 10:16:41 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2024-09-07 20:56:39 -0700 |
| commit | e80c9ac3e213c0c2e6d1a80ea2d4bf074ff8f887 (patch) | |
| tree | e5f6ec621bff1769bcfa8ba9b2ed4894b940c642 /src/librustdoc/clean/inline.rs | |
| parent | 878f49f5ff0dd88a85bcd5d99fc0d90e219c354c (diff) | |
| download | rust-e80c9ac3e213c0c2e6d1a80ea2d4bf074ff8f887.tar.gz rust-e80c9ac3e213c0c2e6d1a80ea2d4bf074ff8f887.zip | |
rustdoc: use `LocalDefId` for inline stmt
It's never a cross-crate DefId, so save space by not storing it.
Diffstat (limited to 'src/librustdoc/clean/inline.rs')
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index d22c4cc4b76..7978ce6e22e 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{DefId, DefIdSet, LocalModDefId}; +use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalModDefId}; use rustc_hir::Mutability; use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty::fast_reject::SimplifiedType; @@ -43,7 +43,7 @@ pub(crate) fn try_inline( cx: &mut DocContext<'_>, res: Res, name: Symbol, - attrs: Option<(&[ast::Attribute], Option<DefId>)>, + attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>, visited: &mut DefIdSet, ) -> Option<Vec<clean::Item>> { let did = res.opt_def_id()?; @@ -157,7 +157,7 @@ pub(crate) fn try_inline( kind, did, name, - import_def_id.and_then(|def_id| def_id.as_local()), + import_def_id, None, ); // The visibility needs to reflect the one from the reexport and not from the "source" DefId. @@ -198,7 +198,7 @@ pub(crate) fn try_inline_glob( visited, inlined_names, Some(&reexports), - Some((attrs, Some(import.owner_id.def_id.to_def_id()))), + Some((attrs, Some(import.owner_id.def_id))), ); items.retain(|item| { if let Some(name) = item.name { @@ -372,7 +372,7 @@ fn build_type_alias( pub(crate) fn build_impls( cx: &mut DocContext<'_>, did: DefId, - attrs: Option<(&[ast::Attribute], Option<DefId>)>, + attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>, ret: &mut Vec<clean::Item>, ) { let _prof_timer = cx.tcx.sess.prof.generic_activity("build_inherent_impls"); @@ -405,7 +405,7 @@ pub(crate) fn build_impls( pub(crate) fn merge_attrs( cx: &mut DocContext<'_>, old_attrs: &[ast::Attribute], - new_attrs: Option<(&[ast::Attribute], Option<DefId>)>, + new_attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>, ) -> (clean::Attributes, Option<Arc<clean::cfg::Cfg>>) { // NOTE: If we have additional attributes (from a re-export), // always insert them first. This ensure that re-export @@ -416,7 +416,7 @@ pub(crate) fn merge_attrs( both.extend_from_slice(old_attrs); ( if let Some(item_id) = item_id { - Attributes::from_ast_with_additional(old_attrs, (inner, item_id)) + Attributes::from_ast_with_additional(old_attrs, (inner, item_id.to_def_id())) } else { Attributes::from_ast(&both) }, @@ -431,7 +431,7 @@ pub(crate) fn merge_attrs( pub(crate) fn build_impl( cx: &mut DocContext<'_>, did: DefId, - attrs: Option<(&[ast::Attribute], Option<DefId>)>, + attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>, ret: &mut Vec<clean::Item>, ) { if !cx.inlined.insert(did.into()) { @@ -641,7 +641,7 @@ fn build_module_items( visited: &mut DefIdSet, inlined_names: &mut FxHashSet<(ItemType, Symbol)>, allowed_def_ids: Option<&DefIdSet>, - attrs: Option<(&[ast::Attribute], Option<DefId>)>, + attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>, ) -> Vec<clean::Item> { let mut items = Vec::new(); @@ -745,7 +745,7 @@ fn build_macro( cx: &mut DocContext<'_>, def_id: DefId, name: Symbol, - import_def_id: Option<DefId>, + import_def_id: Option<LocalDefId>, macro_kind: MacroKind, is_doc_hidden: bool, ) -> clean::ItemKind { @@ -753,7 +753,7 @@ fn build_macro( LoadedMacro::MacroDef(item_def, _) => match macro_kind { MacroKind::Bang => { if let ast::ItemKind::MacroDef(ref def) = item_def.kind { - let vis = cx.tcx.visibility(import_def_id.unwrap_or(def_id)); + let vis = cx.tcx.visibility(import_def_id.map(|d| d.to_def_id()).unwrap_or(def_id)); clean::MacroItem(clean::Macro { source: utils::display_macro_source( cx, |
