diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index b82a9a909e6d0..b94fb5498e9a3 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,6 +10,7 @@ #![allow(internal_features)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] +#![cfg_attr(bootstrap, feature(macro_metavar_expr))] #![cfg_attr(not(parallel_compiler), feature(cell_leak))] #![deny(unsafe_op_in_unsafe_fn)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] @@ -25,7 +26,6 @@ #![feature(hasher_prefixfree_extras)] #![feature(lazy_cell)] #![feature(lint_reasons)] -#![feature(macro_metavar_expr)] #![feature(maybe_uninit_uninit_array)] #![feature(min_specialization)] #![feature(negative_impls)] diff --git a/compiler/rustc_data_structures/src/tagged_ptr/impl_tag.rs b/compiler/rustc_data_structures/src/tagged_ptr/impl_tag.rs index f17a0bf26d747..1bccfb230515d 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/impl_tag.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/impl_tag.rs @@ -11,7 +11,7 @@ /// Basic usage: /// /// ``` -/// #![feature(macro_metavar_expr)] +/// #![cfg_attr(bootstrap, feature(macro_metavar_expr))] /// use rustc_data_structures::{impl_tag, tagged_ptr::Tag}; /// /// #[derive(Copy, Clone, PartialEq, Debug)] @@ -51,7 +51,7 @@ /// Structs are supported: /// /// ``` -/// #![feature(macro_metavar_expr)] +/// #![cfg_attr(bootstrap, feature(macro_metavar_expr))] /// # use rustc_data_structures::impl_tag; /// #[derive(Copy, Clone)] /// struct Flags { a: bool, b: bool } @@ -68,7 +68,7 @@ /// Not specifying all values results in a compile error: /// /// ```compile_fail,E0004 -/// #![feature(macro_metavar_expr)] +/// #![cfg_attr(bootstrap, feature(macro_metavar_expr))] /// # use rustc_data_structures::impl_tag; /// #[derive(Copy, Clone)] /// enum E { diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index c9a3aeedd0209..2113e68c7ab37 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -6,7 +6,7 @@ #![feature(if_let_guard)] #![feature(let_chains)] #![feature(lint_reasons)] -#![feature(macro_metavar_expr)] +#![cfg_attr(bootstrap, feature(macro_metavar_expr))] #![feature(map_try_insert)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_internals)] diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 5fd3716743b22..59773ec12262b 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -183,11 +183,6 @@ fn parse_tree<'a>( return TokenTree::token(token::Dollar, span); } Ok(elem) => { - maybe_emit_macro_metavar_expr_feature( - features, - sess, - delim_span.entire(), - ); return TokenTree::MetaVarExpr(delim_span, elem); } } diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index f133a2f5f73b2..f1adbb3a6cb0c 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -11,7 +11,7 @@ #![feature(let_chains)] #![feature(if_let_guard)] #![feature(proc_macro_internals)] -#![feature(macro_metavar_expr)] +#![cfg_attr(bootstrap, feature(macro_metavar_expr))] #![feature(min_specialization)] #![feature(trusted_len)] #![feature(try_blocks)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index e52a5863fd03d..be1a334442360 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -59,7 +59,7 @@ #![feature(yeet_expr)] #![feature(const_option)] #![feature(ptr_alignment_type)] -#![feature(macro_metavar_expr)] +#![cfg_attr(bootstrap, feature(macro_metavar_expr))] #![allow(internal_features)] #![allow(rustc::potential_query_instability)] #![allow(rustc::diagnostic_outside_of_impl)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 2718dd114731b..a01736cf65fff 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -204,6 +204,7 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(macro_metavar_expr))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] #![feature(allow_internal_unsafe)] @@ -238,7 +239,6 @@ #![feature(lang_items)] #![feature(let_chains)] #![feature(link_llvm_intrinsics)] -#![feature(macro_metavar_expr)] #![feature(min_exhaustive_patterns)] #![feature(min_specialization)] #![feature(multiple_supertrait_upcastable)] diff --git a/tests/ui/macros/meta-variable-depth-outside-repeat.rs b/tests/ui/macros/meta-variable-depth-outside-repeat.rs index b7fb947854f04..747baf79f763a 100644 --- a/tests/ui/macros/meta-variable-depth-outside-repeat.rs +++ b/tests/ui/macros/meta-variable-depth-outside-repeat.rs @@ -1,5 +1,3 @@ -#![feature(macro_metavar_expr)] - macro_rules! metavar { ( $i:expr ) => { ${length(0)} diff --git a/tests/ui/macros/meta-variable-depth-outside-repeat.stderr b/tests/ui/macros/meta-variable-depth-outside-repeat.stderr index 49b5053a023cc..197e7fcf6af46 100644 --- a/tests/ui/macros/meta-variable-depth-outside-repeat.stderr +++ b/tests/ui/macros/meta-variable-depth-outside-repeat.stderr @@ -1,5 +1,5 @@ error: meta-variable expression `length` with depth parameter must be called inside of a macro repetition - --> $DIR/meta-variable-depth-outside-repeat.rs:5:10 + --> $DIR/meta-variable-depth-outside-repeat.rs:3:10 | LL | ${length(0)} | ^^^^^^^^^^^ diff --git a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs b/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs index 3a14e0c64fd1d..0e74b8ae6dbfa 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(macro_metavar_expr)] - fn main() { macro_rules! one_nested_count_and_length { ( $( [ $( $l:literal ),* ] ),* ) => { diff --git a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs b/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs index 6464fd6f2fd2f..fbfef862440aa 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs @@ -2,71 +2,6 @@ #![feature(macro_metavar_expr)] -/// Count the number of idents in a macro repetition. -macro_rules! count_idents { - ( $( $i:ident ),* ) => { - ${count($i)} - }; -} - -/// Count the number of idents in a 2-dimensional macro repetition. -macro_rules! count_idents_2 { - ( $( [ $( $i:ident ),* ] ),* ) => { - ${count($i)} - }; -} - -/// Mostly counts the number of OUTER-MOST repetitions -macro_rules! count_depth_limits { - ( $( { $( [ $( $outer:ident : ( $( $inner:ident )* ) )* ] )* } )* ) => { - ( - ( - ${count($inner)}, - ${count($inner, 0)}, - ${count($inner, 1)}, - ${count($inner, 2)}, - ${count($inner, 3)}, - ), - ( - ${count($outer)}, - ${count($outer, 0)}, - ${count($outer, 1)}, - ${count($outer, 2)}, - ), - ) - }; -} - -/// Produce (index, length) pairs for literals in a macro repetition. -/// The literal is not included in the output, so this macro uses the -/// `ignore` meta-variable expression to create a non-expanding -/// repetition binding. -macro_rules! enumerate_literals { - ( $( ($l:stmt) ),* ) => { - [$( ${ignore($l)} (${index()}, ${length()}) ),*] - }; -} - -/// Produce index and length tuples for literals in a 2-dimensional -/// macro repetition. -macro_rules! enumerate_literals_2 { - ( $( [ $( ($l:literal) ),* ] ),* ) => { - [ - $( - $( - ( - ${index(1)}, - ${length(1)}, - ${index(0)}, - ${length(0)}, - $l - ), - )* - )* - ] - }; -} - /// Generate macros that count idents and then add a constant number /// to the count. /// @@ -108,39 +43,6 @@ make_picker!(first => a, b; a); make_picker!(second => a, b; b); fn main() { - assert_eq!(count_idents!(a, b, c), 3); - assert_eq!(count_idents_2!([a, b, c], [d, e], [f]), 6); - assert_eq!( - count_depth_limits! { - { - [ A: (a b c) D: (d e f) ] - [ G: (g h) I: (i j k l m) ] - [ N: (n) ] - } - { - [ O: (o) P: (p q) R: (r s) ] - [ T: (t u v w x y z) ] - } - }, - ((26, 26, 9, 5, 2), (9, 9, 5, 2)) - ); - assert_eq!(enumerate_literals![("foo"), ("bar")], [(0, 2), (1, 2)]); - assert_eq!( - enumerate_literals_2![ - [("foo"), ("bar"), ("baz")], - [("qux"), ("quux"), ("quuz"), ("xyzzy")] - ], - [ - (0, 2, 0, 3, "foo"), - (0, 2, 1, 3, "bar"), - (0, 2, 2, 3, "baz"), - - (1, 2, 0, 4, "qux"), - (1, 2, 1, 4, "quux"), - (1, 2, 2, 4, "quuz"), - (1, 2, 3, 4, "xyzzy"), - ] - ); assert_eq!(plus_one!(a, b, c), 4); assert_eq!(plus_five!(a, b), 7); assert_eq!(first!(1, 2), 1); diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs index 3000bfed6a887..9e9d84d1d9d6e 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs @@ -1,5 +1,3 @@ -#![feature(macro_metavar_expr)] - macro_rules! foo { ( $( $($t:ident),* );* ) => { ${count($t,)} } //~^ ERROR `count` followed by a comma must have an associated diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr index fd53c1686cf14..479b5eec736dd 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr @@ -1,11 +1,11 @@ error: `count` followed by a comma must have an associated index indicating its depth - --> $DIR/issue-111904.rs:4:37 + --> $DIR/issue-111904.rs:2:37 | LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^^^^^ error: expected expression, found `$` - --> $DIR/issue-111904.rs:4:35 + --> $DIR/issue-111904.rs:2:35 | LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^ expected expression diff --git a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs b/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs index 787b927c449b3..f0a3809802426 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(macro_metavar_expr)] - #[derive(Debug)] struct Example<'a> { _indexes: &'a [(u32, u32)], diff --git a/tests/ui/macros/rfc-3086-metavar-expr/operations.rs b/tests/ui/macros/rfc-3086-metavar-expr/operations.rs new file mode 100644 index 0000000000000..9e2f19a7de9a6 --- /dev/null +++ b/tests/ui/macros/rfc-3086-metavar-expr/operations.rs @@ -0,0 +1,102 @@ +//@ run-pass + +/// Count the number of idents in a macro repetition. +macro_rules! count_idents { + ( $( $i:ident ),* ) => { + ${count($i)} + }; +} + +/// Count the number of idents in a 2-dimensional macro repetition. +macro_rules! count_idents_2 { + ( $( [ $( $i:ident ),* ] ),* ) => { + ${count($i)} + }; +} + +/// Mostly counts the number of OUTER-MOST repetitions +macro_rules! count_depth_limits { + ( $( { $( [ $( $outer:ident : ( $( $inner:ident )* ) )* ] )* } )* ) => { + ( + ( + ${count($inner)}, + ${count($inner, 0)}, + ${count($inner, 1)}, + ${count($inner, 2)}, + ${count($inner, 3)}, + ), + ( + ${count($outer)}, + ${count($outer, 0)}, + ${count($outer, 1)}, + ${count($outer, 2)}, + ), + ) + }; +} + +/// Produce (index, length) pairs for literals in a macro repetition. +/// The literal is not included in the output, so this macro uses the +/// `ignore` meta-variable expression to create a non-expanding +/// repetition binding. +macro_rules! enumerate_literals { + ( $( ($l:stmt) ),* ) => { + [$( ${ignore($l)} (${index()}, ${length()}) ),*] + }; +} + +/// Produce index and length tuples for literals in a 2-dimensional +/// macro repetition. +macro_rules! enumerate_literals_2 { + ( $( [ $( ($l:literal) ),* ] ),* ) => { + [ + $( + $( + ( + ${index(1)}, + ${length(1)}, + ${index(0)}, + ${length(0)}, + $l + ), + )* + )* + ] + }; +} + +fn main() { + assert_eq!(count_idents!(a, b, c), 3); + assert_eq!(count_idents_2!([a, b, c], [d, e], [f]), 6); + assert_eq!( + count_depth_limits! { + { + [ A: (a b c) D: (d e f) ] + [ G: (g h) I: (i j k l m) ] + [ N: (n) ] + } + { + [ O: (o) P: (p q) R: (r s) ] + [ T: (t u v w x y z) ] + } + }, + ((26, 26, 9, 5, 2), (9, 9, 5, 2)) + ); + assert_eq!(enumerate_literals![("foo"), ("bar")], [(0, 2), (1, 2)]); + assert_eq!( + enumerate_literals_2![ + [("foo"), ("bar"), ("baz")], + [("qux"), ("quux"), ("quuz"), ("xyzzy")] + ], + [ + (0, 2, 0, 3, "foo"), + (0, 2, 1, 3, "bar"), + (0, 2, 2, 3, "baz"), + + (1, 2, 0, 4, "qux"), + (1, 2, 1, 4, "quux"), + (1, 2, 2, 4, "quuz"), + (1, 2, 3, 4, "xyzzy"), + ] + ); +} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs index d195506af3612..2a7c5664df5e8 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs @@ -1,5 +1,3 @@ -#![feature(macro_metavar_expr)] - macro_rules! a { ( $( { $( [ $( ( $( $foo:ident )* ) )* ] )* } )* ) => { ( diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr index f757b8af219fd..2fdd66cd4516a 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr @@ -1,17 +1,17 @@ error: depth parameter of meta-variable expression `count` must be less than 4 - --> $DIR/out-of-bounds-arguments.rs:7:14 + --> $DIR/out-of-bounds-arguments.rs:5:14 | LL | ${count($foo, 10)}, | ^^^^^^^^^^^^^^^^^ error: depth parameter of meta-variable expression `index` must be less than 3 - --> $DIR/out-of-bounds-arguments.rs:19:18 + --> $DIR/out-of-bounds-arguments.rs:17:18 | LL | ${index(10)}, | ^^^^^^^^^^^ error: depth parameter of meta-variable expression `length` must be less than 2 - --> $DIR/out-of-bounds-arguments.rs:32:18 + --> $DIR/out-of-bounds-arguments.rs:30:18 | LL | ${length(10)} | ^^^^^^^^^^^^ diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs index 53d045700f9fe..b6d5f73aa2270 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs @@ -1,10 +1,3 @@ -macro_rules! count { - ( $( $e:stmt ),* ) => { - ${ count($e) } - //~^ ERROR meta-variable expressions are unstable - }; -} - macro_rules! dollar_dollar { () => { macro_rules! bar { @@ -17,28 +10,5 @@ macro_rules! dollar_dollar { }; } -macro_rules! index { - ( $( $e:stmt ),* ) => { - $( ${ignore($e)} ${index()} )* - //~^ ERROR meta-variable expressions are unstable - //~| ERROR meta-variable expressions are unstable - }; -} - -macro_rules! ignore { - ( $( $i:stmt ),* ) => {{ - 0 $( + 1 ${ignore($i)} )* - //~^ ERROR meta-variable expressions are unstable - }}; -} - -macro_rules! length { - ( $( $e:stmt ),* ) => { - $( ${ignore($e)} ${length()} )* - //~^ ERROR meta-variable expressions are unstable - //~| ERROR meta-variable expressions are unstable - }; -} - fn main() { } diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr index 7f4adb728c0b6..09fa20c178dec 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr @@ -1,15 +1,5 @@ error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:3:10 - | -LL | ${ count($e) } - | ^^^^^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:11:16 + --> $DIR/required-feature.rs:4:16 | LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; | ^ @@ -19,7 +9,7 @@ LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:11:20 + --> $DIR/required-feature.rs:4:20 | LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; | ^ @@ -29,7 +19,7 @@ LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:11:39 + --> $DIR/required-feature.rs:4:39 | LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; | ^ @@ -39,7 +29,7 @@ LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:11:43 + --> $DIR/required-feature.rs:4:43 | LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; | ^ @@ -48,56 +38,6 @@ LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:22:13 - | -LL | $( ${ignore($e)} ${index()} )* - | ^^^^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:22:27 - | -LL | $( ${ignore($e)} ${index()} )* - | ^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:30:19 - | -LL | 0 $( + 1 ${ignore($i)} )* - | ^^^^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:37:13 - | -LL | $( ${ignore($e)} ${length()} )* - | ^^^^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:37:27 - | -LL | $( ${ignore($e)} ${length()} )* - | ^^^^^^^^^^ - | - = note: see issue #83527 for more information - = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 10 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs index 05c65fe869073..6c39345c6da98 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs @@ -1,5 +1,3 @@ -#![feature(macro_metavar_expr)] - // `curly` = Right hand side curly brackets // `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function" // `round` = Left hand side round brackets diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr index 0dda38290ab6b..356bf1ca5bcfd 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr @@ -1,221 +1,221 @@ error: unexpected token: $ - --> $DIR/syntax-errors.rs:46:8 + --> $DIR/syntax-errors.rs:44:8 | LL | ( $$ $a:ident ) => { | ^ note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:46:8 + --> $DIR/syntax-errors.rs:44:8 | LL | ( $$ $a:ident ) => { | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:53:19 + --> $DIR/syntax-errors.rs:51:19 | LL | ${count() a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:53:19 + --> $DIR/syntax-errors.rs:51:19 | LL | ${count() a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:56:20 + --> $DIR/syntax-errors.rs:54:20 | LL | ${count($i a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:56:20 + --> $DIR/syntax-errors.rs:54:20 | LL | ${count($i a b c)} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:58:23 + --> $DIR/syntax-errors.rs:56:23 | LL | ${count($i, 1 a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:58:23 + --> $DIR/syntax-errors.rs:56:23 | LL | ${count($i, 1 a b c)} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:60:21 + --> $DIR/syntax-errors.rs:58:21 | LL | ${count($i) a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:60:21 + --> $DIR/syntax-errors.rs:58:21 | LL | ${count($i) a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:63:22 + --> $DIR/syntax-errors.rs:61:22 | LL | ${ignore($i) a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:63:22 + --> $DIR/syntax-errors.rs:61:22 | LL | ${ignore($i) a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:65:21 + --> $DIR/syntax-errors.rs:63:21 | LL | ${ignore($i a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:65:21 + --> $DIR/syntax-errors.rs:63:21 | LL | ${ignore($i a b c)} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:68:19 + --> $DIR/syntax-errors.rs:66:19 | LL | ${index() a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:68:19 + --> $DIR/syntax-errors.rs:66:19 | LL | ${index() a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:70:19 + --> $DIR/syntax-errors.rs:68:19 | LL | ${index(1 a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:70:19 + --> $DIR/syntax-errors.rs:68:19 | LL | ${index(1 a b c)} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:73:19 + --> $DIR/syntax-errors.rs:71:19 | LL | ${index() a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:73:19 + --> $DIR/syntax-errors.rs:71:19 | LL | ${index() a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:75:19 + --> $DIR/syntax-errors.rs:73:19 | LL | ${index(1 a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:75:19 + --> $DIR/syntax-errors.rs:73:19 | LL | ${index(1 a b c)} | ^ error: meta-variable expression depth must be a literal - --> $DIR/syntax-errors.rs:82:33 + --> $DIR/syntax-errors.rs:80:33 | LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; | ^^^^^ error: unexpected token: { - --> $DIR/syntax-errors.rs:88:8 + --> $DIR/syntax-errors.rs:86:8 | LL | ( ${ length() } ) => { | ^^^^^^^^^^^^ note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:88:8 + --> $DIR/syntax-errors.rs:86:8 | LL | ( ${ length() } ) => { | ^^^^^^^^^^^^ error: expected one of: `*`, `+`, or `?` - --> $DIR/syntax-errors.rs:88:8 + --> $DIR/syntax-errors.rs:86:8 | LL | ( ${ length() } ) => { | ^^^^^^^^^^^^ error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:95:33 + --> $DIR/syntax-errors.rs:93:33 | LL | ( $( $i:ident ),* ) => { ${ ignore() } }; | ^^^^^^ error: only unsuffixes integer literals are supported in meta-variable expressions - --> $DIR/syntax-errors.rs:101:33 + --> $DIR/syntax-errors.rs:99:33 | LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; | ^^^^^ error: meta-variable expression parameter must be wrapped in parentheses - --> $DIR/syntax-errors.rs:107:33 + --> $DIR/syntax-errors.rs:105:33 | LL | ( $( $i:ident ),* ) => { ${ count{i} } }; | ^^^^^ error: expected identifier - --> $DIR/syntax-errors.rs:113:31 + --> $DIR/syntax-errors.rs:111:31 | LL | ( $( $i:ident ),* ) => { ${ {} } }; | ^^^^^^ error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:120:11 + --> $DIR/syntax-errors.rs:118:11 | LL | ${count(foo)} | ^^^^^ error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:128:11 + --> $DIR/syntax-errors.rs:126:11 | LL | ${ignore(bar)} | ^^^^^^ error: unrecognized meta-variable expression - --> $DIR/syntax-errors.rs:135:33 + --> $DIR/syntax-errors.rs:133:33 | LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and length error: `count` can not be placed inside the inner-most repetition - --> $DIR/syntax-errors.rs:12:24 + --> $DIR/syntax-errors.rs:10:24 | LL | ( $i:ident ) => { ${ count($i) } }; | ^^^^^^^^^^^^^ error: `count` can not be placed inside the inner-most repetition - --> $DIR/syntax-errors.rs:17:24 + --> $DIR/syntax-errors.rs:15:24 | LL | ( $i:ident ) => { ${ count($i) } }; | ^^^^^^^^^^^^^ error: variable 'i' is still repeating at this depth - --> $DIR/syntax-errors.rs:34:36 + --> $DIR/syntax-errors.rs:32:36 | LL | ( $( $i:ident ),* ) => { count($i) }; | ^^ error: expected expression, found `$` - --> $DIR/syntax-errors.rs:53:9 + --> $DIR/syntax-errors.rs:51:9 | LL | ${count() a b c} | ^ expected expression @@ -226,7 +226,7 @@ LL | extra_garbage_after_metavar!(a); = note: this error originates in the macro `extra_garbage_after_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:82:30 + --> $DIR/syntax-errors.rs:80:30 | LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; | ^ expected expression @@ -237,7 +237,7 @@ LL | metavar_depth_is_not_literal!(a); = note: this error originates in the macro `metavar_depth_is_not_literal` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:95:30 + --> $DIR/syntax-errors.rs:93:30 | LL | ( $( $i:ident ),* ) => { ${ ignore() } }; | ^ expected expression @@ -248,7 +248,7 @@ LL | metavar_token_without_ident!(a); = note: this error originates in the macro `metavar_token_without_ident` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:101:30 + --> $DIR/syntax-errors.rs:99:30 | LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; | ^ expected expression @@ -259,7 +259,7 @@ LL | metavar_with_literal_suffix!(a); = note: this error originates in the macro `metavar_with_literal_suffix` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:107:30 + --> $DIR/syntax-errors.rs:105:30 | LL | ( $( $i:ident ),* ) => { ${ count{i} } }; | ^ expected expression @@ -270,7 +270,7 @@ LL | metavar_without_parens!(a); = note: this error originates in the macro `metavar_without_parens` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:113:30 + --> $DIR/syntax-errors.rs:111:30 | LL | ( $( $i:ident ),* ) => { ${ {} } }; | ^ expected expression @@ -281,7 +281,7 @@ LL | open_brackets_without_tokens!(a); = note: this error originates in the macro `open_brackets_without_tokens` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:120:9 + --> $DIR/syntax-errors.rs:118:9 | LL | ${count(foo)} | ^ expected expression @@ -292,7 +292,7 @@ LL | unknown_count_ident!(a); = note: this error originates in the macro `unknown_count_ident` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:128:9 + --> $DIR/syntax-errors.rs:126:9 | LL | ${ignore(bar)} | ^ expected expression @@ -303,7 +303,7 @@ LL | unknown_ignore_ident!(a); = note: this error originates in the macro `unknown_ignore_ident` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:135:30 + --> $DIR/syntax-errors.rs:133:30 | LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; | ^ expected expression @@ -314,7 +314,7 @@ LL | unknown_metavar!(a); = note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:22:36 + --> $DIR/syntax-errors.rs:20:36 | LL | ( $( $i:ident ),* ) => { count(i) }; | ^ not found in this scope @@ -325,7 +325,7 @@ LL | no_curly__no_rhs_dollar__round!(a, b, c); = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:28:29 + --> $DIR/syntax-errors.rs:26:29 | LL | ( $i:ident ) => { count(i) }; | ^ not found in this scope @@ -336,13 +336,13 @@ LL | no_curly__no_rhs_dollar__no_round!(a); = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `a` in this scope - --> $DIR/syntax-errors.rs:147:37 + --> $DIR/syntax-errors.rs:145:37 | LL | no_curly__rhs_dollar__no_round!(a); | ^ not found in this scope error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:22:30 + --> $DIR/syntax-errors.rs:20:30 | LL | ( $( $i:ident ),* ) => { count(i) }; | ^^^^^ not found in this scope @@ -353,7 +353,7 @@ LL | no_curly__no_rhs_dollar__round!(a, b, c); = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:28:23 + --> $DIR/syntax-errors.rs:26:23 | LL | ( $i:ident ) => { count(i) }; | ^^^^^ not found in this scope @@ -364,7 +364,7 @@ LL | no_curly__no_rhs_dollar__no_round!(a); = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:39:23 + --> $DIR/syntax-errors.rs:37:23 | LL | ( $i:ident ) => { count($i) }; | ^^^^^ not found in this scope