diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-09-25 11:33:58 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-09-27 11:29:50 +0200 |
| commit | 9362ab549f87e535eeba12c5d42f584ff55ff886 (patch) | |
| tree | 83deb2aadf960653d22d990e2afe80126135ccc0 /src/librustdoc | |
| parent | 653e1036ed5a343a7be7b2a73096c138efc51523 (diff) | |
| download | rust-9362ab549f87e535eeba12c5d42f584ff55ff886.tar.gz rust-9362ab549f87e535eeba12c5d42f584ff55ff886.zip | |
Improve code and fix typo
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 10 | ||||
| -rw-r--r-- | src/librustdoc/passes/propagate_doc_cfg.rs | 3 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 8b8cf19d8e4..c2cf39c4be0 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -925,7 +925,7 @@ pub(crate) fn hir_attr_lists<'a, I: IntoIterator<Item = &'a hir::Attribute>>( /// This type keeps track of (doc) cfg information as we go down the item tree. #[derive(Clone, Debug)] pub(crate) struct CfgInfo { - /// List of currently active `doc(auto_cfg(hide(...)))` cfgs,minus currently active + /// List of currently active `doc(auto_cfg(hide(...)))` cfgs, minus currently active /// `doc(auto_cfg(show(...)))` cfgs. hidden_cfg: FxHashSet<Cfg>, /// Current computed `cfg`. Each time we enter a new item, this field is updated as well while @@ -942,13 +942,11 @@ pub(crate) struct CfgInfo { impl Default for CfgInfo { fn default() -> Self { Self { - hidden_cfg: [ + hidden_cfg: FxHashSet::from_iter([ Cfg::Cfg(sym::test, None), Cfg::Cfg(sym::doc, None), Cfg::Cfg(sym::doctest, None), - ] - .into_iter() - .collect(), + ]), current_cfg: Cfg::True, auto_cfg_active: true, parent_is_doc_cfg: false, @@ -990,7 +988,7 @@ fn handle_auto_cfg_hide_show( && let MetaItemKind::List(items) = &item.kind { for item in items { - // Cfg parsing errors should already have been reported in `rustc_passes::check_attr`. + // FIXME: Report in case `Cfg::parse` reports an error? if let Ok(Cfg::Cfg(key, value)) = Cfg::parse(item) { if is_show { if let Some(span) = new_hide_attrs.get(&(key, value)) { diff --git a/src/librustdoc/passes/propagate_doc_cfg.rs b/src/librustdoc/passes/propagate_doc_cfg.rs index 4bcb60a9a40..d5b20f2b941 100644 --- a/src/librustdoc/passes/propagate_doc_cfg.rs +++ b/src/librustdoc/passes/propagate_doc_cfg.rs @@ -97,9 +97,8 @@ impl CfgPropagator<'_, '_> { // // Otherwise, `cfg_info` already tracks everything we need so nothing else to do! if matches!(item.kind, ItemKind::ImplItem(_)) - && let Some(def_id) = item.item_id.as_def_id().and_then(|def_id| def_id.as_local()) + && let Some(mut next_def_id) = item.item_id.as_local_def_id() { - let mut next_def_id = def_id; while let Some(parent_def_id) = self.cx.tcx.opt_local_parent(next_def_id) { let x = load_attrs(self.cx, parent_def_id.to_def_id()); add_only_cfg_attributes(&mut attrs, x); |
