Skip to content

Commit 5a94d57

Browse files
authored
Rollup merge of rust-lang#64031 - Centril:param-attrs-no-macros-test, r=nikomatsakis
Harden `param_attrs` test wrt. usage of a proc macro `#[attr]` The `param-attrs-builtin-attrs.rs` test file uses the `#[test]` attribute which should cover this but `#[test]` isn't a proc macro attribute so we add another test to be on the safe side. This intends to address rust-lang#64010 (comment). r? @nikomatsakis cc @c410-f3r @petrochenkov cc rust-lang#60406
2 parents 77a033a + 5187a3e commit 5a94d57

File tree

3 files changed

+299
-0
lines changed

3 files changed

+299
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
8+
use proc_macro::TokenStream;
9+
10+
#[proc_macro_attribute]
11+
pub fn id(_: TokenStream, input: TokenStream) -> TokenStream { input }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// aux-build:ident-mac.rs
2+
3+
#![feature(param_attrs)]
4+
#![feature(c_variadic)]
5+
6+
extern crate ident_mac;
7+
use ident_mac::id;
8+
9+
struct W(u8);
10+
11+
extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
12+
//~^ ERROR the attribute `id` is currently unknown to the compiler
13+
//~| ERROR the attribute `id` is currently unknown to the compiler
14+
15+
unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {}
16+
//~^ ERROR the attribute `id` is currently unknown to the compiler
17+
18+
type Alias = extern "C" fn(#[id] u8, #[id] ...);
19+
//~^ ERROR the attribute `id` is currently unknown to the compiler
20+
//~| ERROR the attribute `id` is currently unknown to the compiler
21+
22+
fn free(#[id] arg1: u8) {
23+
//~^ ERROR the attribute `id` is currently unknown to the compiler
24+
let lam = |#[id] W(x), #[id] y| ();
25+
//~^ ERROR the attribute `id` is currently unknown to the compiler
26+
//~| ERROR the attribute `id` is currently unknown to the compiler
27+
}
28+
29+
impl W {
30+
fn inherent1(#[id] self, #[id] arg1: u8) {}
31+
//~^ ERROR the attribute `id` is currently unknown to the compiler
32+
//~| ERROR the attribute `id` is currently unknown to the compiler
33+
fn inherent2(#[id] &self, #[id] arg1: u8) {}
34+
//~^ ERROR the attribute `id` is currently unknown to the compiler
35+
//~| ERROR the attribute `id` is currently unknown to the compiler
36+
fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
37+
//~^ ERROR the attribute `id` is currently unknown to the compiler
38+
//~| ERROR the attribute `id` is currently unknown to the compiler
39+
fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
40+
//~^ ERROR the attribute `id` is currently unknown to the compiler
41+
//~| ERROR the attribute `id` is currently unknown to the compiler
42+
}
43+
44+
trait A {
45+
fn trait1(#[id] self, #[id] arg1: u8);
46+
//~^ ERROR the attribute `id` is currently unknown to the compiler
47+
//~| ERROR the attribute `id` is currently unknown to the compiler
48+
fn trait2(#[id] &self, #[id] arg1: u8);
49+
//~^ ERROR the attribute `id` is currently unknown to the compiler
50+
//~| ERROR the attribute `id` is currently unknown to the compiler
51+
fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
52+
//~^ ERROR the attribute `id` is currently unknown to the compiler
53+
//~| ERROR the attribute `id` is currently unknown to the compiler
54+
fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
55+
//~^ ERROR the attribute `id` is currently unknown to the compiler
56+
//~| ERROR the attribute `id` is currently unknown to the compiler
57+
//~| ERROR the attribute `id` is currently unknown to the compiler
58+
}
59+
60+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
2+
--> $DIR/proc-macro-cannot-be-used.rs:11:21
3+
|
4+
LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
5+
| ^^^^^
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
8+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
9+
10+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
11+
--> $DIR/proc-macro-cannot-be-used.rs:11:38
12+
|
13+
LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
14+
| ^^^^^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
17+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
18+
19+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
20+
--> $DIR/proc-macro-cannot-be-used.rs:15:38
21+
|
22+
LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {}
23+
| ^^^^^
24+
|
25+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
26+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
27+
28+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
29+
--> $DIR/proc-macro-cannot-be-used.rs:18:28
30+
|
31+
LL | type Alias = extern "C" fn(#[id] u8, #[id] ...);
32+
| ^^^^^
33+
|
34+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
35+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
36+
37+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
38+
--> $DIR/proc-macro-cannot-be-used.rs:18:38
39+
|
40+
LL | type Alias = extern "C" fn(#[id] u8, #[id] ...);
41+
| ^^^^^
42+
|
43+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
44+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
45+
46+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
47+
--> $DIR/proc-macro-cannot-be-used.rs:22:9
48+
|
49+
LL | fn free(#[id] arg1: u8) {
50+
| ^^^^^
51+
|
52+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
53+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
54+
55+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
56+
--> $DIR/proc-macro-cannot-be-used.rs:24:16
57+
|
58+
LL | let lam = |#[id] W(x), #[id] y| ();
59+
| ^^^^^
60+
|
61+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
62+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
63+
64+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
65+
--> $DIR/proc-macro-cannot-be-used.rs:24:28
66+
|
67+
LL | let lam = |#[id] W(x), #[id] y| ();
68+
| ^^^^^
69+
|
70+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
71+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
72+
73+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
74+
--> $DIR/proc-macro-cannot-be-used.rs:30:18
75+
|
76+
LL | fn inherent1(#[id] self, #[id] arg1: u8) {}
77+
| ^^^^^
78+
|
79+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
80+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
81+
82+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
83+
--> $DIR/proc-macro-cannot-be-used.rs:30:30
84+
|
85+
LL | fn inherent1(#[id] self, #[id] arg1: u8) {}
86+
| ^^^^^
87+
|
88+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
89+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
90+
91+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
92+
--> $DIR/proc-macro-cannot-be-used.rs:33:18
93+
|
94+
LL | fn inherent2(#[id] &self, #[id] arg1: u8) {}
95+
| ^^^^^
96+
|
97+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
98+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
99+
100+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
101+
--> $DIR/proc-macro-cannot-be-used.rs:33:31
102+
|
103+
LL | fn inherent2(#[id] &self, #[id] arg1: u8) {}
104+
| ^^^^^
105+
|
106+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
107+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
108+
109+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
110+
--> $DIR/proc-macro-cannot-be-used.rs:36:22
111+
|
112+
LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
113+
| ^^^^^
114+
|
115+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
116+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
117+
118+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
119+
--> $DIR/proc-macro-cannot-be-used.rs:36:42
120+
|
121+
LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
122+
| ^^^^^
123+
|
124+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
125+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
126+
127+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
128+
--> $DIR/proc-macro-cannot-be-used.rs:39:22
129+
|
130+
LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
131+
| ^^^^^
132+
|
133+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
134+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
135+
136+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
137+
--> $DIR/proc-macro-cannot-be-used.rs:39:45
138+
|
139+
LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
140+
| ^^^^^
141+
|
142+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
143+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
144+
145+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
146+
--> $DIR/proc-macro-cannot-be-used.rs:45:15
147+
|
148+
LL | fn trait1(#[id] self, #[id] arg1: u8);
149+
| ^^^^^
150+
|
151+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
152+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
153+
154+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
155+
--> $DIR/proc-macro-cannot-be-used.rs:45:27
156+
|
157+
LL | fn trait1(#[id] self, #[id] arg1: u8);
158+
| ^^^^^
159+
|
160+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
161+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
162+
163+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
164+
--> $DIR/proc-macro-cannot-be-used.rs:48:15
165+
|
166+
LL | fn trait2(#[id] &self, #[id] arg1: u8);
167+
| ^^^^^
168+
|
169+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
170+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
171+
172+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
173+
--> $DIR/proc-macro-cannot-be-used.rs:48:28
174+
|
175+
LL | fn trait2(#[id] &self, #[id] arg1: u8);
176+
| ^^^^^
177+
|
178+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
179+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
180+
181+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
182+
--> $DIR/proc-macro-cannot-be-used.rs:51:19
183+
|
184+
LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
185+
| ^^^^^
186+
|
187+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
188+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
189+
190+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
191+
--> $DIR/proc-macro-cannot-be-used.rs:51:39
192+
|
193+
LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
194+
| ^^^^^
195+
|
196+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
197+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
198+
199+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
200+
--> $DIR/proc-macro-cannot-be-used.rs:54:19
201+
|
202+
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
203+
| ^^^^^
204+
|
205+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
206+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
207+
208+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
209+
--> $DIR/proc-macro-cannot-be-used.rs:54:42
210+
|
211+
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
212+
| ^^^^^
213+
|
214+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
215+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
216+
217+
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future
218+
--> $DIR/proc-macro-cannot-be-used.rs:54:58
219+
|
220+
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
221+
| ^^^^^
222+
|
223+
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
224+
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
225+
226+
error: aborting due to 25 previous errors
227+
228+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)