-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Harden param_attrs
test wrt. usage of a proc macro #[attr]
#64031
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_attribute] | ||
pub fn id(_: TokenStream, input: TokenStream) -> TokenStream { input } | ||
60 changes: 60 additions & 0 deletions
60
src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs
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,60 @@ | ||
// aux-build:ident-mac.rs | ||
|
||
#![feature(param_attrs)] | ||
#![feature(c_variadic)] | ||
|
||
extern crate ident_mac; | ||
use ident_mac::id; | ||
|
||
struct W(u8); | ||
|
||
extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
|
||
unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
|
||
type Alias = extern "C" fn(#[id] u8, #[id] ...); | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
|
||
fn free(#[id] arg1: u8) { | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
let lam = |#[id] W(x), #[id] y| (); | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
} | ||
|
||
impl W { | ||
fn inherent1(#[id] self, #[id] arg1: u8) {} | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
fn inherent2(#[id] &self, #[id] arg1: u8) {} | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {} | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
} | ||
|
||
trait A { | ||
fn trait1(#[id] self, #[id] arg1: u8); | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
fn trait2(#[id] &self, #[id] arg1: u8); | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); | ||
//~^ ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
//~| ERROR the attribute `id` is currently unknown to the compiler | ||
} | ||
|
||
fn main() {} |
228 changes: 228 additions & 0 deletions
228
src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr
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,228 @@ | ||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:11:21 | ||
| | ||
LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:11:38 | ||
| | ||
LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:15:38 | ||
| | ||
LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:18:28 | ||
| | ||
LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:18:38 | ||
| | ||
LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:22:9 | ||
| | ||
LL | fn free(#[id] arg1: u8) { | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:24:16 | ||
| | ||
LL | let lam = |#[id] W(x), #[id] y| (); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:24:28 | ||
| | ||
LL | let lam = |#[id] W(x), #[id] y| (); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:30:18 | ||
| | ||
LL | fn inherent1(#[id] self, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:30:30 | ||
| | ||
LL | fn inherent1(#[id] self, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:33:18 | ||
| | ||
LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:33:31 | ||
| | ||
LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:36:22 | ||
| | ||
LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:36:42 | ||
| | ||
LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:39:22 | ||
| | ||
LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:39:45 | ||
| | ||
LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {} | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:45:15 | ||
| | ||
LL | fn trait1(#[id] self, #[id] arg1: u8); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:45:27 | ||
| | ||
LL | fn trait1(#[id] self, #[id] arg1: u8); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:48:15 | ||
| | ||
LL | fn trait2(#[id] &self, #[id] arg1: u8); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:48:28 | ||
| | ||
LL | fn trait2(#[id] &self, #[id] arg1: u8); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:51:19 | ||
| | ||
LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:51:39 | ||
| | ||
LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:54:19 | ||
| | ||
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:54:42 | ||
| | ||
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future | ||
--> $DIR/proc-macro-cannot-be-used.rs:54:58 | ||
| | ||
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable | ||
|
||
error: aborting due to 25 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have
auxiliary/test-macros.rs
that defines all the utility macros like this, you can use#[identity_attr]
from there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to move the test, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok then.
(We need a way to use a crate from the root
auxiliary
directory in all subdirectories to avoid duplication.)