-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Macros: match const { ... } with expr nonterminal in edition 2024
Co-authored-by: Eric Holk <[email protected]> Signed-off-by: Vincenzo Palazzo <[email protected]>
- Loading branch information
1 parent
e0b7d92
commit 09b6eca
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error: no rules expected the token `const` | ||
--> $DIR/expr_2021_inline_const.rs:22:12 | ||
| | ||
LL | macro_rules! m2021 { | ||
| ------------------ when calling this macro | ||
... | ||
LL | m2021!(const { 1 }); | ||
| ^^^^^ no rules expected this token in macro call | ||
| | ||
note: while trying to match meta-variable `$e:expr_2021` | ||
--> $DIR/expr_2021_inline_const.rs:11:6 | ||
| | ||
LL | ($e:expr_2021) => { | ||
| ^^^^^^^^^^^^ | ||
|
||
error: no rules expected the token `const` | ||
--> $DIR/expr_2021_inline_const.rs:23:12 | ||
| | ||
LL | macro_rules! m2024 { | ||
| ------------------ when calling this macro | ||
... | ||
LL | m2024!(const { 1 }); | ||
| ^^^^^ no rules expected this token in macro call | ||
| | ||
note: while trying to match meta-variable `$e:expr` | ||
--> $DIR/expr_2021_inline_const.rs:17:6 | ||
| | ||
LL | ($e:expr) => { | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: no rules expected the token `const` | ||
--> $DIR/expr_2021_inline_const.rs:22:12 | ||
| | ||
LL | macro_rules! m2021 { | ||
| ------------------ when calling this macro | ||
... | ||
LL | m2021!(const { 1 }); | ||
| ^^^^^ no rules expected this token in macro call | ||
| | ||
note: while trying to match meta-variable `$e:expr_2021` | ||
--> $DIR/expr_2021_inline_const.rs:11:6 | ||
| | ||
LL | ($e:expr_2021) => { | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@ revisions: edi2021 edi2024 | ||
//@[edi2024]compile-flags: --edition=2024 -Z unstable-options | ||
//@[edi2021]compile-flags: --edition=2021 | ||
|
||
// This test ensures that the inline const match only on edition 2024 | ||
#![feature(expr_fragment_specifier_2024)] | ||
#![feature(inline_const)] | ||
#![allow(incomplete_features)] | ||
|
||
macro_rules! m2021 { | ||
($e:expr_2021) => { | ||
$e | ||
}; | ||
} | ||
|
||
macro_rules! m2024 { | ||
($e:expr) => { | ||
$e | ||
}; | ||
} | ||
fn main() { | ||
m2021!(const { 1 }); //~ ERROR: no rules expected the token `const` | ||
m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected the token `const` | ||
} |