diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-29 21:42:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-29 21:42:43 +0200 |
| commit | 967e64279ac2695b1767f226d5b6e5cada3d67f4 (patch) | |
| tree | ab1f2347b1693d374e13c33cf22d28b1311e7fec /src | |
| parent | fdb965f3f76e0bbb75ef20ddae033b7e689c7d3c (diff) | |
| parent | 2e63708d39553ed882a20a198cdc0f269bb6cd30 (diff) | |
| download | rust-967e64279ac2695b1767f226d5b6e5cada3d67f4.tar.gz rust-967e64279ac2695b1767f226d5b6e5cada3d67f4.zip | |
Rollup merge of #147133 - GuillaumeGomez:rm-loop-extract_cfg_from_attrs, r=lolbinarycat
Remove one loop in `extract_cfg_from_attrs` Follow-up of https://github.com/rust-lang/rust/pull/138907. r? lolbinarycat
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 4eb32585ffb..6e3dfa0ac22 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1084,8 +1084,8 @@ 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() { + // We get all `doc(auto_cfg)`, `cfg` and `target_feature` attributes. + for attr in attrs { if let Some(ident) = attr.ident() && ident.name == sym::doc && let Some(attrs) = attr.meta_item_list() @@ -1146,15 +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 { - // treat #[target_feature(enable = "feat")] attributes as if they were - // #[doc(cfg(target_feature = "feat"))] attributes as well + } 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 { cfg_info.current_cfg &= Cfg::Cfg(sym::target_feature, Some(*feature)); } |
