mirror of
https://github.com/rust-lang/rust
synced 2024-10-01 22:34:35 +00:00
tests: Centralize proc macros commonly used for testing
This commit is contained in:
parent
50a0defd5a
commit
fb52aeafc9
|
@ -1,28 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_derive(Foo)]
|
|
||||||
pub fn derive_foo(input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_derive(Bar)]
|
|
||||||
pub fn derive_bar(input: TokenStream) -> TokenStream {
|
|
||||||
panic!("lolnope");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_derive(WithHelper, attributes(helper))]
|
|
||||||
pub fn with_helper(input: TokenStream) -> TokenStream {
|
|
||||||
TokenStream::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn helper(_: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// compile-pass
|
|
||||||
// aux-build:plugin.rs
|
|
||||||
|
|
||||||
extern crate plugin;
|
|
||||||
|
|
||||||
mod inner {
|
|
||||||
use plugin::WithHelper;
|
|
||||||
|
|
||||||
#[derive(WithHelper)]
|
|
||||||
struct S;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,12 +0,0 @@
|
||||||
// aux-build:plugin.rs
|
|
||||||
|
|
||||||
#[macro_use(WithHelper)]
|
|
||||||
extern crate plugin;
|
|
||||||
|
|
||||||
use plugin::helper;
|
|
||||||
|
|
||||||
#[derive(WithHelper)]
|
|
||||||
#[helper] //~ ERROR `helper` is ambiguous
|
|
||||||
struct S;
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,21 +0,0 @@
|
||||||
error[E0659]: `helper` is ambiguous (derive helper attribute vs any other name)
|
|
||||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:9:3
|
|
||||||
|
|
|
||||||
LL | #[helper]
|
|
||||||
| ^^^^^^ ambiguous name
|
|
||||||
|
|
|
||||||
note: `helper` could refer to the derive helper attribute defined here
|
|
||||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:8:10
|
|
||||||
|
|
|
||||||
LL | #[derive(WithHelper)]
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
note: `helper` could also refer to the attribute macro imported here
|
|
||||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:6:5
|
|
||||||
|
|
|
||||||
LL | use plugin::helper;
|
|
||||||
| ^^^^^^^^^^^^^^
|
|
||||||
= help: use `crate::helper` to refer to this attribute macro unambiguously
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0659`.
|
|
|
@ -1,28 +0,0 @@
|
||||||
// compile-pass
|
|
||||||
// aux-build:plugin.rs
|
|
||||||
|
|
||||||
#[macro_use(WithHelper)]
|
|
||||||
extern crate plugin;
|
|
||||||
|
|
||||||
use self::one::*;
|
|
||||||
use self::two::*;
|
|
||||||
|
|
||||||
mod helper {}
|
|
||||||
|
|
||||||
mod one {
|
|
||||||
use helper;
|
|
||||||
|
|
||||||
#[derive(WithHelper)]
|
|
||||||
#[helper]
|
|
||||||
struct One;
|
|
||||||
}
|
|
||||||
|
|
||||||
mod two {
|
|
||||||
use helper;
|
|
||||||
|
|
||||||
#[derive(WithHelper)]
|
|
||||||
#[helper]
|
|
||||||
struct Two;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,12 +0,0 @@
|
||||||
// aux-build:plugin.rs
|
|
||||||
|
|
||||||
|
|
||||||
#[macro_use] extern crate plugin;
|
|
||||||
|
|
||||||
#[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked
|
|
||||||
struct Baz {
|
|
||||||
a: i32,
|
|
||||||
b: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,10 +0,0 @@
|
||||||
error: proc-macro derive panicked
|
|
||||||
--> $DIR/issue-36935.rs:6:15
|
|
||||||
|
|
|
||||||
LL | #[derive(Foo, Bar)]
|
|
||||||
| ^^^
|
|
||||||
|
|
|
||||||
= help: message: lolnope
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
// aux-build:attr_proc_macro.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
extern crate attr_proc_macro;
|
#[macro_use]
|
||||||
use attr_proc_macro::*;
|
extern crate test_macros;
|
||||||
|
|
||||||
#[attr_proc_macro] // OK
|
#[identity_attr] // OK
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Before;
|
struct Before;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]`
|
#[identity_attr] //~ ERROR macro attributes must be placed before `#[derive]`
|
||||||
struct After;
|
struct After;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: macro attributes must be placed before `#[derive]`
|
error: macro attributes must be placed before `#[derive]`
|
||||||
--> $DIR/attribute-order-restricted.rs:11:1
|
--> $DIR/attribute-order-restricted.rs:11:1
|
||||||
|
|
|
|
||||||
LL | #[attr_proc_macro]
|
LL | #[identity_attr]
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
// aux-build:attribute-with-error.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#![feature(custom_inner_attributes)]
|
#![feature(custom_inner_attributes)]
|
||||||
|
|
||||||
extern crate attribute_with_error;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
use attribute_with_error::foo;
|
#[recollect_attr]
|
||||||
|
|
||||||
#[foo]
|
|
||||||
fn test1() {
|
fn test1() {
|
||||||
let a: i32 = "foo";
|
let a: i32 = "foo";
|
||||||
//~^ ERROR: mismatched types
|
//~^ ERROR: mismatched types
|
||||||
|
@ -15,13 +14,13 @@ fn test1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test2() {
|
fn test2() {
|
||||||
#![foo]
|
#![recollect_attr]
|
||||||
|
|
||||||
// FIXME: should have a type error here and assert it works but it doesn't
|
// FIXME: should have a type error here and assert it works but it doesn't
|
||||||
}
|
}
|
||||||
|
|
||||||
trait A {
|
trait A {
|
||||||
// FIXME: should have a #[foo] attribute here and assert that it works
|
// FIXME: should have a #[recollect_attr] attribute here and assert that it works
|
||||||
fn foo(&self) {
|
fn foo(&self) {
|
||||||
let a: i32 = "foo";
|
let a: i32 = "foo";
|
||||||
//~^ ERROR: mismatched types
|
//~^ ERROR: mismatched types
|
||||||
|
@ -31,13 +30,13 @@ fn foo(&self) {
|
||||||
struct B;
|
struct B;
|
||||||
|
|
||||||
impl A for B {
|
impl A for B {
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
fn foo(&self) {
|
fn foo(&self) {
|
||||||
let a: i32 = "foo";
|
let a: i32 = "foo";
|
||||||
//~^ ERROR: mismatched types
|
//~^ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/attribute-with-error.rs:11:18
|
--> $DIR/attribute-with-error.rs:10:18
|
||||||
|
|
|
|
||||||
LL | let a: i32 = "foo";
|
LL | let a: i32 = "foo";
|
||||||
| ^^^^^ expected i32, found reference
|
| ^^^^^ expected i32, found reference
|
||||||
|
@ -8,7 +8,7 @@ LL | let a: i32 = "foo";
|
||||||
found type `&'static str`
|
found type `&'static str`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/attribute-with-error.rs:13:18
|
--> $DIR/attribute-with-error.rs:12:18
|
||||||
|
|
|
|
||||||
LL | let b: i32 = "f'oo";
|
LL | let b: i32 = "f'oo";
|
||||||
| ^^^^^^ expected i32, found reference
|
| ^^^^^^ expected i32, found reference
|
||||||
|
@ -17,7 +17,7 @@ LL | let b: i32 = "f'oo";
|
||||||
found type `&'static str`
|
found type `&'static str`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/attribute-with-error.rs:26:22
|
--> $DIR/attribute-with-error.rs:25:22
|
||||||
|
|
|
|
||||||
LL | let a: i32 = "foo";
|
LL | let a: i32 = "foo";
|
||||||
| ^^^^^ expected i32, found reference
|
| ^^^^^ expected i32, found reference
|
||||||
|
@ -26,7 +26,7 @@ LL | let a: i32 = "foo";
|
||||||
found type `&'static str`
|
found type `&'static str`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/attribute-with-error.rs:36:22
|
--> $DIR/attribute-with-error.rs:35:22
|
||||||
|
|
|
|
||||||
LL | let a: i32 = "foo";
|
LL | let a: i32 = "foo";
|
||||||
| ^^^^^ expected i32, found reference
|
| ^^^^^ expected i32, found reference
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn foo(_attr: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input.into_iter().collect()
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn bang_proc_macro(input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_derive(A)]
|
|
||||||
pub fn derive_a(_: TokenStream) -> TokenStream {
|
|
||||||
"".parse().unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_derive(B)]
|
|
||||||
pub fn derive_b(_: TokenStream) -> TokenStream {
|
|
||||||
"".parse().unwrap()
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_derive(A)]
|
|
||||||
pub fn derive_a(input: TokenStream) -> TokenStream {
|
|
||||||
"".parse().unwrap()
|
|
||||||
}
|
|
|
@ -1,2 +1,2 @@
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! my_attr { () => () }
|
macro_rules! empty_helper { () => () }
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::*;
|
|
||||||
|
|
||||||
#[proc_macro_derive(MyTrait, attributes(my_attr))]
|
|
||||||
pub fn foo(_: TokenStream) -> TokenStream {
|
|
||||||
TokenStream::new()
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::*;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn my_attr(_: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_derive(MyTrait, attributes(my_attr))]
|
|
||||||
pub fn derive(input: TokenStream) -> TokenStream {
|
|
||||||
TokenStream::new()
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_derive(A)]
|
|
||||||
pub fn derive_a(_input: TokenStream) -> TokenStream {
|
|
||||||
panic!("nope!");
|
|
||||||
}
|
|
|
@ -3,14 +3,14 @@
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! external {
|
macro_rules! external {
|
||||||
() => {
|
() => {
|
||||||
dollar_crate::m! {
|
print_bang! {
|
||||||
struct M($crate::S);
|
struct M($crate::S);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dollar_crate::a]
|
#[print_attr]
|
||||||
struct A($crate::S);
|
struct A($crate::S);
|
||||||
|
|
||||||
#[derive(dollar_crate::d)]
|
#[derive(Print)]
|
||||||
struct D($crate::S);
|
struct D($crate::S);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn m_empty(input: TokenStream) -> TokenStream {
|
|
||||||
println!("PROC MACRO INPUT (PRETTY-PRINTED): {}", input);
|
|
||||||
println!("PROC MACRO INPUT: {:#?}", input);
|
|
||||||
TokenStream::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn m(input: TokenStream) -> TokenStream {
|
|
||||||
println!("PROC MACRO INPUT (PRETTY-PRINTED): {}", input);
|
|
||||||
println!("PROC MACRO INPUT: {:#?}", input);
|
|
||||||
input.into_iter().collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn a(_args: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
println!("ATTRIBUTE INPUT (PRETTY-PRINTED): {}", input);
|
|
||||||
println!("ATTRIBUTE INPUT: {:#?}", input);
|
|
||||||
input.into_iter().collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_derive(d)]
|
|
||||||
pub fn d(input: TokenStream) -> TokenStream {
|
|
||||||
println!("DERIVE INPUT (PRETTY-PRINTED): {}", input);
|
|
||||||
println!("DERIVE INPUT: {:#?}", input);
|
|
||||||
input.into_iter().collect()
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn emit_unchanged(_args: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::*;
|
|
||||||
|
|
||||||
#[proc_macro_derive(MyTrait, attributes(my_attr))]
|
|
||||||
pub fn foo(_: TokenStream) -> TokenStream {
|
|
||||||
TokenStream::new()
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::*;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn doit(_: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input.into_iter().collect()
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::*;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn foo(_: TokenStream, item: TokenStream) -> TokenStream {
|
|
||||||
item.into_iter().collect()
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::*;
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn m(a: TokenStream) -> TokenStream {
|
|
||||||
a
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn a(_a: TokenStream, b: TokenStream) -> TokenStream {
|
|
||||||
b
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
// force-host
|
|
||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn foo(_: TokenStream, input: TokenStream) -> TokenStream {
|
|
||||||
input.into_iter().collect()
|
|
||||||
}
|
|
|
@ -1,26 +1,112 @@
|
||||||
// force-host
|
// force-host
|
||||||
// no-prefer-dynamic
|
// no-prefer-dynamic
|
||||||
|
|
||||||
|
// Proc macros commonly used by tests.
|
||||||
|
// `panic`/`print` -> `panic_bang`/`print_bang` to avoid conflicts with standard macros.
|
||||||
|
|
||||||
#![crate_type = "proc-macro"]
|
#![crate_type = "proc-macro"]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
// Macro that return empty token stream.
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn empty(_: TokenStream) -> TokenStream {
|
||||||
|
TokenStream::new()
|
||||||
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn empty_attr(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||||
assert!(_attr.to_string().is_empty());
|
TokenStream::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_derive(Empty, attributes(empty_helper))]
|
||||||
|
pub fn empty_derive(_: TokenStream) -> TokenStream {
|
||||||
|
TokenStream::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Macro that panics.
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn panic_bang(_: TokenStream) -> TokenStream {
|
||||||
|
panic!("panic-bang");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn panic_attr(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||||
|
panic!("panic-attr");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_derive(Panic, attributes(panic_helper))]
|
||||||
|
pub fn panic_derive(_: TokenStream) -> TokenStream {
|
||||||
|
panic!("panic-derive");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Macros that return the input stream.
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn identity(input: TokenStream) -> TokenStream {
|
||||||
input
|
input
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream {
|
pub fn identity_attr(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
assert!(_attr.to_string().is_empty());
|
input
|
||||||
assert!(!_input.to_string().is_empty());
|
}
|
||||||
"".parse().unwrap()
|
|
||||||
|
#[proc_macro_derive(Identity, attributes(identity_helper))]
|
||||||
|
pub fn identity_derive(input: TokenStream) -> TokenStream {
|
||||||
|
input
|
||||||
|
}
|
||||||
|
|
||||||
|
// Macros that iterate and re-collect the input stream.
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn recollect(input: TokenStream) -> TokenStream {
|
||||||
|
input.into_iter().collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn recollect_attr(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
|
input.into_iter().collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_derive(Recollect, attributes(recollect_helper))]
|
||||||
|
pub fn recollect_derive(input: TokenStream) -> TokenStream {
|
||||||
|
input.into_iter().collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Macros that print their input in the original and re-collected forms (if they differ).
|
||||||
|
|
||||||
|
fn print_helper(input: TokenStream, kind: &str) -> TokenStream {
|
||||||
|
let input_display = format!("{}", input);
|
||||||
|
let input_debug = format!("{:#?}", input);
|
||||||
|
let recollected = input.into_iter().collect();
|
||||||
|
let recollected_display = format!("{}", recollected);
|
||||||
|
let recollected_debug = format!("{:#?}", recollected);
|
||||||
|
println!("PRINT-{} INPUT (DISPLAY): {}", kind, input_display);
|
||||||
|
if recollected_display != input_display {
|
||||||
|
println!("PRINT-{} RE-COLLECTED (DISPLAY): {}", kind, recollected_display);
|
||||||
|
}
|
||||||
|
println!("PRINT-{} INPUT (DEBUG): {}", kind, input_debug);
|
||||||
|
if recollected_debug != input_debug {
|
||||||
|
println!("PRINT-{} RE-COLLECTED (DEBUG): {}", kind, recollected_debug);
|
||||||
|
}
|
||||||
|
recollected
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn emit_input(input: TokenStream) -> TokenStream {
|
pub fn print_bang(input: TokenStream) -> TokenStream {
|
||||||
input
|
print_helper(input, "BANG")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn print_attr(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
|
print_helper(input, "ATTR")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_derive(Print, attributes(print_helper))]
|
||||||
|
pub fn print_derive(input: TokenStream) -> TokenStream {
|
||||||
|
print_helper(input, "DERIVE")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// aux-build:derive-helper-shadowed.rs
|
// aux-build:test-macros.rs
|
||||||
// aux-build:derive-helper-shadowed-2.rs
|
// aux-build:derive-helper-shadowed-2.rs
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_helper_shadowed;
|
extern crate test_macros;
|
||||||
#[macro_use(my_attr)]
|
#[macro_use(empty_helper)]
|
||||||
extern crate derive_helper_shadowed_2;
|
extern crate derive_helper_shadowed_2;
|
||||||
|
|
||||||
macro_rules! my_attr { () => () }
|
macro_rules! empty_helper { () => () }
|
||||||
|
|
||||||
#[derive(MyTrait)]
|
#[derive(Empty)]
|
||||||
#[my_attr] // OK
|
#[empty_helper] // OK
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
// aux-build:derive-helper-shadowing.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
extern crate derive_helper_shadowing;
|
#[macro_use]
|
||||||
use derive_helper_shadowing::*;
|
extern crate test_macros;
|
||||||
|
|
||||||
#[my_attr] //~ ERROR `my_attr` is ambiguous
|
use test_macros::empty_attr as empty_helper;
|
||||||
#[derive(MyTrait)]
|
|
||||||
|
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
|
||||||
|
#[derive(Empty)]
|
||||||
struct S {
|
struct S {
|
||||||
// FIXME No ambiguity, attributes in non-macro positions are not resolved properly
|
// FIXME No ambiguity, attributes in non-macro positions are not resolved properly
|
||||||
#[my_attr]
|
#[empty_helper]
|
||||||
field: [u8; {
|
field: [u8; {
|
||||||
// FIXME No ambiguity, derive helpers are not put into scope for non-attributes
|
// FIXME No ambiguity, derive helpers are not put into scope for non-attributes
|
||||||
use my_attr;
|
use empty_helper;
|
||||||
|
|
||||||
// FIXME No ambiguity, derive helpers are not put into scope for inner items
|
// FIXME No ambiguity, derive helpers are not put into scope for inner items
|
||||||
#[my_attr]
|
#[empty_helper]
|
||||||
struct U;
|
struct U;
|
||||||
|
|
||||||
mod inner {
|
mod inner {
|
||||||
#[my_attr] //~ ERROR attribute `my_attr` is currently unknown
|
#[empty_helper] //~ ERROR attribute `empty_helper` is currently unknown
|
||||||
struct V;
|
struct V;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
error[E0658]: The attribute `my_attr` is currently unknown to the compiler and may have meaning added to it in the future
|
error[E0658]: The attribute `empty_helper` is currently unknown to the compiler and may have meaning added to it in the future
|
||||||
--> $DIR/derive-helper-shadowing.rs:20:15
|
--> $DIR/derive-helper-shadowing.rs:22:15
|
||||||
|
|
|
|
||||||
LL | #[my_attr]
|
LL | #[empty_helper]
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
||||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name)
|
error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
|
||||||
--> $DIR/derive-helper-shadowing.rs:6:3
|
--> $DIR/derive-helper-shadowing.rs:8:3
|
||||||
|
|
|
|
||||||
LL | #[my_attr]
|
LL | #[empty_helper]
|
||||||
| ^^^^^^^ ambiguous name
|
| ^^^^^^^^^^^^ ambiguous name
|
||||||
|
|
|
|
||||||
note: `my_attr` could refer to the derive helper attribute defined here
|
note: `empty_helper` could refer to the derive helper attribute defined here
|
||||||
--> $DIR/derive-helper-shadowing.rs:7:10
|
--> $DIR/derive-helper-shadowing.rs:9:10
|
||||||
|
|
|
|
||||||
LL | #[derive(MyTrait)]
|
LL | #[derive(Empty)]
|
||||||
| ^^^^^^^
|
| ^^^^^
|
||||||
note: `my_attr` could also refer to the attribute macro imported here
|
note: `empty_helper` could also refer to the attribute macro imported here
|
||||||
--> $DIR/derive-helper-shadowing.rs:4:5
|
--> $DIR/derive-helper-shadowing.rs:6:5
|
||||||
|
|
|
|
||||||
LL | use derive_helper_shadowing::*;
|
LL | use test_macros::empty_attr as empty_helper;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= help: use `crate::my_attr` to refer to this attribute macro unambiguously
|
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
13
src/test/ui/proc-macro/derive-in-mod.rs
Normal file
13
src/test/ui/proc-macro/derive-in-mod.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// compile-pass
|
||||||
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
|
mod inner {
|
||||||
|
use test_macros::Empty;
|
||||||
|
|
||||||
|
#[derive(Empty)]
|
||||||
|
struct S;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,11 +1,9 @@
|
||||||
// aux-build:derive-a.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#![allow(warnings)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_a;
|
extern crate test_macros;
|
||||||
|
|
||||||
#[derive_A] //~ ERROR attribute `derive_A` is currently unknown
|
#[derive_Empty] //~ ERROR attribute `derive_Empty` is currently unknown
|
||||||
struct A;
|
struct A;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0658]: The attribute `derive_A` is currently unknown to the compiler and may have meaning added to it in the future
|
error[E0658]: The attribute `derive_Empty` is currently unknown to the compiler and may have meaning added to it in the future
|
||||||
--> $DIR/derive-still-gated.rs:8:3
|
--> $DIR/derive-still-gated.rs:6:3
|
||||||
|
|
|
|
||||||
LL | #[derive_A]
|
LL | #[derive_Empty]
|
||||||
| ^^^^^^^^ help: a built-in attribute with a similar name exists: `derive`
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
||||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// edition:2018
|
// edition:2018
|
||||||
// aux-build:dollar-crate.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
|
// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
|
||||||
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
|
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
|
||||||
// normalize-stdout-test "bytes\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
|
// normalize-stdout-test "bytes\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
|
||||||
|
|
||||||
extern crate dollar_crate;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
type S = u8;
|
type S = u8;
|
||||||
|
|
||||||
macro_rules! m {
|
macro_rules! m {
|
||||||
() => {
|
() => {
|
||||||
dollar_crate::m_empty! {
|
print_bang! {
|
||||||
struct M($crate::S);
|
struct M($crate::S);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dollar_crate::a]
|
#[print_attr]
|
||||||
struct A($crate::S);
|
struct A($crate::S);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
PROC MACRO INPUT (PRETTY-PRINTED): struct M ( $crate :: S ) ;
|
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
|
||||||
PROC MACRO INPUT: TokenStream [
|
PRINT-BANG INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
|
@ -38,8 +38,9 @@ PROC MACRO INPUT: TokenStream [
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
ATTRIBUTE INPUT (PRETTY-PRINTED): struct A(crate::S);
|
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
|
||||||
ATTRIBUTE INPUT: TokenStream [
|
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
|
||||||
|
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
|
|
|
@ -1,29 +1,28 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
// aux-build:dollar-crate.rs
|
// aux-build:test-macros.rs
|
||||||
// aux-build:dollar-crate-external.rs
|
// aux-build:dollar-crate-external.rs
|
||||||
|
|
||||||
// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
|
// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
|
||||||
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
|
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
|
||||||
// normalize-stdout-test "bytes\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
|
// normalize-stdout-test "bytes\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
|
||||||
|
|
||||||
extern crate dollar_crate;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
extern crate dollar_crate_external;
|
extern crate dollar_crate_external;
|
||||||
|
|
||||||
type S = u8;
|
type S = u8;
|
||||||
|
|
||||||
mod local {
|
mod local {
|
||||||
use crate::dollar_crate;
|
|
||||||
|
|
||||||
macro_rules! local {
|
macro_rules! local {
|
||||||
() => {
|
() => {
|
||||||
dollar_crate::m! {
|
print_bang! {
|
||||||
struct M($crate::S);
|
struct M($crate::S);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dollar_crate::a]
|
#[print_attr]
|
||||||
struct A($crate::S);
|
struct A($crate::S);
|
||||||
|
|
||||||
#[derive(dollar_crate::d)]
|
#[derive(Print)]
|
||||||
struct D($crate::S); //~ ERROR the name `D` is defined multiple times
|
struct D($crate::S); //~ ERROR the name `D` is defined multiple times
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0428]: the name `D` is defined multiple times
|
error[E0428]: the name `D` is defined multiple times
|
||||||
--> $DIR/dollar-crate.rs:27:13
|
--> $DIR/dollar-crate.rs:26:13
|
||||||
|
|
|
|
||||||
LL | struct D($crate::S);
|
LL | struct D($crate::S);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -13,7 +13,7 @@ LL | local!();
|
||||||
= note: `D` must be defined only once in the type namespace of this module
|
= note: `D` must be defined only once in the type namespace of this module
|
||||||
|
|
||||||
error[E0428]: the name `D` is defined multiple times
|
error[E0428]: the name `D` is defined multiple times
|
||||||
--> $DIR/dollar-crate.rs:37:5
|
--> $DIR/dollar-crate.rs:36:5
|
||||||
|
|
|
|
||||||
LL | dollar_crate_external::external!();
|
LL | dollar_crate_external::external!();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
PROC MACRO INPUT (PRETTY-PRINTED): struct M ( $crate :: S ) ;
|
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
|
||||||
PROC MACRO INPUT: TokenStream [
|
PRINT-BANG INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
|
@ -38,8 +38,9 @@ PROC MACRO INPUT: TokenStream [
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
ATTRIBUTE INPUT (PRETTY-PRINTED): struct A(crate::S);
|
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
|
||||||
ATTRIBUTE INPUT: TokenStream [
|
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
|
||||||
|
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
|
@ -78,8 +79,9 @@ ATTRIBUTE INPUT: TokenStream [
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
DERIVE INPUT (PRETTY-PRINTED): struct D(crate::S);
|
PRINT-DERIVE INPUT (DISPLAY): struct D(crate::S);
|
||||||
DERIVE INPUT: TokenStream [
|
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
|
||||||
|
PRINT-DERIVE INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
|
@ -118,8 +120,8 @@ DERIVE INPUT: TokenStream [
|
||||||
span: #2 bytes(LO..HI),
|
span: #2 bytes(LO..HI),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
PROC MACRO INPUT (PRETTY-PRINTED): struct M ( $crate :: S ) ;
|
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
|
||||||
PROC MACRO INPUT: TokenStream [
|
PRINT-BANG INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #10 bytes(LO..HI),
|
span: #10 bytes(LO..HI),
|
||||||
|
@ -158,8 +160,9 @@ PROC MACRO INPUT: TokenStream [
|
||||||
span: #10 bytes(LO..HI),
|
span: #10 bytes(LO..HI),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
ATTRIBUTE INPUT (PRETTY-PRINTED): struct A(::dollar_crate_external::S);
|
PRINT-ATTR INPUT (DISPLAY): struct A(::dollar_crate_external::S);
|
||||||
ATTRIBUTE INPUT: TokenStream [
|
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
|
||||||
|
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #10 bytes(LO..HI),
|
span: #10 bytes(LO..HI),
|
||||||
|
@ -198,8 +201,9 @@ ATTRIBUTE INPUT: TokenStream [
|
||||||
span: #10 bytes(LO..HI),
|
span: #10 bytes(LO..HI),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
DERIVE INPUT (PRETTY-PRINTED): struct D(::dollar_crate_external::S);
|
PRINT-DERIVE INPUT (DISPLAY): struct D(::dollar_crate_external::S);
|
||||||
DERIVE INPUT: TokenStream [
|
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
|
||||||
|
PRINT-DERIVE INPUT (DEBUG): TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "struct",
|
ident: "struct",
|
||||||
span: #10 bytes(LO..HI),
|
span: #10 bytes(LO..HI),
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
|
#[macro_use(Empty)]
|
||||||
|
extern crate test_macros;
|
||||||
|
use test_macros::empty_attr as empty_helper;
|
||||||
|
|
||||||
|
#[derive(Empty)]
|
||||||
|
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
|
||||||
|
struct S;
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,21 @@
|
||||||
|
error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
|
||||||
|
--> $DIR/helper-attr-blocked-by-import-ambig.rs:8:3
|
||||||
|
|
|
||||||
|
LL | #[empty_helper]
|
||||||
|
| ^^^^^^^^^^^^ ambiguous name
|
||||||
|
|
|
||||||
|
note: `empty_helper` could refer to the derive helper attribute defined here
|
||||||
|
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:10
|
||||||
|
|
|
||||||
|
LL | #[derive(Empty)]
|
||||||
|
| ^^^^^
|
||||||
|
note: `empty_helper` could also refer to the attribute macro imported here
|
||||||
|
--> $DIR/helper-attr-blocked-by-import-ambig.rs:5:5
|
||||||
|
|
|
||||||
|
LL | use test_macros::empty_attr as empty_helper;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0659`.
|
28
src/test/ui/proc-macro/helper-attr-blocked-by-import.rs
Normal file
28
src/test/ui/proc-macro/helper-attr-blocked-by-import.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// compile-pass
|
||||||
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
|
#[macro_use(Empty)]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
|
use self::one::*;
|
||||||
|
use self::two::*;
|
||||||
|
|
||||||
|
mod empty_helper {}
|
||||||
|
|
||||||
|
mod one {
|
||||||
|
use empty_helper;
|
||||||
|
|
||||||
|
#[derive(Empty)]
|
||||||
|
#[empty_helper]
|
||||||
|
struct One;
|
||||||
|
}
|
||||||
|
|
||||||
|
mod two {
|
||||||
|
use empty_helper;
|
||||||
|
|
||||||
|
#[derive(Empty)]
|
||||||
|
#[empty_helper]
|
||||||
|
struct Two;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,11 +1,8 @@
|
||||||
// aux-build:derive-a.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#![allow(warnings)]
|
extern crate test_macros;
|
||||||
|
|
||||||
#[macro_use]
|
use test_macros::empty_derive;
|
||||||
extern crate derive_a;
|
//~^ ERROR: unresolved import `test_macros::empty_derive`
|
||||||
|
|
||||||
use derive_a::derive_a;
|
|
||||||
//~^ ERROR: unresolved import `derive_a::derive_a`
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0432]: unresolved import `derive_a::derive_a`
|
error[E0432]: unresolved import `test_macros::empty_derive`
|
||||||
--> $DIR/import.rs:8:5
|
--> $DIR/import.rs:5:5
|
||||||
|
|
|
|
||||||
LL | use derive_a::derive_a;
|
LL | use test_macros::empty_derive;
|
||||||
| ^^^^^^^^^^^^^^^^^^ no `derive_a` in the root
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ no `empty_derive` in the root
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
12
src/test/ui/proc-macro/issue-36935.rs
Normal file
12
src/test/ui/proc-macro/issue-36935.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
|
#[derive(Identity, Panic)] //~ ERROR proc-macro derive panicked
|
||||||
|
struct Baz {
|
||||||
|
a: i32,
|
||||||
|
b: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
10
src/test/ui/proc-macro/issue-36935.stderr
Normal file
10
src/test/ui/proc-macro/issue-36935.stderr
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
error: proc-macro derive panicked
|
||||||
|
--> $DIR/issue-36935.rs:6:20
|
||||||
|
|
|
||||||
|
LL | #[derive(Identity, Panic)]
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= help: message: panic-derive
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// aux-build:derive-a-b.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_a_b;
|
extern crate test_macros;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Test that constructing the `visible_parent_map` (in `cstore_impl.rs`) does not ICE.
|
// Test that constructing the `visible_parent_map` (in `cstore_impl.rs`) does not ICE.
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
// aux-build:issue-41211.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
// FIXME: https://github.com/rust-lang/rust/issues/41430
|
// FIXME: https://github.com/rust-lang/rust/issues/41430
|
||||||
// This is a temporary regression test for the ICE reported in #41211
|
// This is a temporary regression test for the ICE reported in #41211
|
||||||
|
|
||||||
#![feature(custom_inner_attributes)]
|
#![feature(custom_inner_attributes)]
|
||||||
|
|
||||||
#![emit_unchanged]
|
#![identity_attr]
|
||||||
//~^ ERROR attribute `emit_unchanged` is currently unknown to the compiler
|
//~^ ERROR attribute `identity_attr` is currently unknown to the compiler
|
||||||
//~| ERROR inconsistent resolution for a macro: first custom attribute, then attribute macro
|
//~| ERROR inconsistent resolution for a macro: first custom attribute, then attribute macro
|
||||||
extern crate issue_41211;
|
extern crate test_macros;
|
||||||
use issue_41211::emit_unchanged;
|
use test_macros::identity_attr;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0658]: The attribute `emit_unchanged` is currently unknown to the compiler and may have meaning added to it in the future
|
error[E0658]: The attribute `identity_attr` is currently unknown to the compiler and may have meaning added to it in the future
|
||||||
--> $DIR/issue-41211.rs:8:4
|
--> $DIR/issue-41211.rs:8:4
|
||||||
|
|
|
|
||||||
LL | #![emit_unchanged]
|
LL | #![identity_attr]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
||||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||||
|
@ -10,8 +10,8 @@ LL | #![emit_unchanged]
|
||||||
error: inconsistent resolution for a macro: first custom attribute, then attribute macro
|
error: inconsistent resolution for a macro: first custom attribute, then attribute macro
|
||||||
--> $DIR/issue-41211.rs:8:4
|
--> $DIR/issue-41211.rs:8:4
|
||||||
|
|
|
|
||||||
LL | #![emit_unchanged]
|
LL | #![identity_attr]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// aux-build:issue-53481.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate issue_53481;
|
extern crate test_macros;
|
||||||
|
|
||||||
mod m1 {
|
mod m1 {
|
||||||
use m2::MyTrait;
|
use m2::Empty;
|
||||||
|
|
||||||
#[derive(MyTrait)]
|
#[derive(Empty)]
|
||||||
struct A {}
|
struct A {}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod m2 {
|
mod m2 {
|
||||||
pub type MyTrait = u8;
|
pub type Empty = u8;
|
||||||
|
|
||||||
#[derive(MyTrait)]
|
#[derive(Empty)]
|
||||||
#[my_attr]
|
#[empty_helper]
|
||||||
struct B {}
|
struct B {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// aux-build:derive-panic.rs
|
// aux-build:test-macros.rs
|
||||||
// compile-flags:--error-format human
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_panic;
|
extern crate test_macros;
|
||||||
|
|
||||||
#[derive(A)]
|
#[derive(Panic)]
|
||||||
//~^ ERROR: proc-macro derive panicked
|
//~^ ERROR: proc-macro derive panicked
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: proc-macro derive panicked
|
error: proc-macro derive panicked
|
||||||
--> $DIR/load-panic.rs:7:10
|
--> $DIR/load-panic.rs:6:10
|
||||||
|
|
|
|
||||||
LL | #[derive(A)]
|
LL | #[derive(Panic)]
|
||||||
| ^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
= help: message: nope!
|
= help: message: panic-derive
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// aux-build:macro-brackets.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
extern crate macro_brackets as bar;
|
#[macro_use]
|
||||||
use bar::doit;
|
extern crate test_macros;
|
||||||
|
|
||||||
macro_rules! id {
|
macro_rules! id {
|
||||||
($($t:tt)*) => ($($t)*)
|
($($t:tt)*) => ($($t)*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doit]
|
#[identity_attr]
|
||||||
id![static X: u32 = 'a';]; //~ ERROR: mismatched types
|
id![static X: u32 = 'a';]; //~ ERROR: mismatched types
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// aux-build:attr_proc_macro.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#[macro_use] extern crate attr_proc_macro;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
#[attr_proc_macro]
|
#[identity_attr]
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// aux-build:bang_proc_macro.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bang_proc_macro;
|
extern crate test_macros;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
bang_proc_macro!(println!("Hello, world!"));
|
identity!(println!("Hello, world!"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// aux-build:test-macros.rs
|
// aux-build:test-macros.rs
|
||||||
// ignore-wasm32
|
// ignore-wasm32
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
extern crate test_macros;
|
extern crate test_macros;
|
||||||
|
|
||||||
use test_macros::{nop_attr, no_output, emit_input};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(unsafe { rust_get_test_int() }, 0isize);
|
assert_eq!(unsafe { rust_get_test_int() }, 0isize);
|
||||||
assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF);
|
assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF);
|
||||||
|
@ -12,14 +11,14 @@ fn main() {
|
||||||
|
|
||||||
#[link(name = "rust_test_helpers", kind = "static")]
|
#[link(name = "rust_test_helpers", kind = "static")]
|
||||||
extern {
|
extern {
|
||||||
#[no_output]
|
#[empty_attr]
|
||||||
//~^ ERROR macro invocations in `extern {}` blocks are experimental
|
//~^ ERROR macro invocations in `extern {}` blocks are experimental
|
||||||
fn some_definitely_unknown_symbol_which_should_be_removed();
|
fn some_definitely_unknown_symbol_which_should_be_removed();
|
||||||
|
|
||||||
#[nop_attr]
|
#[identity_attr]
|
||||||
//~^ ERROR macro invocations in `extern {}` blocks are experimental
|
//~^ ERROR macro invocations in `extern {}` blocks are experimental
|
||||||
fn rust_get_test_int() -> isize;
|
fn rust_get_test_int() -> isize;
|
||||||
|
|
||||||
emit_input!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;);
|
identity!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;);
|
||||||
//~^ ERROR macro invocations in `extern {}` blocks are experimental
|
//~^ ERROR macro invocations in `extern {}` blocks are experimental
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
error[E0658]: macro invocations in `extern {}` blocks are experimental
|
error[E0658]: macro invocations in `extern {}` blocks are experimental
|
||||||
--> $DIR/macros-in-extern.rs:15:5
|
--> $DIR/macros-in-extern.rs:14:5
|
||||||
|
|
|
|
||||||
LL | #[no_output]
|
LL | #[empty_attr]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/49476
|
= note: for more information, see https://github.com/rust-lang/rust/issues/49476
|
||||||
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
|
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: macro invocations in `extern {}` blocks are experimental
|
error[E0658]: macro invocations in `extern {}` blocks are experimental
|
||||||
--> $DIR/macros-in-extern.rs:19:5
|
--> $DIR/macros-in-extern.rs:18:5
|
||||||
|
|
|
|
||||||
LL | #[nop_attr]
|
LL | #[identity_attr]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/49476
|
= note: for more information, see https://github.com/rust-lang/rust/issues/49476
|
||||||
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
|
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: macro invocations in `extern {}` blocks are experimental
|
error[E0658]: macro invocations in `extern {}` blocks are experimental
|
||||||
--> $DIR/macros-in-extern.rs:23:5
|
--> $DIR/macros-in-extern.rs:22:5
|
||||||
|
|
|
|
||||||
LL | emit_input!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;);
|
LL | identity!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/49476
|
= note: for more information, see https://github.com/rust-lang/rust/issues/49476
|
||||||
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
|
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// aux-build:nested-item-spans.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
extern crate nested_item_spans;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
use nested_item_spans::foo;
|
#[recollect_attr]
|
||||||
|
|
||||||
#[foo]
|
|
||||||
fn another() {
|
fn another() {
|
||||||
fn bar() {
|
fn bar() {
|
||||||
let x: u32 = "x"; //~ ERROR: mismatched types
|
let x: u32 = "x"; //~ ERROR: mismatched types
|
||||||
|
@ -14,7 +13,7 @@ fn bar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
fn bar() {
|
fn bar() {
|
||||||
let x: u32 = "x"; //~ ERROR: mismatched types
|
let x: u32 = "x"; //~ ERROR: mismatched types
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/nested-item-spans.rs:10:22
|
--> $DIR/nested-item-spans.rs:9:22
|
||||||
|
|
|
|
||||||
LL | let x: u32 = "x";
|
LL | let x: u32 = "x";
|
||||||
| ^^^ expected u32, found reference
|
| ^^^ expected u32, found reference
|
||||||
|
@ -8,7 +8,7 @@ LL | let x: u32 = "x";
|
||||||
found type `&'static str`
|
found type `&'static str`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/nested-item-spans.rs:19:22
|
--> $DIR/nested-item-spans.rs:18:22
|
||||||
|
|
|
|
||||||
LL | let x: u32 = "x";
|
LL | let x: u32 = "x";
|
||||||
| ^^^ expected u32, found reference
|
| ^^^ expected u32, found reference
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// aux-build:derive-a.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![warn(unused_extern_crates)]
|
#![warn(unused_extern_crates)]
|
||||||
|
|
||||||
extern crate derive_a;
|
extern crate test_macros;
|
||||||
//~^ WARN unused extern crate
|
//~^ WARN unused extern crate
|
||||||
|
|
||||||
#[rustc_error]
|
#[rustc_error]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
warning: unused extern crate
|
warning: unused extern crate
|
||||||
--> $DIR/no-macro-use-attr.rs:6:1
|
--> $DIR/no-macro-use-attr.rs:6:1
|
||||||
|
|
|
|
||||||
LL | extern crate derive_a;
|
LL | extern crate test_macros;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
||||||
|
|
|
|
||||||
note: lint level defined here
|
note: lint level defined here
|
||||||
--> $DIR/no-macro-use-attr.rs:4:9
|
--> $DIR/no-macro-use-attr.rs:4:9
|
||||||
|
|
|
@ -1,61 +1,62 @@
|
||||||
// aux-build:proc-macro-gates.rs
|
// aux-build:test-macros.rs
|
||||||
// gate-test-proc_macro_hygiene
|
// gate-test-proc_macro_hygiene
|
||||||
|
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
|
||||||
extern crate proc_macro_gates as foo;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
use foo::*;
|
|
||||||
|
|
||||||
fn _test_inner() {
|
fn _test_inner() {
|
||||||
#![a] //~ ERROR: non-builtin inner attributes are unstable
|
#![empty_attr] //~ ERROR: non-builtin inner attributes are unstable
|
||||||
}
|
}
|
||||||
|
|
||||||
#[a] //~ ERROR: custom attributes cannot be applied to modules
|
#[empty_attr] //~ ERROR: custom attributes cannot be applied to modules
|
||||||
mod _test2 {}
|
mod _test2 {}
|
||||||
|
|
||||||
mod _test2_inner {
|
mod _test2_inner {
|
||||||
#![a] //~ ERROR: custom attributes cannot be applied to modules
|
#![empty_attr] //~ ERROR: custom attributes cannot be applied to modules
|
||||||
//~| ERROR: non-builtin inner attributes are unstable
|
//~| ERROR: non-builtin inner attributes are unstable
|
||||||
}
|
}
|
||||||
|
|
||||||
#[a = "y"] //~ ERROR: must only be followed by a delimiter token
|
#[empty_attr = "y"] //~ ERROR: must only be followed by a delimiter token
|
||||||
fn _test3() {}
|
fn _test3() {}
|
||||||
|
|
||||||
fn attrs() {
|
fn attrs() {
|
||||||
// Statement, item
|
// Statement, item
|
||||||
#[a] // OK
|
#[empty_attr] // OK
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
// Statement, macro
|
// Statement, macro
|
||||||
#[a] //~ ERROR: custom attributes cannot be applied to statements
|
#[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
// Statement, semi
|
// Statement, semi
|
||||||
#[a] //~ ERROR: custom attributes cannot be applied to statements
|
#[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
|
||||||
S;
|
S;
|
||||||
|
|
||||||
// Statement, local
|
// Statement, local
|
||||||
#[a] //~ ERROR: custom attributes cannot be applied to statements
|
#[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
|
||||||
let _x = 2;
|
let _x = 2;
|
||||||
|
|
||||||
// Expr
|
// Expr
|
||||||
let _x = #[a] 2; //~ ERROR: custom attributes cannot be applied to expressions
|
let _x = #[identity_attr] 2; //~ ERROR: custom attributes cannot be applied to expressions
|
||||||
|
|
||||||
// Opt expr
|
// Opt expr
|
||||||
let _x = [#[a] 2]; //~ ERROR: custom attributes cannot be applied to expressions
|
let _x = [#[identity_attr] 2]; //~ ERROR: custom attributes cannot be applied to expressions
|
||||||
|
|
||||||
// Expr macro
|
// Expr macro
|
||||||
let _x = #[a] println!(); //~ ERROR: custom attributes cannot be applied to expressions
|
let _x = #[identity_attr] println!();
|
||||||
|
//~^ ERROR: custom attributes cannot be applied to expressions
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _x: m!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types
|
let _x: identity!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types
|
||||||
if let m!(Some(_x)) = Some(3) {} //~ ERROR: procedural macros cannot be expanded to patterns
|
if let identity!(Some(_x)) = Some(3) {}
|
||||||
|
//~^ ERROR: procedural macros cannot be expanded to patterns
|
||||||
|
|
||||||
m!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements
|
empty!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements
|
||||||
m!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements
|
empty!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements
|
||||||
|
|
||||||
let _x = m!(3); //~ ERROR: procedural macros cannot be expanded to expressions
|
let _x = identity!(3); //~ ERROR: procedural macros cannot be expanded to expressions
|
||||||
let _x = [m!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions
|
let _x = [empty!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,95 +1,95 @@
|
||||||
error[E0658]: non-builtin inner attributes are unstable
|
error[E0658]: non-builtin inner attributes are unstable
|
||||||
--> $DIR/proc-macro-gates.rs:11:5
|
--> $DIR/proc-macro-gates.rs:10:5
|
||||||
|
|
|
|
||||||
LL | #![a]
|
LL | #![empty_attr]
|
||||||
| ^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54726
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54726
|
||||||
= help: add #![feature(custom_inner_attributes)] to the crate attributes to enable
|
= help: add #![feature(custom_inner_attributes)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: non-builtin inner attributes are unstable
|
error[E0658]: non-builtin inner attributes are unstable
|
||||||
--> $DIR/proc-macro-gates.rs:18:5
|
--> $DIR/proc-macro-gates.rs:17:5
|
||||||
|
|
|
|
||||||
LL | #![a]
|
LL | #![empty_attr]
|
||||||
| ^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54726
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54726
|
||||||
= help: add #![feature(custom_inner_attributes)] to the crate attributes to enable
|
= help: add #![feature(custom_inner_attributes)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to modules
|
error[E0658]: custom attributes cannot be applied to modules
|
||||||
--> $DIR/proc-macro-gates.rs:14:1
|
--> $DIR/proc-macro-gates.rs:13:1
|
||||||
|
|
|
|
||||||
LL | #[a]
|
LL | #[empty_attr]
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to modules
|
error[E0658]: custom attributes cannot be applied to modules
|
||||||
--> $DIR/proc-macro-gates.rs:18:5
|
--> $DIR/proc-macro-gates.rs:17:5
|
||||||
|
|
|
|
||||||
LL | #![a]
|
LL | #![empty_attr]
|
||||||
| ^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error: custom attribute invocations must be of the form #[foo] or #[foo(..)], the macro name must only be followed by a delimiter token
|
error: custom attribute invocations must be of the form #[foo] or #[foo(..)], the macro name must only be followed by a delimiter token
|
||||||
--> $DIR/proc-macro-gates.rs:22:1
|
--> $DIR/proc-macro-gates.rs:21:1
|
||||||
|
|
|
|
||||||
LL | #[a = "y"]
|
LL | #[empty_attr = "y"]
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to statements
|
error[E0658]: custom attributes cannot be applied to statements
|
||||||
--> $DIR/proc-macro-gates.rs:31:5
|
--> $DIR/proc-macro-gates.rs:30:5
|
||||||
|
|
|
|
||||||
LL | #[a]
|
LL | #[empty_attr]
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to statements
|
error[E0658]: custom attributes cannot be applied to statements
|
||||||
--> $DIR/proc-macro-gates.rs:35:5
|
--> $DIR/proc-macro-gates.rs:34:5
|
||||||
|
|
|
|
||||||
LL | #[a]
|
LL | #[empty_attr]
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to statements
|
error[E0658]: custom attributes cannot be applied to statements
|
||||||
--> $DIR/proc-macro-gates.rs:39:5
|
--> $DIR/proc-macro-gates.rs:38:5
|
||||||
|
|
|
|
||||||
LL | #[a]
|
LL | #[empty_attr]
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to expressions
|
error[E0658]: custom attributes cannot be applied to expressions
|
||||||
--> $DIR/proc-macro-gates.rs:43:14
|
--> $DIR/proc-macro-gates.rs:42:14
|
||||||
|
|
|
|
||||||
LL | let _x = #[a] 2;
|
LL | let _x = #[identity_attr] 2;
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to expressions
|
error[E0658]: custom attributes cannot be applied to expressions
|
||||||
--> $DIR/proc-macro-gates.rs:46:15
|
--> $DIR/proc-macro-gates.rs:45:15
|
||||||
|
|
|
|
||||||
LL | let _x = [#[a] 2];
|
LL | let _x = [#[identity_attr] 2];
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: custom attributes cannot be applied to expressions
|
error[E0658]: custom attributes cannot be applied to expressions
|
||||||
--> $DIR/proc-macro-gates.rs:49:14
|
--> $DIR/proc-macro-gates.rs:48:14
|
||||||
|
|
|
|
||||||
LL | let _x = #[a] println!();
|
LL | let _x = #[identity_attr] println!();
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
@ -97,8 +97,8 @@ LL | let _x = #[a] println!();
|
||||||
error[E0658]: procedural macros cannot be expanded to types
|
error[E0658]: procedural macros cannot be expanded to types
|
||||||
--> $DIR/proc-macro-gates.rs:53:13
|
--> $DIR/proc-macro-gates.rs:53:13
|
||||||
|
|
|
|
||||||
LL | let _x: m!(u32) = 3;
|
LL | let _x: identity!(u32) = 3;
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
@ -106,17 +106,8 @@ LL | let _x: m!(u32) = 3;
|
||||||
error[E0658]: procedural macros cannot be expanded to patterns
|
error[E0658]: procedural macros cannot be expanded to patterns
|
||||||
--> $DIR/proc-macro-gates.rs:54:12
|
--> $DIR/proc-macro-gates.rs:54:12
|
||||||
|
|
|
|
||||||
LL | if let m!(Some(_x)) = Some(3) {}
|
LL | if let identity!(Some(_x)) = Some(3) {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
|
||||||
|
|
||||||
error[E0658]: procedural macros cannot be expanded to statements
|
|
||||||
--> $DIR/proc-macro-gates.rs:56:5
|
|
||||||
|
|
|
||||||
LL | m!(struct S;);
|
|
||||||
| ^^^^^^^^^^^^^^
|
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
@ -124,26 +115,35 @@ LL | m!(struct S;);
|
||||||
error[E0658]: procedural macros cannot be expanded to statements
|
error[E0658]: procedural macros cannot be expanded to statements
|
||||||
--> $DIR/proc-macro-gates.rs:57:5
|
--> $DIR/proc-macro-gates.rs:57:5
|
||||||
|
|
|
|
||||||
LL | m!(let _x = 3;);
|
LL | empty!(struct S;);
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: procedural macros cannot be expanded to statements
|
||||||
|
--> $DIR/proc-macro-gates.rs:58:5
|
||||||
|
|
|
||||||
|
LL | empty!(let _x = 3;);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: procedural macros cannot be expanded to expressions
|
error[E0658]: procedural macros cannot be expanded to expressions
|
||||||
--> $DIR/proc-macro-gates.rs:59:14
|
--> $DIR/proc-macro-gates.rs:60:14
|
||||||
|
|
|
|
||||||
LL | let _x = m!(3);
|
LL | let _x = identity!(3);
|
||||||
| ^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: procedural macros cannot be expanded to expressions
|
error[E0658]: procedural macros cannot be expanded to expressions
|
||||||
--> $DIR/proc-macro-gates.rs:60:15
|
--> $DIR/proc-macro-gates.rs:61:15
|
||||||
|
|
|
|
||||||
LL | let _x = [m!(3)];
|
LL | let _x = [empty!(3)];
|
||||||
| ^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||||
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
// aux-build:proc-macro-gates.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
|
||||||
extern crate proc_macro_gates as foo;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
use foo::*;
|
|
||||||
|
|
||||||
// NB. these errors aren't the best errors right now, but they're definitely
|
// NB. these errors aren't the best errors right now, but they're definitely
|
||||||
// intended to be errors. Somehow using a custom attribute in these positions
|
// intended to be errors. Somehow using a custom attribute in these positions
|
||||||
// should either require a feature gate or not be allowed on stable.
|
// should either require a feature gate or not be allowed on stable.
|
||||||
|
|
||||||
fn _test6<#[a] T>() {}
|
fn _test6<#[empty_attr] T>() {}
|
||||||
//~^ ERROR: unknown to the compiler
|
//~^ ERROR: unknown to the compiler
|
||||||
|
|
||||||
fn _test7() {
|
fn _test7() {
|
||||||
match 1 {
|
match 1 {
|
||||||
#[a] //~ ERROR: unknown to the compiler
|
#[empty_attr] //~ ERROR: unknown to the compiler
|
||||||
0 => {}
|
0 => {}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
error[E0658]: The attribute `a` is currently unknown to the compiler and may have meaning added to it in the future
|
error[E0658]: The attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future
|
||||||
--> $DIR/proc-macro-gates2.rs:13:11
|
--> $DIR/proc-macro-gates2.rs:12:11
|
||||||
|
|
|
|
||||||
LL | fn _test6<#[a] T>() {}
|
LL | fn _test6<#[empty_attr] T>() {}
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
||||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: The attribute `a` is currently unknown to the compiler and may have meaning added to it in the future
|
error[E0658]: The attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future
|
||||||
--> $DIR/proc-macro-gates2.rs:18:9
|
--> $DIR/proc-macro-gates2.rs:17:9
|
||||||
|
|
|
|
||||||
LL | #[a]
|
LL | #[empty_attr]
|
||||||
| ^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
|
||||||
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// aux-build:derive-foo.rs
|
// aux-build:derive-foo.rs
|
||||||
// aux-build:derive-clona.rs
|
// aux-build:derive-clona.rs
|
||||||
// aux-build:attr_proc_macro.rs
|
// aux-build:test-macros.rs
|
||||||
// aux-build:bang_proc_macro.rs
|
|
||||||
|
|
||||||
#![feature(custom_attribute)]
|
#![feature(custom_attribute)]
|
||||||
|
|
||||||
|
@ -9,11 +8,10 @@
|
||||||
extern crate derive_foo;
|
extern crate derive_foo;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_clona;
|
extern crate derive_clona;
|
||||||
extern crate attr_proc_macro;
|
extern crate test_macros;
|
||||||
extern crate bang_proc_macro;
|
|
||||||
|
|
||||||
use attr_proc_macro::attr_proc_macro;
|
use test_macros::empty as bang_proc_macro;
|
||||||
use bang_proc_macro::bang_proc_macro;
|
use test_macros::empty_attr as attr_proc_macro;
|
||||||
|
|
||||||
macro_rules! FooWithLongNam {
|
macro_rules! FooWithLongNam {
|
||||||
() => {}
|
() => {}
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
error: cannot find derive macro `FooWithLongNan` in this scope
|
error: cannot find derive macro `FooWithLongNan` in this scope
|
||||||
--> $DIR/resolve-error.rs:26:10
|
--> $DIR/resolve-error.rs:24:10
|
||||||
|
|
|
|
||||||
LL | #[derive(FooWithLongNan)]
|
LL | #[derive(FooWithLongNan)]
|
||||||
| ^^^^^^^^^^^^^^ help: try: `FooWithLongName`
|
| ^^^^^^^^^^^^^^ help: try: `FooWithLongName`
|
||||||
|
|
||||||
error: cannot find derive macro `Dlone` in this scope
|
error: cannot find derive macro `Dlone` in this scope
|
||||||
--> $DIR/resolve-error.rs:36:10
|
--> $DIR/resolve-error.rs:34:10
|
||||||
|
|
|
|
||||||
LL | #[derive(Dlone)]
|
LL | #[derive(Dlone)]
|
||||||
| ^^^^^ help: try: `Clone`
|
| ^^^^^ help: try: `Clone`
|
||||||
|
|
||||||
error: cannot find derive macro `Dlona` in this scope
|
error: cannot find derive macro `Dlona` in this scope
|
||||||
--> $DIR/resolve-error.rs:40:10
|
--> $DIR/resolve-error.rs:38:10
|
||||||
|
|
|
|
||||||
LL | #[derive(Dlona)]
|
LL | #[derive(Dlona)]
|
||||||
| ^^^^^ help: try: `Clona`
|
| ^^^^^ help: try: `Clona`
|
||||||
|
|
||||||
error: cannot find derive macro `attr_proc_macra` in this scope
|
error: cannot find derive macro `attr_proc_macra` in this scope
|
||||||
--> $DIR/resolve-error.rs:44:10
|
--> $DIR/resolve-error.rs:42:10
|
||||||
|
|
|
|
||||||
LL | #[derive(attr_proc_macra)]
|
LL | #[derive(attr_proc_macra)]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: cannot find macro `FooWithLongNama!` in this scope
|
error: cannot find macro `FooWithLongNama!` in this scope
|
||||||
--> $DIR/resolve-error.rs:49:5
|
--> $DIR/resolve-error.rs:47:5
|
||||||
|
|
|
|
||||||
LL | FooWithLongNama!();
|
LL | FooWithLongNama!();
|
||||||
| ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam`
|
| ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam`
|
||||||
|
|
||||||
error: cannot find macro `attr_proc_macra!` in this scope
|
error: cannot find macro `attr_proc_macra!` in this scope
|
||||||
--> $DIR/resolve-error.rs:52:5
|
--> $DIR/resolve-error.rs:50:5
|
||||||
|
|
|
|
||||||
LL | attr_proc_macra!();
|
LL | attr_proc_macra!();
|
||||||
| ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac`
|
| ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac`
|
||||||
|
|
||||||
error: cannot find macro `Dlona!` in this scope
|
error: cannot find macro `Dlona!` in this scope
|
||||||
--> $DIR/resolve-error.rs:55:5
|
--> $DIR/resolve-error.rs:53:5
|
||||||
|
|
|
|
||||||
LL | Dlona!();
|
LL | Dlona!();
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error: cannot find macro `bang_proc_macrp!` in this scope
|
error: cannot find macro `bang_proc_macrp!` in this scope
|
||||||
--> $DIR/resolve-error.rs:58:5
|
--> $DIR/resolve-error.rs:56:5
|
||||||
|
|
|
|
||||||
LL | bang_proc_macrp!();
|
LL | bang_proc_macrp!();
|
||||||
| ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro`
|
| ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// aux-build:derive-a.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_a;
|
extern crate test_macros;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derive_a; //~ ERROR the name `derive_a` is defined multiple times
|
extern crate test_macros; //~ ERROR the name `test_macros` is defined multiple times
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
error[E0259]: the name `derive_a` is defined multiple times
|
error[E0259]: the name `test_macros` is defined multiple times
|
||||||
--> $DIR/shadow.rs:6:1
|
--> $DIR/shadow.rs:6:1
|
||||||
|
|
|
|
||||||
LL | extern crate derive_a;
|
LL | extern crate test_macros;
|
||||||
| ---------------------- previous import of the extern crate `derive_a` here
|
| ------------------------- previous import of the extern crate `test_macros` here
|
||||||
LL | #[macro_use]
|
LL | #[macro_use]
|
||||||
LL | extern crate derive_a;
|
LL | extern crate test_macros;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `test_macros` reimported here
|
||||||
|
|
|
|
||||||
= note: `derive_a` must be defined only once in the type namespace of this module
|
= note: `test_macros` must be defined only once in the type namespace of this module
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
//~ ERROR mismatched types
|
//~ ERROR mismatched types
|
||||||
// aux-build:span-preservation.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
// For each of these, we should get the appropriate type mismatch error message,
|
// For each of these, we should get the appropriate type mismatch error message,
|
||||||
// and the function should be echoed.
|
// and the function should be echoed.
|
||||||
|
|
||||||
extern crate span_preservation as foo;
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
use foo::foo;
|
#[recollect_attr]
|
||||||
|
|
||||||
#[foo]
|
|
||||||
fn a() {
|
fn a() {
|
||||||
let x: usize = "hello";;;;; //~ ERROR mismatched types
|
let x: usize = "hello";;;;; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
fn b(x: Option<isize>) -> usize {
|
fn b(x: Option<isize>) -> usize {
|
||||||
match x {
|
match x {
|
||||||
Some(x) => { return x }, //~ ERROR mismatched types
|
Some(x) => { return x }, //~ ERROR mismatched types
|
||||||
|
@ -21,7 +20,7 @@ fn b(x: Option<isize>) -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
fn c() {
|
fn c() {
|
||||||
struct Foo {
|
struct Foo {
|
||||||
a: usize
|
a: usize
|
||||||
|
@ -39,12 +38,12 @@ struct Bar {
|
||||||
// FIXME: This doesn't work at the moment. See the one below. The pretty-printer
|
// FIXME: This doesn't work at the moment. See the one below. The pretty-printer
|
||||||
// injects a "C" between `extern` and `fn` which causes a "probably_eq"
|
// injects a "C" between `extern` and `fn` which causes a "probably_eq"
|
||||||
// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST.
|
// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST.
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
extern fn bar() {
|
extern fn bar() {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[foo]
|
#[recollect_attr]
|
||||||
extern "C" fn baz() {
|
extern "C" fn baz() {
|
||||||
0 //~ ERROR mismatched types
|
0 //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0308]: mismatched types
|
||||||
found type `{integer}`
|
found type `{integer}`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/span-preservation.rs:13:20
|
--> $DIR/span-preservation.rs:12:20
|
||||||
|
|
|
|
||||||
LL | let x: usize = "hello";;;;;
|
LL | let x: usize = "hello";;;;;
|
||||||
| ^^^^^^^ expected usize, found reference
|
| ^^^^^^^ expected usize, found reference
|
||||||
|
@ -13,7 +13,7 @@ LL | let x: usize = "hello";;;;;
|
||||||
found type `&'static str`
|
found type `&'static str`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/span-preservation.rs:19:29
|
--> $DIR/span-preservation.rs:18:29
|
||||||
|
|
|
|
||||||
LL | fn b(x: Option<isize>) -> usize {
|
LL | fn b(x: Option<isize>) -> usize {
|
||||||
| ----- expected `usize` because of return type
|
| ----- expected `usize` because of return type
|
||||||
|
@ -22,13 +22,13 @@ LL | Some(x) => { return x },
|
||||||
| ^ expected usize, found isize
|
| ^ expected usize, found isize
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/span-preservation.rs:35:22
|
--> $DIR/span-preservation.rs:34:22
|
||||||
|
|
|
|
||||||
LL | let x = Foo { a: 10isize };
|
LL | let x = Foo { a: 10isize };
|
||||||
| ^^^^^^^ expected usize, found isize
|
| ^^^^^^^ expected usize, found isize
|
||||||
|
|
||||||
error[E0560]: struct `c::Foo` has no field named `b`
|
error[E0560]: struct `c::Foo` has no field named `b`
|
||||||
--> $DIR/span-preservation.rs:36:26
|
--> $DIR/span-preservation.rs:35:26
|
||||||
|
|
|
|
||||||
LL | let y = Foo { a: 10, b: 10isize };
|
LL | let y = Foo { a: 10, b: 10isize };
|
||||||
| ^ `c::Foo` does not have this field
|
| ^ `c::Foo` does not have this field
|
||||||
|
@ -36,7 +36,7 @@ LL | let y = Foo { a: 10, b: 10isize };
|
||||||
= note: available fields are: `a`
|
= note: available fields are: `a`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/span-preservation.rs:49:5
|
--> $DIR/span-preservation.rs:48:5
|
||||||
|
|
|
|
||||||
LL | extern "C" fn baz() {
|
LL | extern "C" fn baz() {
|
||||||
| - possibly return type missing here?
|
| - possibly return type missing here?
|
||||||
|
|
Loading…
Reference in a new issue