Skip to content

suspicious use of binary operator wrongly flags logical operators in conditions #7084

@pwnorbitals

Description

@pwnorbitals

Lint name: suspicious use of binary operator

I tried this code (uses impl_ops crate):

impl_op_ex!(- |a : &Struct, b : &Struct| -> Struct{ if a.getA() == b.getA() && a.getB() == b.getB() { return Struct::new(a.getData() - b.getData(), a.getA(), a.getB()); } todo!("A or B change on substraction is not yet supported"); });

I expected to see this happen: no error or warning is thrown

Instead, this happened: error is thrown on the && logical operator in the if expression

Meta

  • cargo clippy -V: clippy 0.0.212 (cb75ad5d 2021-02-10)
  • rustc -Vv:
    rustc 1.50.0 (cb75ad5db 2021-02-10) binary: rustc commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b commit-date: 2021-02-10 host: x86_64-pc-windows-msvc release: 1.50.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-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