Skip to content
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

Remove negative integer literal checks. #3677

Merged
merged 2 commits into from
Jan 21, 2019
Merged

Remove negative integer literal checks. #3677

merged 2 commits into from
Jan 21, 2019

Conversation

daxpedda
Copy link
Contributor

@daxpedda daxpedda commented Jan 20, 2019

Fixes #3678.

@phansch phansch added the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Jan 21, 2019
@oli-obk oli-obk closed this Jan 21, 2019
@oli-obk oli-obk reopened this Jan 21, 2019
@@ -92,11 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
}
},
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
let ty = cx.tables.expr_ty(arg);
if ty.is_integral() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing the lint entirely, I think we should only skip reporting it if arg is a constant. You can use clippy's const folder to check if it's a constant. If it is, don't report the lint. That should cause -1 and -(-1) to stop linting, but -i and -(-i) not.

Copy link
Contributor Author

@daxpedda daxpedda Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if constant_simple(cx, cx.tables, expr).is_none() {

Not sure if that is what you meant, but it seems to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jup, exactly what I had in mind

tests/ui/arithmetic.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor

oli-obk commented Jan 21, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Jan 21, 2019

📌 Commit 87d24e1 has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Jan 21, 2019

⌛ Testing commit 87d24e1 with merge 9d5b148...

bors added a commit that referenced this pull request Jan 21, 2019
Remove negative integer literal checks.

Fixes #3678.
@bors
Copy link
Contributor

bors commented Jan 21, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: oli-obk
Pushing 9d5b148 to master...

@bors bors merged commit 87d24e1 into rust-lang:master Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants