-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #128718 - jieyouxu:check-cfg_attr, r=nnethercote
Consider `cfg_attr` checked by `CheckAttrVisitor` I forgor about `cfg_attr` in #128581, it should be treated like `cfg`. Fixes #128716.
- Loading branch information
Showing
3 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! I missed a `cfg_attr` match in #128581, it should have had the same treatment as `cfg`. If | ||
//! an invalid attribute starting with `cfg_attr` is passed, then it would trigger an ICE because | ||
//! it was not considered "checked" (e.g. `#[cfg_attr::skip]` or `#[cfg_attr::no_such_thing]`). | ||
//! | ||
//! This test is not exhaustive, there's too many possible positions to check, instead it just does | ||
//! a basic smoke test in a few select positions to make sure we don't ICE for e.g. | ||
//! `#[cfg_attr::no_such_thing]`. | ||
//! | ||
//! issue: rust-lang/rust#128716 | ||
#![crate_type = "lib"] | ||
|
||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
mod we_are_no_strangers_to_love {} | ||
|
||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
struct YouKnowTheRules { | ||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
and_so_do_i: u8, | ||
} | ||
|
||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
fn a_full_commitment() { | ||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
let is_what_i_am_thinking_of = (); | ||
} | ||
|
||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
union AnyOtherGuy { | ||
owo: () | ||
} | ||
struct This; | ||
|
||
#[cfg_attr(FALSE, doc = "you wouldn't get this")] | ||
impl From<AnyOtherGuy> for This { | ||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
fn from(#[cfg_attr::no_such_thing] any_other_guy: AnyOtherGuy) -> This { | ||
//~^ ERROR failed to resolve | ||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR attributes on expressions are experimental | ||
//~| ERROR failed to resolve | ||
unreachable!() | ||
} | ||
} | ||
|
||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
enum NeverGonna { | ||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
GiveYouUp(#[cfg_attr::no_such_thing] u8), | ||
//~^ ERROR failed to resolve | ||
LetYouDown { | ||
#![cfg_attr::no_such_thing] | ||
//~^ ERROR an inner attribute is not permitted in this context | ||
never_gonna: (), | ||
round_around: (), | ||
#[cfg_attr::no_such_thing] | ||
//~^ ERROR failed to resolve | ||
and_desert_you: (), | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
error: an inner attribute is not permitted in this context | ||
--> $DIR/check-cfg_attr-ice.rs:60:9 | ||
| | ||
LL | #![cfg_attr::no_such_thing] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files | ||
= note: outer attributes, like `#[test]`, annotate the item following them | ||
|
||
error[E0658]: attributes on expressions are experimental | ||
--> $DIR/check-cfg_attr-ice.rs:45:9 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information | ||
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:52:3 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:55:7 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:57:17 | ||
| | ||
LL | GiveYouUp(#[cfg_attr::no_such_thing] u8), | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:64:11 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:41:7 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:43:15 | ||
| | ||
LL | fn from(#[cfg_attr::no_such_thing] any_other_guy: AnyOtherGuy) -> This { | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:45:11 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:32:3 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:24:3 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:27:7 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:16:3 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:19:7 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr` | ||
--> $DIR/check-cfg_attr-ice.rs:12:3 | ||
| | ||
LL | #[cfg_attr::no_such_thing] | ||
| ^^^^^^^^ use of undeclared crate or module `cfg_attr` | ||
|
||
error: aborting due to 15 previous errors | ||
|
||
Some errors have detailed explanations: E0433, E0658. | ||
For more information about an error, try `rustc --explain E0433`. |