diff options
Diffstat (limited to 'tests/ui/proc-macro')
20 files changed, 406 insertions, 98 deletions
diff --git a/tests/ui/proc-macro/attribute.rs b/tests/ui/proc-macro/attribute.rs index 988cdcd0403..dfb26738377 100644 --- a/tests/ui/proc-macro/attribute.rs +++ b/tests/ui/proc-macro/attribute.rs @@ -9,46 +9,55 @@ use proc_macro::*; #[proc_macro_derive] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo1(input: TokenStream) -> TokenStream { input } #[proc_macro_derive = ""] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo2(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d3, a, b)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE the only valid argument here is `attributes` +//~| NOTE for more information, visit pub fn foo3(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d4, attributes(a), b)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo4(input: TokenStream) -> TokenStream { input } #[proc_macro_derive("a")] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect a literal here +//~| NOTE for more information, visit pub fn foo5(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d6 = "")] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo6(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(m::d7)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo7(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d8(a))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo8(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(self)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo9(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(PartialEq)] // OK @@ -57,34 +66,41 @@ pub fn foo10(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d11, a)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE the only valid argument here is `attributes` +//~| NOTE for more information, visit pub fn foo11(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d12, attributes)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo12(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d13, attributes("a"))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo13(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d14, attributes(a = ""))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo14(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d15, attributes(m::a))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo15(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d16, attributes(a(b)))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo16(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d17, attributes(self))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo17(input: TokenStream) -> TokenStream { input } diff --git a/tests/ui/proc-macro/attribute.stderr b/tests/ui/proc-macro/attribute.stderr index db59a1fdfb3..e7127c8ef1d 100644 --- a/tests/ui/proc-macro/attribute.stderr +++ b/tests/ui/proc-macro/attribute.stderr @@ -2,145 +2,283 @@ error[E0539]: malformed `proc_macro_derive` attribute input --> $DIR/attribute.rs:9:1 | LL | #[proc_macro_derive] - | ^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[proc_macro_derive(TraitName)] + | +++++++++++ +LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:14:1 + --> $DIR/attribute.rs:15:1 | LL | #[proc_macro_derive = ""] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive = ""] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive = ""] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:19:1 + --> $DIR/attribute.rs:21:1 | LL | #[proc_macro_derive(d3, a, b)] | ^^^^^^^^^^^^^^^^^^^^^^^^-^^^^^ - | | | - | | the only valid argument here is `attributes` - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | the only valid argument here is `attributes` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d3, a, b)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d3, a, b)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:24:1 + --> $DIR/attribute.rs:27:1 | LL | #[proc_macro_derive(d4, attributes(a), b)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d4, attributes(a), b)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d4, attributes(a), b)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:29:1 + --> $DIR/attribute.rs:33:1 | LL | #[proc_macro_derive("a")] | ^^^^^^^^^^^^^^^^^^^^---^^ - | | | - | | didn't expect a literal here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect a literal here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive("a")] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive("a")] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:34:1 + --> $DIR/attribute.rs:39:1 | LL | #[proc_macro_derive(d6 = "")] | ^^^^^^^^^^^^^^^^^^^^^^^----^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d6 = "")] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d6 = "")] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:39:1 + --> $DIR/attribute.rs:45:1 | LL | #[proc_macro_derive(m::d7)] | ^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(m::d7)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(m::d7)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:44:1 + --> $DIR/attribute.rs:51:1 | LL | #[proc_macro_derive(d8(a))] | ^^^^^^^^^^^^^^^^^^^^^^---^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d8(a))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d8(a))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:49:1 + --> $DIR/attribute.rs:57:1 | LL | #[proc_macro_derive(self)] | ^^^^^^^^^^^^^^^^^^^^----^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(self)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(self)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:57:1 + --> $DIR/attribute.rs:66:1 | LL | #[proc_macro_derive(d11, a)] | ^^^^^^^^^^^^^^^^^^^^^^^^^-^^ - | | | - | | the only valid argument here is `attributes` - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | the only valid argument here is `attributes` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d11, a)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d11, a)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:62:1 + --> $DIR/attribute.rs:72:1 | LL | #[proc_macro_derive(d12, attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^----------^^ - | | | - | | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d12, attributes)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d12, attributes)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:67:1 + --> $DIR/attribute.rs:78:1 | LL | #[proc_macro_derive(d13, attributes("a"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d13, attributes("a"))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d13, attributes("a"))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:72:1 + --> $DIR/attribute.rs:84:1 | LL | #[proc_macro_derive(d14, attributes(a = ""))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d14, attributes(a = ""))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d14, attributes(a = ""))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:77:1 + --> $DIR/attribute.rs:90:1 | LL | #[proc_macro_derive(d15, attributes(m::a))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d15, attributes(m::a))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d15, attributes(m::a))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:82:1 + --> $DIR/attribute.rs:96:1 | LL | #[proc_macro_derive(d16, attributes(a(b)))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d16, attributes(a(b)))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d16, attributes(a(b)))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:87:1 + --> $DIR/attribute.rs:102:1 | LL | #[proc_macro_derive(d17, attributes(self))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d17, attributes(self))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d17, attributes(self))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error: aborting due to 16 previous errors diff --git a/tests/ui/proc-macro/auxiliary/match-expander.rs b/tests/ui/proc-macro/auxiliary/match-expander.rs new file mode 100644 index 00000000000..bf78df2addf --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/match-expander.rs @@ -0,0 +1,15 @@ +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn matcher(input: TokenStream) -> TokenStream { +" +struct S(()); +let s = S(()); +match s { + true => {} + _ => {} +} +".parse().unwrap() +} diff --git a/tests/ui/proc-macro/derive-helper-shadowing.rs b/tests/ui/proc-macro/derive-helper-shadowing.rs index e774e464053..ee883be3352 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.rs +++ b/tests/ui/proc-macro/derive-helper-shadowing.rs @@ -17,7 +17,7 @@ macro_rules! gen_helper_use { } #[empty_helper] //~ ERROR `empty_helper` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[derive(Empty)] struct S { diff --git a/tests/ui/proc-macro/derive-helper-shadowing.stderr b/tests/ui/proc-macro/derive-helper-shadowing.stderr index 1206778bb23..65989375ab5 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.stderr +++ b/tests/ui/proc-macro/derive-helper-shadowing.stderr @@ -58,7 +58,7 @@ LL | use test_macros::empty_attr as empty_helper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/derive-helper-shadowing.rs:19:3 | LL | #[empty_helper] @@ -69,8 +69,22 @@ LL | #[derive(Empty)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default + = note: `#[deny(legacy_derive_helpers)]` on by default -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/derive-helper-shadowing.rs:19:3 + | +LL | #[empty_helper] + | ^^^^^^^^^^^^ +... +LL | #[derive(Empty)] + | ----- the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs index 1197dd7f3bf..97c81e9945d 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs @@ -5,7 +5,7 @@ extern crate test_macros; use test_macros::empty_attr as empty_helper; #[empty_helper] //~ ERROR `empty_helper` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[derive(Empty)] struct S; diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr index 1c12a2804c6..df7951464fb 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr @@ -17,7 +17,7 @@ LL | use test_macros::empty_attr as empty_helper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3 | LL | #[empty_helper] @@ -28,8 +28,22 @@ LL | #[derive(Empty)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default + = note: `#[deny(legacy_derive_helpers)]` on by default -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3 + | +LL | #[empty_helper] + | ^^^^^^^^^^^^ +... +LL | #[derive(Empty)] + | ----- the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + diff --git a/tests/ui/proc-macro/issue-75930-derive-cfg.rs b/tests/ui/proc-macro/issue-75930-derive-cfg.rs index f0851b31e9c..e8df1a66dd9 100644 --- a/tests/ui/proc-macro/issue-75930-derive-cfg.rs +++ b/tests/ui/proc-macro/issue-75930-derive-cfg.rs @@ -6,7 +6,7 @@ // Tests that we cfg-strip all targets before invoking // a derive macro // FIXME: We currently lose spans here (see issue #43081) - +#![warn(legacy_derive_helpers)] #![no_std] // Don't load unnecessary hygiene information from std extern crate std; diff --git a/tests/ui/proc-macro/issue-75930-derive-cfg.stderr b/tests/ui/proc-macro/issue-75930-derive-cfg.stderr index df1e36d7390..906e9c6bf69 100644 --- a/tests/ui/proc-macro/issue-75930-derive-cfg.stderr +++ b/tests/ui/proc-macro/issue-75930-derive-cfg.stderr @@ -9,7 +9,11 @@ LL | #[derive(Print)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default +note: the lint level is defined here + --> $DIR/issue-75930-derive-cfg.rs:9:9 + | +LL | #![warn(legacy_derive_helpers)] + | ^^^^^^^^^^^^^^^^^^^^^ warning: derive helper attribute is used before it is introduced --> $DIR/issue-75930-derive-cfg.rs:46:3 @@ -26,3 +30,39 @@ LL | #[derive(Print)] warning: 2 warnings emitted +Future incompatibility report: Future breakage diagnostic: +warning: derive helper attribute is used before it is introduced + --> $DIR/issue-75930-derive-cfg.rs:46:3 + | +LL | #[print_helper(a)] + | ^^^^^^^^^^^^ +... +LL | #[derive(Print)] + | ----- the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> +note: the lint level is defined here + --> $DIR/issue-75930-derive-cfg.rs:9:9 + | +LL | #![warn(legacy_derive_helpers)] + | ^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +warning: derive helper attribute is used before it is introduced + --> $DIR/issue-75930-derive-cfg.rs:46:3 + | +LL | #[print_helper(a)] + | ^^^^^^^^^^^^ +... +LL | #[derive(Print)] + | ----- the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> +note: the lint level is defined here + --> $DIR/issue-75930-derive-cfg.rs:9:9 + | +LL | #![warn(legacy_derive_helpers)] + | ^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/proc-macro/load-panic-backtrace.rs b/tests/ui/proc-macro/load-panic-backtrace.rs index 848bdaf9f37..82645eb4e9f 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.rs +++ b/tests/ui/proc-macro/load-panic-backtrace.rs @@ -1,7 +1,7 @@ //@ proc-macro: test-macros.rs //@ compile-flags: -Z proc-macro-backtrace //@ rustc-env:RUST_BACKTRACE=0 -//@ normalize-stderr: "thread '.*' panicked " -> "" +//@ normalize-stderr: "thread '.*' \(0x[[:xdigit:]]+\) panicked " -> "" //@ normalize-stderr: "note:.*RUST_BACKTRACE=1.*\n" -> "" //@ needs-unwind proc macro panics to report errors diff --git a/tests/ui/proc-macro/load-panic-backtrace.stderr b/tests/ui/proc-macro/load-panic-backtrace.stderr index a1049f5a324..b8872eb12b7 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.stderr +++ b/tests/ui/proc-macro/load-panic-backtrace.stderr @@ -1,5 +1,5 @@ -at $DIR/auxiliary/test-macros.rs:38:5: +thread '<unnamed>' ($TID) panicked at $DIR/auxiliary/test-macros.rs:38:5: panic-derive error: proc-macro derive panicked --> $DIR/load-panic-backtrace.rs:11:10 diff --git a/tests/ui/proc-macro/match-expander.rs b/tests/ui/proc-macro/match-expander.rs new file mode 100644 index 00000000000..23e5746c540 --- /dev/null +++ b/tests/ui/proc-macro/match-expander.rs @@ -0,0 +1,12 @@ +//@ proc-macro: match-expander.rs +// Ensure that we don't point at macro invocation when providing inference contexts. + +#[macro_use] +extern crate match_expander; + +fn main() { + match_expander::matcher!(); + //~^ ERROR: mismatched types + //~| NOTE: expected `S`, found `bool` + //~| NOTE: in this expansion of match_expander::matcher! +} diff --git a/tests/ui/proc-macro/match-expander.stderr b/tests/ui/proc-macro/match-expander.stderr new file mode 100644 index 00000000000..b77468ec60a --- /dev/null +++ b/tests/ui/proc-macro/match-expander.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/match-expander.rs:8:5 + | +LL | match_expander::matcher!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `S`, found `bool` + | + = note: this error originates in the macro `match_expander::matcher` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/proc-macro/proc-macro-attributes.rs b/tests/ui/proc-macro/proc-macro-attributes.rs index 455fcc56e58..f1270b896aa 100644 --- a/tests/ui/proc-macro/proc-macro-attributes.rs +++ b/tests/ui/proc-macro/proc-macro-attributes.rs @@ -4,17 +4,17 @@ extern crate derive_b; #[B] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[C] //~ ERROR cannot find attribute `C` in this scope #[B(D)] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[B(E = "foo")] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[derive(B)] struct B; diff --git a/tests/ui/proc-macro/proc-macro-attributes.stderr b/tests/ui/proc-macro/proc-macro-attributes.stderr index 140d8790690..2cc57383eb3 100644 --- a/tests/ui/proc-macro/proc-macro-attributes.stderr +++ b/tests/ui/proc-macro/proc-macro-attributes.stderr @@ -76,7 +76,7 @@ note: `B` could also refer to the derive macro imported here LL | #[macro_use] | ^^^^^^^^^^^^ -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:6:3 | LL | #[B] @@ -87,9 +87,9 @@ LL | #[derive(B)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default + = note: `#[deny(legacy_derive_helpers)]` on by default -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:10:3 | LL | #[B(D)] @@ -101,7 +101,7 @@ LL | #[derive(B)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:13:3 | LL | #[B(E = "foo")] @@ -113,7 +113,7 @@ LL | #[derive(B)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:16:3 | LL | #[B(arbitrary tokens)] @@ -125,6 +125,62 @@ LL | #[derive(B)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> -error: aborting due to 5 previous errors; 4 warnings emitted +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:6:3 + | +LL | #[B] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + +Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:10:3 + | +LL | #[B(D)] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + +Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:13:3 + | +LL | #[B(E = "foo")] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + +Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:16:3 + | +LL | #[B(arbitrary tokens)] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr index ecb12c1df3b..0bcea9b85f4 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr @@ -5,7 +5,6 @@ LL | quote!($($nonrep $nonrep)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this | here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr index 093e2ebc098..d945ab41a12 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr @@ -5,7 +5,6 @@ LL | quote!($($nonrep)*); | ^^^^^^^^^^^^^^^^^^^ | | | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this | here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr index 937209e675e..2d715f293d4 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> $DIR/does-not-have-iter-separated.rs:8:5 | LL | quote!($(a b),*); - | ^^^^^^^^^^^^^^^^ - | | - | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `HasIterator`, found `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter.stderr b/tests/ui/proc-macro/quote/does-not-have-iter.stderr index e74ea334899..ac8e725038a 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> $DIR/does-not-have-iter.rs:8:5 | LL | quote!($(a b)*); - | ^^^^^^^^^^^^^^^ - | | - | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this + | ^^^^^^^^^^^^^^^ expected `HasIterator`, found `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/span-from-proc-macro.stderr b/tests/ui/proc-macro/span-from-proc-macro.stderr index 452c04df877..c79ab04eadf 100644 --- a/tests/ui/proc-macro/span-from-proc-macro.stderr +++ b/tests/ui/proc-macro/span-from-proc-macro.stderr @@ -10,7 +10,7 @@ LL | field: MissingType ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] - | ----------------------- in this procedural macro expansion + | ----------------------- in this attribute macro expansion error[E0412]: cannot find type `OtherMissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:42:21 |
