Closed
Description
Negative numbers are no longer parsed as literals when used as a parameter to a macro inside a macro. This appears to be a regression from stable to nightly.
According to cargo-bisect-rustc, #69023 is responsible (thanks to @jebrosen for helping with this on the Rust discord)
Specifically, the changes to this function look suspicious.
The below fails to compile:
macro_rules! foo {
($a:literal) => {
bar!($a)
}
}
macro_rules! bar {
($b:literal) => {}
}
fn main() {
// fails on nightly, but not stable
foo!(-2);
// doesn't fail
bar!(-2);
}
with the following error on nightly-2020-02-14,
~ >cargo b
error: no rules expected the token `-2`
--> src\main.rs:3:14
|
3 | bar!($a)
| ^^ no rules expected this token in macro call
...
7 | macro_rules! bar {
| ---------------- when calling this macro
...
12 | foo!(-2);
| --------- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error