Skip to content

Commit 3b59d9d

Browse files
Rollup merge of #155783 - qaijuang:issue-150566-cfg-trace-suggestions, r=JonathanBrouwer
Do not suggest internal cfg trace attributes Fixes #150566.
2 parents 730b676 + b178225 commit 3b59d9d

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
12811281
suggestions.extend(
12821282
BUILTIN_ATTRIBUTES
12831283
.iter()
1284+
// These trace attributes are compiler-generated and have
1285+
// deliberately invalid names.
1286+
.filter(|attr| {
1287+
!matches!(attr.name, sym::cfg_trace | sym::cfg_attr_trace)
1288+
})
12841289
.map(|attr| TypoSuggestion::typo_from_name(attr.name, res)),
12851290
);
12861291
}

tests/ui/suggestions/attribute-typos.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ fn bar() {}
88
//~^ ERROR cannot find attribute `rustc_dumm` in this scope
99
//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
1010

11+
// Regression test for https://github.com/rust-lang/rust/issues/150566.
12+
#[cfg_trace] //~ ERROR cannot find attribute `cfg_trace` in this scope
13+
fn cfg_trace_attr() {}
14+
15+
#[cfg_attr_trace] //~ ERROR cannot find attribute `cfg_attr_trace` in this scope
16+
fn cfg_attr_trace_attr() {}
17+
1118
fn main() {}

tests/ui/suggestions/attribute-typos.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error: attributes starting with `rustc` are reserved for use by the `rustc` comp
44
LL | #[rustc_dumm]
55
| ^^^^^^^^^^
66

7+
error: cannot find attribute `cfg_attr_trace` in this scope
8+
--> $DIR/attribute-typos.rs:15:3
9+
|
10+
LL | #[cfg_attr_trace]
11+
| ^^^^^^^^^^^^^^
12+
713
error: cannot find attribute `rustc_dumm` in this scope
814
--> $DIR/attribute-typos.rs:7:3
915
|
@@ -15,6 +21,12 @@ help: a built-in attribute with a similar name exists
1521
LL | #[rustc_dummy]
1622
| +
1723

24+
error: cannot find attribute `cfg_trace` in this scope
25+
--> $DIR/attribute-typos.rs:12:3
26+
|
27+
LL | #[cfg_trace]
28+
| ^^^^^^^^^
29+
1830
error: cannot find attribute `tests` in this scope
1931
--> $DIR/attribute-typos.rs:4:3
2032
|
@@ -41,5 +53,5 @@ help: a built-in attribute with a similar name exists
4153
LL | #[deprecated]
4254
| +
4355

44-
error: aborting due to 4 previous errors
56+
error: aborting due to 6 previous errors
4557

0 commit comments

Comments
 (0)