Skip to content
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 1 commit into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/test/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs
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 }
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.)

60 changes: 60 additions & 0 deletions src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs
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 src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr
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`.