Skip to content

Clippy misses integer arithmetic when one operand is a reference #5328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RalfJung opened this issue Mar 17, 2020 · 0 comments · Fixed by #5329
Closed

Clippy misses integer arithmetic when one operand is a reference #5328

RalfJung opened this issue Mar 17, 2020 · 0 comments · Fixed by #5329
Assignees
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@RalfJung
Copy link
Member

RalfJung commented Mar 17, 2020

I expected this code to trigger an "integer arithmetic" warning:

#![warn(clippy::integer_arithmetic)]

pub fn foo(x: &i32) -> i32 {
    let a = 5;
    a+x
}

However, no such warning is emitted.

@matthiaskrgr matthiaskrgr self-assigned this Mar 17, 2020
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Mar 17, 2020
changelog: integer_arithmetic fix false negatives with references on integers

Fixes rust-lang#5328
@flip1995 flip1995 added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Mar 18, 2020
bors added a commit that referenced this issue Mar 18, 2020
integer_arithmetic: detect integer arithmetic on references.

changelog: integer_arithmetic fix false negatives with references on integers

Fixes #5328
@bors bors closed this as completed in c7c7ab2 Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants