Skip to content

Commit c8f302a

Browse files
committed
tests: add regression test to make sure cfg_attr isn't considered unhandled
1 parent b586701 commit c8f302a

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//! I missed a `cfg_attr` match in #128581, it should have had the same treatment as `cfg`.
2+
//!
3+
//! This test is not exhaustive, there's too many possible positions to check, instead it just does
4+
//! a basic smoke test in a few select positions to make sure we don't ICE for e.g.
5+
//! `#[cfg_attr::skip]`.
6+
//!
7+
//! issue: rust-lang/rust#128716
8+
#![crate_type = "lib"]
9+
10+
#[cfg_attr::skip]
11+
//~^ ERROR failed to resolve
12+
mod we_are_no_strangers_to_love {}
13+
14+
#[cfg_attr::skip]
15+
//~^ ERROR failed to resolve
16+
struct YouKnowTheRules {
17+
#[cfg_attr::skip]
18+
//~^ ERROR failed to resolve
19+
and_so_do_i: u8,
20+
}
21+
22+
#[cfg_attr::skip]
23+
//~^ ERROR failed to resolve
24+
fn a_full_commitment() {
25+
#[cfg_attr::skip]
26+
//~^ ERROR failed to resolve
27+
let is_what_i_am_thinking_of = ();
28+
}
29+
30+
#[cfg_attr::skip]
31+
//~^ ERROR failed to resolve
32+
union AnyOtherGuy {
33+
owo: ()
34+
}
35+
struct This;
36+
37+
#[cfg_attr(FALSE, doc = "you wouldn't get this")]
38+
impl From<AnyOtherGuy> for This {
39+
#[cfg_attr::skip]
40+
//~^ ERROR failed to resolve
41+
fn from(#[cfg_attr::skip] any_other_guy: AnyOtherGuy) -> This {
42+
//~^ ERROR failed to resolve
43+
#[cfg_attr::skip]
44+
//~^ ERROR attributes on expressions are experimental
45+
//~| ERROR failed to resolve
46+
unreachable!()
47+
}
48+
}
49+
50+
#[cfg_attr::skip]
51+
//~^ ERROR failed to resolve
52+
enum NeverGonna {
53+
#[cfg_attr::skip]
54+
//~^ ERROR failed to resolve
55+
GiveYouUp(#[cfg_attr::skip] u8),
56+
//~^ ERROR failed to resolve
57+
LetYouDown {
58+
#![cfg_attr::skip]
59+
//~^ ERROR an inner attribute is not permitted in this context
60+
never_gonna: (),
61+
round_around: (),
62+
#[cfg_attr::skip]
63+
//~^ ERROR failed to resolve
64+
and_desert_you: (),
65+
},
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
error: an inner attribute is not permitted in this context
2+
--> $DIR/check-cfg_attr-ice.rs:58:9
3+
|
4+
LL | #![cfg_attr::skip]
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
8+
= note: outer attributes, like `#[test]`, annotate the item following them
9+
10+
error[E0658]: attributes on expressions are experimental
11+
--> $DIR/check-cfg_attr-ice.rs:43:9
12+
|
13+
LL | #[cfg_attr::skip]
14+
| ^^^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
17+
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
18+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
19+
20+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
21+
--> $DIR/check-cfg_attr-ice.rs:50:3
22+
|
23+
LL | #[cfg_attr::skip]
24+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
25+
26+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
27+
--> $DIR/check-cfg_attr-ice.rs:53:7
28+
|
29+
LL | #[cfg_attr::skip]
30+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
31+
32+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
33+
--> $DIR/check-cfg_attr-ice.rs:55:17
34+
|
35+
LL | GiveYouUp(#[cfg_attr::skip] u8),
36+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
37+
38+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
39+
--> $DIR/check-cfg_attr-ice.rs:62:11
40+
|
41+
LL | #[cfg_attr::skip]
42+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
43+
44+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
45+
--> $DIR/check-cfg_attr-ice.rs:39:7
46+
|
47+
LL | #[cfg_attr::skip]
48+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
49+
50+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
51+
--> $DIR/check-cfg_attr-ice.rs:41:15
52+
|
53+
LL | fn from(#[cfg_attr::skip] any_other_guy: AnyOtherGuy) -> This {
54+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
55+
56+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
57+
--> $DIR/check-cfg_attr-ice.rs:43:11
58+
|
59+
LL | #[cfg_attr::skip]
60+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
61+
62+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
63+
--> $DIR/check-cfg_attr-ice.rs:30:3
64+
|
65+
LL | #[cfg_attr::skip]
66+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
67+
68+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
69+
--> $DIR/check-cfg_attr-ice.rs:22:3
70+
|
71+
LL | #[cfg_attr::skip]
72+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
73+
74+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
75+
--> $DIR/check-cfg_attr-ice.rs:25:7
76+
|
77+
LL | #[cfg_attr::skip]
78+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
79+
80+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
81+
--> $DIR/check-cfg_attr-ice.rs:14:3
82+
|
83+
LL | #[cfg_attr::skip]
84+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
85+
86+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
87+
--> $DIR/check-cfg_attr-ice.rs:17:7
88+
|
89+
LL | #[cfg_attr::skip]
90+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
91+
92+
error[E0433]: failed to resolve: use of undeclared crate or module `cfg_attr`
93+
--> $DIR/check-cfg_attr-ice.rs:10:3
94+
|
95+
LL | #[cfg_attr::skip]
96+
| ^^^^^^^^ use of undeclared crate or module `cfg_attr`
97+
98+
error: aborting due to 15 previous errors
99+
100+
Some errors have detailed explanations: E0433, E0658.
101+
For more information about an error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)