Closed
Description
I tried this code:
macro_rules! x {
{} => { "q" };
}
fn f() -> String {
(x! {}.to_string())
}
fn main() {}
I expected to see this happen: No warning about unnecessary parens
Instead, this happened: A warning about unnecessary parens suggesting to remove parens. Attempting to actually follow the advice causes an error.
warning: unnecessary parentheses around block return value
--> src/main.rs:6:5
|
6 | (x! {}.to_string())
| ^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
This can be worked around by using x!().to_string
or (x! {}).to_string()
instead, however this shouldn't be necessary as the original code is fine.
This happens since Rust 1.42.
Meta
rustc --version --verbose
:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0