Rollup merge of #61024 - petrochenkov:proctest, r=nikomatsakis

tests: Centralize proc macros commonly used for testing

Many proc macros in `ui\proc-macro\auxiliary` were doing same things.
(I added a fair share of those myself.)

Now commonly used macros (empty, identity, etc) are collected in one place - `ui\proc-macro\auxiliary\test-macros.rs`.
This commit is contained in:
Mazdak Farrokhzad 2019-05-29 00:19:57 +02:00 committed by GitHub
commit bfe9080ea0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 480 additions and 654 deletions

View file

@ -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
}

View file

@ -1,13 +0,0 @@
// compile-pass
// aux-build:plugin.rs
extern crate plugin;
mod inner {
use plugin::WithHelper;
#[derive(WithHelper)]
struct S;
}
fn main() {}

View file

@ -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() {}

View file

@ -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`.

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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

View file

@ -1,14 +1,14 @@
// aux-build:attr_proc_macro.rs
// aux-build:test-macros.rs
extern crate attr_proc_macro;
use attr_proc_macro::*;
#[macro_use]
extern crate test_macros;
#[attr_proc_macro] // OK
#[identity_attr] // OK
#[derive(Clone)]
struct Before;
#[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;
fn main() {}

View file

@ -1,8 +1,8 @@
error: macro attributes must be placed before `#[derive]`
--> $DIR/attribute-order-restricted.rs:11:1
|
LL | #[attr_proc_macro]
| ^^^^^^^^^^^^^^^^^^
LL | #[identity_attr]
| ^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -1,12 +1,11 @@
// aux-build:attribute-with-error.rs
// aux-build:test-macros.rs
#![feature(custom_inner_attributes)]
extern crate attribute_with_error;
#[macro_use]
extern crate test_macros;
use attribute_with_error::foo;
#[foo]
#[recollect_attr]
fn test1() {
let a: i32 = "foo";
//~^ ERROR: mismatched types
@ -15,13 +14,13 @@ fn test1() {
}
fn test2() {
#![foo]
#![recollect_attr]
// FIXME: should have a type error here and assert it works but it doesn't
}
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) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
@ -31,13 +30,13 @@ trait A {
struct B;
impl A for B {
#[foo]
#[recollect_attr]
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}
#[foo]
#[recollect_attr]
fn main() {
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:11:18
--> $DIR/attribute-with-error.rs:10:18
|
LL | let a: i32 = "foo";
| ^^^^^ expected i32, found reference
@ -8,7 +8,7 @@ LL | let a: i32 = "foo";
found type `&'static str`
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:13:18
--> $DIR/attribute-with-error.rs:12:18
|
LL | let b: i32 = "f'oo";
| ^^^^^^ expected i32, found reference
@ -17,7 +17,7 @@ LL | let b: i32 = "f'oo";
found type `&'static str`
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:26:22
--> $DIR/attribute-with-error.rs:25:22
|
LL | let a: i32 = "foo";
| ^^^^^ expected i32, found reference
@ -26,7 +26,7 @@ LL | let a: i32 = "foo";
found type `&'static str`
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:36:22
--> $DIR/attribute-with-error.rs:35:22
|
LL | let a: i32 = "foo";
| ^^^^^ expected i32, found reference

View file

@ -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
}

View file

@ -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()
}

View file

@ -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
}

View file

@ -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()
}

View file

@ -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()
}

View file

@ -1,2 +1,2 @@
#[macro_export]
macro_rules! my_attr { () => () }
macro_rules! empty_helper { () => () }

View file

@ -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()
}

View file

@ -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()
}

View file

@ -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!");
}

View file

@ -3,14 +3,14 @@ pub type S = u8;
#[macro_export]
macro_rules! external {
() => {
dollar_crate::m! {
print_bang! {
struct M($crate::S);
}
#[dollar_crate::a]
#[print_attr]
struct A($crate::S);
#[derive(dollar_crate::d)]
#[derive(Print)]
struct D($crate::S);
};
}

View file

@ -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()
}

View file

@ -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
}

View file

@ -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()
}

View file

@ -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()
}

View file

@ -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()
}

View file

@ -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
}

View file

@ -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()
}

View file

@ -1,26 +1,112 @@
// force-host
// 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"]
extern crate proc_macro;
use proc_macro::TokenStream;
// Macro that return empty token stream.
#[proc_macro]
pub fn empty(_: TokenStream) -> TokenStream {
TokenStream::new()
}
#[proc_macro_attribute]
pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream {
assert!(_attr.to_string().is_empty());
pub fn empty_attr(_: TokenStream, _: TokenStream) -> TokenStream {
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
}
#[proc_macro_attribute]
pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream {
assert!(_attr.to_string().is_empty());
assert!(!_input.to_string().is_empty());
"".parse().unwrap()
pub fn identity_attr(_: TokenStream, input: TokenStream) -> TokenStream {
input
}
#[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]
pub fn emit_input(input: TokenStream) -> TokenStream {
input
pub fn print_bang(input: TokenStream) -> TokenStream {
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")
}

View file

@ -1,16 +1,16 @@
// compile-pass
// aux-build:derive-helper-shadowed.rs
// aux-build:test-macros.rs
// aux-build:derive-helper-shadowed-2.rs
#[macro_use]
extern crate derive_helper_shadowed;
#[macro_use(my_attr)]
extern crate test_macros;
#[macro_use(empty_helper)]
extern crate derive_helper_shadowed_2;
macro_rules! my_attr { () => () }
macro_rules! empty_helper { () => () }
#[derive(MyTrait)]
#[my_attr] // OK
#[derive(Empty)]
#[empty_helper] // OK
struct S;
fn main() {}

View file

@ -1,23 +1,25 @@
// aux-build:derive-helper-shadowing.rs
// aux-build:test-macros.rs
extern crate derive_helper_shadowing;
use derive_helper_shadowing::*;
#[macro_use]
extern crate test_macros;
#[my_attr] //~ ERROR `my_attr` is ambiguous
#[derive(MyTrait)]
use test_macros::empty_attr as empty_helper;
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
#[derive(Empty)]
struct S {
// FIXME No ambiguity, attributes in non-macro positions are not resolved properly
#[my_attr]
#[empty_helper]
field: [u8; {
// 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
#[my_attr]
#[empty_helper]
struct U;
mod inner {
#[my_attr] //~ ERROR attribute `my_attr` is currently unknown
#[empty_helper] //~ ERROR attribute `empty_helper` is currently unknown
struct V;
}

View file

@ -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
--> $DIR/derive-helper-shadowing.rs:20:15
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:22:15
|
LL | #[my_attr]
| ^^^^^^^
LL | #[empty_helper]
| ^^^^^^^^^^^^
|
= 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[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name)
--> $DIR/derive-helper-shadowing.rs:6:3
error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
--> $DIR/derive-helper-shadowing.rs:8:3
|
LL | #[my_attr]
| ^^^^^^^ ambiguous name
LL | #[empty_helper]
| ^^^^^^^^^^^^ ambiguous name
|
note: `my_attr` could refer to the derive helper attribute defined here
--> $DIR/derive-helper-shadowing.rs:7:10
note: `empty_helper` could refer to the derive helper attribute defined here
--> $DIR/derive-helper-shadowing.rs:9:10
|
LL | #[derive(MyTrait)]
| ^^^^^^^
note: `my_attr` could also refer to the attribute macro imported here
--> $DIR/derive-helper-shadowing.rs:4:5
LL | #[derive(Empty)]
| ^^^^^
note: `empty_helper` could also refer to the attribute macro imported here
--> $DIR/derive-helper-shadowing.rs:6:5
|
LL | use derive_helper_shadowing::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use `crate::my_attr` to refer to this attribute macro unambiguously
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 2 previous errors

View 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() {}

View file

@ -1,11 +1,9 @@
// aux-build:derive-a.rs
#![allow(warnings)]
// aux-build:test-macros.rs
#[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;
fn main() {}

View file

@ -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
--> $DIR/derive-still-gated.rs:8:3
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:6:3
|
LL | #[derive_A]
| ^^^^^^^^ help: a built-in attribute with a similar name exists: `derive`
LL | #[derive_Empty]
| ^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable

View file

@ -1,22 +1,23 @@
// compile-pass
// edition:2018
// aux-build:dollar-crate.rs
// aux-build:test-macros.rs
// 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\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
extern crate dollar_crate;
#[macro_use]
extern crate test_macros;
type S = u8;
macro_rules! m {
() => {
dollar_crate::m_empty! {
print_bang! {
struct M($crate::S);
}
#[dollar_crate::a]
#[print_attr]
struct A($crate::S);
};
}

View file

@ -1,5 +1,5 @@
PROC MACRO INPUT (PRETTY-PRINTED): struct M ( $crate :: S ) ;
PROC MACRO INPUT: TokenStream [
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #2 bytes(LO..HI),
@ -38,8 +38,9 @@ PROC MACRO INPUT: TokenStream [
span: #2 bytes(LO..HI),
},
]
ATTRIBUTE INPUT (PRETTY-PRINTED): struct A(crate::S);
ATTRIBUTE INPUT: TokenStream [
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #2 bytes(LO..HI),

View file

@ -1,29 +1,28 @@
// edition:2018
// aux-build:dollar-crate.rs
// aux-build:test-macros.rs
// aux-build:dollar-crate-external.rs
// 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\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
extern crate dollar_crate;
#[macro_use]
extern crate test_macros;
extern crate dollar_crate_external;
type S = u8;
mod local {
use crate::dollar_crate;
macro_rules! local {
() => {
dollar_crate::m! {
print_bang! {
struct M($crate::S);
}
#[dollar_crate::a]
#[print_attr]
struct A($crate::S);
#[derive(dollar_crate::d)]
#[derive(Print)]
struct D($crate::S); //~ ERROR the name `D` is defined multiple times
};
}

View file

@ -1,5 +1,5 @@
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);
| ^^^^^^^^^^^^^^^^^^^^
@ -13,7 +13,7 @@ LL | local!();
= note: `D` must be defined only once in the type namespace of this module
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!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
PROC MACRO INPUT (PRETTY-PRINTED): struct M ( $crate :: S ) ;
PROC MACRO INPUT: TokenStream [
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #2 bytes(LO..HI),
@ -38,8 +38,9 @@ PROC MACRO INPUT: TokenStream [
span: #2 bytes(LO..HI),
},
]
ATTRIBUTE INPUT (PRETTY-PRINTED): struct A(crate::S);
ATTRIBUTE INPUT: TokenStream [
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #2 bytes(LO..HI),
@ -78,8 +79,9 @@ ATTRIBUTE INPUT: TokenStream [
span: #2 bytes(LO..HI),
},
]
DERIVE INPUT (PRETTY-PRINTED): struct D(crate::S);
DERIVE INPUT: TokenStream [
PRINT-DERIVE INPUT (DISPLAY): struct D(crate::S);
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #2 bytes(LO..HI),
@ -118,8 +120,8 @@ DERIVE INPUT: TokenStream [
span: #2 bytes(LO..HI),
},
]
PROC MACRO INPUT (PRETTY-PRINTED): struct M ( $crate :: S ) ;
PROC MACRO INPUT: TokenStream [
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #10 bytes(LO..HI),
@ -158,8 +160,9 @@ PROC MACRO INPUT: TokenStream [
span: #10 bytes(LO..HI),
},
]
ATTRIBUTE INPUT (PRETTY-PRINTED): struct A(::dollar_crate_external::S);
ATTRIBUTE INPUT: TokenStream [
PRINT-ATTR INPUT (DISPLAY): struct A(::dollar_crate_external::S);
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #10 bytes(LO..HI),
@ -198,8 +201,9 @@ ATTRIBUTE INPUT: TokenStream [
span: #10 bytes(LO..HI),
},
]
DERIVE INPUT (PRETTY-PRINTED): struct D(::dollar_crate_external::S);
DERIVE INPUT: TokenStream [
PRINT-DERIVE INPUT (DISPLAY): struct D(::dollar_crate_external::S);
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #10 bytes(LO..HI),

View file

@ -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() {}

View file

@ -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`.

View 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() {}

View file

@ -1,11 +1,8 @@
// aux-build:derive-a.rs
// aux-build:test-macros.rs
#![allow(warnings)]
extern crate test_macros;
#[macro_use]
extern crate derive_a;
use derive_a::derive_a;
//~^ ERROR: unresolved import `derive_a::derive_a`
use test_macros::empty_derive;
//~^ ERROR: unresolved import `test_macros::empty_derive`
fn main() {}

View file

@ -1,8 +1,8 @@
error[E0432]: unresolved import `derive_a::derive_a`
--> $DIR/import.rs:8:5
error[E0432]: unresolved import `test_macros::empty_derive`
--> $DIR/import.rs:5:5
|
LL | use derive_a::derive_a;
| ^^^^^^^^^^^^^^^^^^ no `derive_a` in the root
LL | use test_macros::empty_derive;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ no `empty_derive` in the root
error: aborting due to previous error

View 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() {}

View 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

View file

@ -1,7 +1,7 @@
// aux-build:derive-a-b.rs
// aux-build:test-macros.rs
#[macro_use]
extern crate derive_a_b;
extern crate test_macros;
fn main() {
// Test that constructing the `visible_parent_map` (in `cstore_impl.rs`) does not ICE.

View file

@ -1,14 +1,14 @@
// aux-build:issue-41211.rs
// aux-build:test-macros.rs
// FIXME: https://github.com/rust-lang/rust/issues/41430
// This is a temporary regression test for the ICE reported in #41211
#![feature(custom_inner_attributes)]
#![emit_unchanged]
//~^ ERROR attribute `emit_unchanged` is currently unknown to the compiler
#![identity_attr]
//~^ ERROR attribute `identity_attr` is currently unknown to the compiler
//~| ERROR inconsistent resolution for a macro: first custom attribute, then attribute macro
extern crate issue_41211;
use issue_41211::emit_unchanged;
extern crate test_macros;
use test_macros::identity_attr;
fn main() {}

View file

@ -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
|
LL | #![emit_unchanged]
| ^^^^^^^^^^^^^^
LL | #![identity_attr]
| ^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= 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
--> $DIR/issue-41211.rs:8:4
|
LL | #![emit_unchanged]
| ^^^^^^^^^^^^^^
LL | #![identity_attr]
| ^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -1,21 +1,21 @@
// compile-pass
// aux-build:issue-53481.rs
// aux-build:test-macros.rs
#[macro_use]
extern crate issue_53481;
extern crate test_macros;
mod m1 {
use m2::MyTrait;
use m2::Empty;
#[derive(MyTrait)]
#[derive(Empty)]
struct A {}
}
mod m2 {
pub type MyTrait = u8;
pub type Empty = u8;
#[derive(MyTrait)]
#[my_attr]
#[derive(Empty)]
#[empty_helper]
struct B {}
}

View file

@ -1,10 +1,9 @@
// aux-build:derive-panic.rs
// compile-flags:--error-format human
// aux-build:test-macros.rs
#[macro_use]
extern crate derive_panic;
extern crate test_macros;
#[derive(A)]
#[derive(Panic)]
//~^ ERROR: proc-macro derive panicked
struct Foo;

View file

@ -1,10 +1,10 @@
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

View file

@ -1,13 +1,13 @@
// aux-build:macro-brackets.rs
// aux-build:test-macros.rs
extern crate macro_brackets as bar;
use bar::doit;
#[macro_use]
extern crate test_macros;
macro_rules! id {
($($t:tt)*) => ($($t)*)
}
#[doit]
#[identity_attr]
id![static X: u32 = 'a';]; //~ ERROR: mismatched types

View file

@ -1,9 +1,10 @@
// 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;
fn main() {

View file

@ -1,11 +1,11 @@
// compile-pass
// aux-build:bang_proc_macro.rs
// aux-build:test-macros.rs
#![feature(proc_macro_hygiene)]
#[macro_use]
extern crate bang_proc_macro;
extern crate test_macros;
fn main() {
bang_proc_macro!(println!("Hello, world!"));
identity!(println!("Hello, world!"));
}

View file

@ -1,10 +1,9 @@
// aux-build:test-macros.rs
// ignore-wasm32
#[macro_use]
extern crate test_macros;
use test_macros::{nop_attr, no_output, emit_input};
fn main() {
assert_eq!(unsafe { rust_get_test_int() }, 0isize);
assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF);
@ -12,14 +11,14 @@ fn main() {
#[link(name = "rust_test_helpers", kind = "static")]
extern {
#[no_output]
#[empty_attr]
//~^ ERROR macro invocations in `extern {}` blocks are experimental
fn some_definitely_unknown_symbol_which_should_be_removed();
#[nop_attr]
#[identity_attr]
//~^ ERROR macro invocations in `extern {}` blocks are experimental
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
}

View file

@ -1,26 +1,26 @@
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
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
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
= help: add #![feature(macros_in_extern)] to the crate attributes to enable
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
= help: add #![feature(macros_in_extern)] to the crate attributes to enable

View file

@ -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;
#[foo]
#[recollect_attr]
fn another() {
fn bar() {
let x: u32 = "x"; //~ ERROR: mismatched types
@ -14,7 +13,7 @@ fn another() {
}
fn main() {
#[foo]
#[recollect_attr]
fn bar() {
let x: u32 = "x"; //~ ERROR: mismatched types
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/nested-item-spans.rs:10:22
--> $DIR/nested-item-spans.rs:9:22
|
LL | let x: u32 = "x";
| ^^^ expected u32, found reference
@ -8,7 +8,7 @@ LL | let x: u32 = "x";
found type `&'static str`
error[E0308]: mismatched types
--> $DIR/nested-item-spans.rs:19:22
--> $DIR/nested-item-spans.rs:18:22
|
LL | let x: u32 = "x";
| ^^^ expected u32, found reference

View file

@ -1,9 +1,9 @@
// aux-build:derive-a.rs
// aux-build:test-macros.rs
#![feature(rustc_attrs)]
#![warn(unused_extern_crates)]
extern crate derive_a;
extern crate test_macros;
//~^ WARN unused extern crate
#[rustc_error]

View file

@ -1,8 +1,8 @@
warning: unused extern crate
--> $DIR/no-macro-use-attr.rs:6:1
|
LL | extern crate derive_a;
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove it
LL | extern crate test_macros;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
note: lint level defined here
--> $DIR/no-macro-use-attr.rs:4:9

View file

@ -1,61 +1,62 @@
// aux-build:proc-macro-gates.rs
// aux-build:test-macros.rs
// gate-test-proc_macro_hygiene
#![feature(stmt_expr_attributes)]
extern crate proc_macro_gates as foo;
use foo::*;
#[macro_use]
extern crate test_macros;
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_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
}
#[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 attrs() {
// Statement, item
#[a] // OK
#[empty_attr] // OK
struct S;
// Statement, macro
#[a] //~ ERROR: custom attributes cannot be applied to statements
#[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
println!();
// Statement, semi
#[a] //~ ERROR: custom attributes cannot be applied to statements
#[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
S;
// Statement, local
#[a] //~ ERROR: custom attributes cannot be applied to statements
#[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
let _x = 2;
// 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
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
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() {
let _x: m!(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
let _x: identity!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types
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
m!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements
empty!(struct S;); //~ 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 = [m!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions
let _x = identity!(3); //~ ERROR: procedural macros cannot be expanded to expressions
let _x = [empty!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions
}

View file

@ -1,95 +1,95 @@
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
= help: add #![feature(custom_inner_attributes)] to the crate attributes to enable
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
= help: add #![feature(custom_inner_attributes)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= 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
--> $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
--> $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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= 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
--> $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
= 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
--> $DIR/proc-macro-gates.rs:54:12
|
LL | if let m!(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;);
| ^^^^^^^^^^^^^^
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
@ -124,26 +115,35 @@ LL | m!(struct S;);
error[E0658]: procedural macros cannot be expanded to statements
--> $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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable
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
= help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable

View file

@ -1,21 +1,20 @@
// aux-build:proc-macro-gates.rs
// aux-build:test-macros.rs
#![feature(stmt_expr_attributes)]
extern crate proc_macro_gates as foo;
use foo::*;
#[macro_use]
extern crate test_macros;
// 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
// 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
fn _test7() {
match 1 {
#[a] //~ ERROR: unknown to the compiler
#[empty_attr] //~ ERROR: unknown to the compiler
0 => {}
_ => {}
}

View file

@ -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
--> $DIR/proc-macro-gates2.rs:13:11
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: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
= 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
--> $DIR/proc-macro-gates2.rs:18:9
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:17:9
|
LL | #[a]
| ^^^^
LL | #[empty_attr]
| ^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable

View file

@ -1,7 +1,6 @@
// aux-build:derive-foo.rs
// aux-build:derive-clona.rs
// aux-build:attr_proc_macro.rs
// aux-build:bang_proc_macro.rs
// aux-build:test-macros.rs
#![feature(custom_attribute)]
@ -9,11 +8,10 @@
extern crate derive_foo;
#[macro_use]
extern crate derive_clona;
extern crate attr_proc_macro;
extern crate bang_proc_macro;
extern crate test_macros;
use attr_proc_macro::attr_proc_macro;
use bang_proc_macro::bang_proc_macro;
use test_macros::empty as bang_proc_macro;
use test_macros::empty_attr as attr_proc_macro;
macro_rules! FooWithLongNam {
() => {}

View file

@ -1,47 +1,47 @@
error: cannot find derive macro `FooWithLongNan` in this scope
--> $DIR/resolve-error.rs:26:10
--> $DIR/resolve-error.rs:24:10
|
LL | #[derive(FooWithLongNan)]
| ^^^^^^^^^^^^^^ help: try: `FooWithLongName`
error: cannot find derive macro `Dlone` in this scope
--> $DIR/resolve-error.rs:36:10
--> $DIR/resolve-error.rs:34:10
|
LL | #[derive(Dlone)]
| ^^^^^ help: try: `Clone`
error: cannot find derive macro `Dlona` in this scope
--> $DIR/resolve-error.rs:40:10
--> $DIR/resolve-error.rs:38:10
|
LL | #[derive(Dlona)]
| ^^^^^ help: try: `Clona`
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)]
| ^^^^^^^^^^^^^^^
error: cannot find macro `FooWithLongNama!` in this scope
--> $DIR/resolve-error.rs:49:5
--> $DIR/resolve-error.rs:47:5
|
LL | FooWithLongNama!();
| ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam`
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!();
| ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac`
error: cannot find macro `Dlona!` in this scope
--> $DIR/resolve-error.rs:55:5
--> $DIR/resolve-error.rs:53:5
|
LL | Dlona!();
| ^^^^^
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!();
| ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro`

View file

@ -1,8 +1,8 @@
// aux-build:derive-a.rs
// aux-build:test-macros.rs
#[macro_use]
extern crate derive_a;
extern crate test_macros;
#[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() {}

View file

@ -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
|
LL | extern crate derive_a;
| ---------------------- previous import of the extern crate `derive_a` here
LL | extern crate test_macros;
| ------------------------- previous import of the extern crate `test_macros` here
LL | #[macro_use]
LL | extern crate derive_a;
| ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here
LL | extern crate test_macros;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `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

View file

@ -1,19 +1,18 @@
//~ 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,
// and the function should be echoed.
extern crate span_preservation as foo;
#[macro_use]
extern crate test_macros;
use foo::foo;
#[foo]
#[recollect_attr]
fn a() {
let x: usize = "hello";;;;; //~ ERROR mismatched types
}
#[foo]
#[recollect_attr]
fn b(x: Option<isize>) -> usize {
match x {
Some(x) => { return x }, //~ ERROR mismatched types
@ -21,7 +20,7 @@ fn b(x: Option<isize>) -> usize {
}
}
#[foo]
#[recollect_attr]
fn c() {
struct Foo {
a: usize
@ -39,12 +38,12 @@ fn c() {
// 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"
// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST.
#[foo]
#[recollect_attr]
extern fn bar() {
0
}
#[foo]
#[recollect_attr]
extern "C" fn baz() {
0 //~ ERROR mismatched types
}

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
found type `{integer}`
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:13:20
--> $DIR/span-preservation.rs:12:20
|
LL | let x: usize = "hello";;;;;
| ^^^^^^^ expected usize, found reference
@ -13,7 +13,7 @@ LL | let x: usize = "hello";;;;;
found type `&'static str`
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:19:29
--> $DIR/span-preservation.rs:18:29
|
LL | fn b(x: Option<isize>) -> usize {
| ----- expected `usize` because of return type
@ -22,13 +22,13 @@ LL | Some(x) => { return x },
| ^ expected usize, found isize
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:35:22
--> $DIR/span-preservation.rs:34:22
|
LL | let x = Foo { a: 10isize };
| ^^^^^^^ expected usize, found isize
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 };
| ^ `c::Foo` does not have this field
@ -36,7 +36,7 @@ LL | let y = Foo { a: 10, b: 10isize };
= note: available fields are: `a`
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:49:5
--> $DIR/span-preservation.rs:48:5
|
LL | extern "C" fn baz() {
| - possibly return type missing here?