diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-09-28 22:32:21 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-09-28 22:32:21 +0200 |
| commit | 632f2cb8a47cc16d7e1e6231ac25ba4711c32be8 (patch) | |
| tree | c0ccc537fc9745140cb7536cbac6570340defad2 | |
| parent | 8d72d3e1e96f58ca10059a6bb6e8aecba4a0e9cd (diff) | |
| download | rust-632f2cb8a47cc16d7e1e6231ac25ba4711c32be8.tar.gz rust-632f2cb8a47cc16d7e1e6231ac25ba4711c32be8.zip | |
Remove one loop in `extract_cfg_from_attrs`
| -rw-r--r-- | src/librustdoc/clean/types.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index c2cf39c4be0..d4f0a196eda 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1085,7 +1085,7 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute> let mut changed_auto_active_status = None; // First we get all `doc(auto_cfg)` attributes. - for attr in attrs.clone() { + for attr in attrs { if let Some(ident) = attr.ident() && ident.name == sym::doc && let Some(attrs) = attr.meta_item_list() @@ -1146,13 +1146,9 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute> } } } - } - } - - // If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because - // `doc(cfg())` overrides `cfg()`). - for attr in attrs { - if let hir::Attribute::Parsed(AttributeKind::TargetFeature { features, .. }) = attr { + // If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because + // `doc(cfg())` overrides `cfg()`). + } else if let hir::Attribute::Parsed(AttributeKind::TargetFeature { features, .. }) = attr { // treat #[target_feature(enable = "feat")] attributes as if they were // #[doc(cfg(target_feature = "feat"))] attributes as well for (feature, _) in features { |
