diff options
| author | bors <bors@rust-lang.org> | 2025-07-15 08:38:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-15 08:38:13 +0000 |
| commit | a9fb6103b05c6ad6eee6bed4c0bb5a2e8e1024c6 (patch) | |
| tree | 635bf7b454df9fe8fbb5d76d8f75102f59e33b6b /compiler/rustc_resolve/src/diagnostics.rs | |
| parent | 7f2065a4bae1faed5bab928c670964eafbf43b55 (diff) | |
| parent | 7a7c74ad89df9f87824fa17fbbe0448d9ab6f7cc (diff) | |
| download | rust-a9fb6103b05c6ad6eee6bed4c0bb5a2e8e1024c6.tar.gz rust-a9fb6103b05c6ad6eee6bed4c0bb5a2e8e1024c6.zip | |
Auto merge of #143460 - JonathanBrouwer:cfg_parser, r=jdonszelmann
Port `#[cfg]` to the new attribute parsing infrastructure Ports `#[cfg]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 I've split this PR into commits for reviewability, and left some comments to clarify things
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index b2f16fb1dfb..93d848787ef 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1,11 +1,10 @@ -use rustc_ast::expand::StrippedCfgItem; use rustc_ast::ptr::P; use rustc_ast::visit::{self, Visitor}; -use rustc_ast::{ - self as ast, CRATE_NODE_ID, Crate, ItemKind, MetaItemInner, MetaItemKind, ModKind, NodeId, Path, -}; +use rustc_ast::{self as ast, CRATE_NODE_ID, Crate, ItemKind, ModKind, NodeId, Path}; use rustc_ast_pretty::pprust; -use rustc_attr_data_structures::{self as attr, AttributeKind, Stability, find_attr}; +use rustc_attr_data_structures::{ + self as attr, AttributeKind, CfgEntry, Stability, StrippedCfgItem, find_attr, +}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::codes::*; @@ -2860,17 +2859,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let note = errors::FoundItemConfigureOut { span: ident.span }; err.subdiagnostic(note); - if let MetaItemKind::List(nested) = &cfg.kind - && let MetaItemInner::MetaItem(meta_item) = &nested[0] - && let MetaItemKind::NameValue(feature_name) = &meta_item.kind - { - let note = errors::ItemWasBehindFeature { - feature: feature_name.symbol, - span: meta_item.span, - }; + if let CfgEntry::NameValue { value: Some((feature, _)), .. } = cfg.0 { + let note = errors::ItemWasBehindFeature { feature, span: cfg.1 }; err.subdiagnostic(note); } else { - let note = errors::ItemWasCfgOut { span: cfg.span }; + let note = errors::ItemWasCfgOut { span: cfg.1 }; err.subdiagnostic(note); } } |
