Skip to content

neg_multiply should show a suggestion #8115

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
kpcyrd opened this issue Dec 10, 2021 · 2 comments · Fixed by #8144
Closed

neg_multiply should show a suggestion #8115

kpcyrd opened this issue Dec 10, 2021 · 2 comments · Fixed by #8144
Assignees
Labels
good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@kpcyrd
Copy link

kpcyrd commented Dec 10, 2021

Description

  --> worker/src/proc.rs:78:19
   |
78 |         let pid = pid as i32 * -1;
   |                   ^^^^^^^^^^^^^^^
   |
   = note: `#[warn(clippy::neg_multiply)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply

There's no suggestion how this should be done and the docs just say:

It’s more readable to just negate.

but don't show how this is supposed to be done.

I had to google "how to negate an integer" and clippy should just suggest this:

let pid = -(pid as i32);

Version

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Additional Labels

No response

@Gh0stm4chine
Copy link
Contributor

@rustbot claim

@xFrednet xFrednet added good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions labels Dec 11, 2021
@bors bors closed this as completed in 9ae4043 Dec 23, 2021
@kpcyrd
Copy link
Author

kpcyrd commented Dec 23, 2021

@Gh0stm4chine Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants