mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Rollup merge of #155783 - qaijuang:issue-150566-cfg-trace-suggestions, r=JonathanBrouwer
Do not suggest internal cfg trace attributes Fixes rust-lang/rust#150566.
This commit is contained in:
@@ -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)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user