Closed shepmaster closed 5 months ago
That's a pretty interesting find.
Even stranger, the warning is sensitive to how the original function was formatted. I don't think I've ever seen that behavior before 😬. This code has no warnings and only differs in a few newlines:
I think there is an issue with the lint. For example this does not create warnings for me (note that there is no macro)
fn demo() -> u8 { {
1
} }
while this creates the unused braces warning (here the suggestion at least does not break the code)
fn demo() -> u8 { { 1 } }
I don't think this whitespace-dependent behavior is intended so it might be worthwhile opening an issue in rust.
I can confirm that no matter the formatting the expanded code is identical. It seems this lint runs on code before macro expansion so I don't think this can be fixed by tracing
for example by adding an allow
.
Looks like this already exists at https://github.com/rust-lang/rust/issues/116347
Bug Report
Version
Platform
N/A (reproduced on the Rust Playground (x86_64 Linux) and my laptop (aarch64-macos-darwin)
Description
I tried this code:
I expected this to compile with no warnings. Instead, a warning is triggered and the warning would make invalid code:
Even stranger, the warning is sensitive to how the original function was formatted. I don't think I've ever seen that behavior before 😬. This code has no warnings and only differs in a few newlines: