Do not suggest internal cfg trace attributes

This commit is contained in:
Qai Juang
2026-04-25 11:47:34 -04:00
parent fb76025f2f
commit b17822575c
3 changed files with 25 additions and 1 deletions
@@ -1281,6 +1281,11 @@ pub(crate) fn add_scope_set_candidates(
suggestions.extend(
BUILTIN_ATTRIBUTES
.iter()
// These trace attributes are compiler-generated and have
// deliberately invalid names.
.filter(|attr| {
!matches!(attr.name, sym::cfg_trace | sym::cfg_attr_trace)
})
.map(|attr| TypoSuggestion::typo_from_name(attr.name, res)),
);
}
+7
View File
@@ -8,4 +8,11 @@ fn bar() {}
//~^ ERROR cannot find attribute `rustc_dumm` in this scope
//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
// Regression test for https://github.com/rust-lang/rust/issues/150566.
#[cfg_trace] //~ ERROR cannot find attribute `cfg_trace` in this scope
fn cfg_trace_attr() {}
#[cfg_attr_trace] //~ ERROR cannot find attribute `cfg_attr_trace` in this scope
fn cfg_attr_trace_attr() {}
fn main() {}
+13 -1
View File
@@ -4,6 +4,12 @@ error: attributes starting with `rustc` are reserved for use by the `rustc` comp
LL | #[rustc_dumm]
| ^^^^^^^^^^
error: cannot find attribute `cfg_attr_trace` in this scope
--> $DIR/attribute-typos.rs:15:3
|
LL | #[cfg_attr_trace]
| ^^^^^^^^^^^^^^
error: cannot find attribute `rustc_dumm` in this scope
--> $DIR/attribute-typos.rs:7:3
|
@@ -15,6 +21,12 @@ help: a built-in attribute with a similar name exists
LL | #[rustc_dummy]
| +
error: cannot find attribute `cfg_trace` in this scope
--> $DIR/attribute-typos.rs:12:3
|
LL | #[cfg_trace]
| ^^^^^^^^^
error: cannot find attribute `tests` in this scope
--> $DIR/attribute-typos.rs:4:3
|
@@ -41,5 +53,5 @@ help: a built-in attribute with a similar name exists
LL | #[deprecated]
| +
error: aborting due to 4 previous errors
error: aborting due to 6 previous errors