Skip to content

if_same_then_else false positive when using macros #11607

@Glamhoth

Description

@Glamhoth

Summary

Clippy incorrectly throws a if_same_then_else warning when using macros.

Lint Name

if_same_then_else

Reproducer

When trying to check this code:

if value {
    logln!("Successful");
} else {
    logln!("Failed");
}

I get a clippy warning:

error: this `if` has identical blocks
  --> src/main.rs:18:14
   |
18 |       if value {
   |  ______________^
19 | |         logln!("Successful");
20 | |     } else {
   | |_____^
   |
note: same as this
  --> src/main.rs:20:12
   |
20 |       } else {
   |  ____________^
21 | |         logln!("Failed");
22 | |     }
   | |_____^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
   = note: `#[deny(clippy::if_same_then_else)]` on by default

In this case macro logln is just an alias for rtt_print:
pub use rtt_target::rprintln as logln;

Version

rustc 1.74.0-nightly (58e967a9c 2023-09-03)
binary: rustc
commit-hash: 58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2
commit-date: 2023-09-03
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions