about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-09-29 22:21:32 +0000
committerbors <bors@rust-lang.org>2025-09-29 22:21:32 +0000
commit29b7717de23f3969ceeb5bef5b01d9223f807655 (patch)
tree430301bed6a9de688c2d62439900fb505bd62713 /src
parentdc2c3564d273cf8ccce32dc4f47eaa27063bceb9 (diff)
parent379979951ed3610d31f63222a479fbcafabe0151 (diff)
downloadrust-29b7717de23f3969ceeb5bef5b01d9223f807655.tar.gz
rust-29b7717de23f3969ceeb5bef5b01d9223f807655.zip
Auto merge of #147162 - matthiaskrgr:rollup-4bv1xzb, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146937 (std: implement `hostname`)
 - rust-lang/rust#147040 (mbe: macro_check: Fix function comments referencing non-existent parameters)
 - rust-lang/rust#147131 (Use MirPatch in simplify_branches.)
 - rust-lang/rust#147133 (Remove one loop in `extract_cfg_from_attrs`)
 - rust-lang/rust#147150 (Emit allocator attributes for allocator shim)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/types.rs16
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));
             }