Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macro_metavar_expr] Add tests to ensure the feature requirement #95764

Merged
merged 1 commit into from Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs
Expand Up @@ -5,5 +5,40 @@ macro_rules! count {
};
}

macro_rules! dollar_dollar {
() => {
macro_rules! bar {
( $$( $$any:tt )* ) => { $$( $$any )* };
//~^ ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
}
};
}

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() {
}
83 changes: 82 additions & 1 deletion src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr
Expand Up @@ -7,6 +7,87 @@ LL | ${ count(e) }
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error: aborting due to previous error
error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:16
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:20
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:39
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:43
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:22:13
|
LL | $( ${ignore(e)} ${index()} )*
| ^^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:22:26
|
LL | $( ${ignore(e)} ${index()} )*
| ^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:30:19
|
LL | 0 $( + 1 ${ignore(i)} )*
| ^^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:37:13
|
LL | $( ${ignore(e)} ${length()} )*
| ^^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:37:26
|
LL | $( ${ignore(e)} ${length()} )*
| ^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0658`.