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

Cargo check fails to detect an error. #52484

Closed
graylikeme opened this issue Jul 18, 2018 · 8 comments
Closed

Cargo check fails to detect an error. #52484

graylikeme opened this issue Jul 18, 2018 · 8 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example

Comments

@graylikeme
Copy link

graylikeme commented Jul 18, 2018

When running cargo check it fails to output an error that is detected with cargo build
b_reg is u8 and running stable 1.27.1

error: attempt to shift right with overflow
  --> src\cpu\instructions.rs:39:36
   |
39 |             cpu.flags.half_carry = ((b_reg | 0x0F) - 1) >> 31 > 0;
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[deny(exceeding_bitshifts)] on by default
@graylikeme graylikeme changed the title Cargo check donot detect an error. Cargo check fails to detect an error. Jul 18, 2018
@graylikeme
Copy link
Author

graylikeme commented Jul 18, 2018

Opened in cargo repo rust-lang/cargo#5747

@graylikeme
Copy link
Author

This is the correct place after all

@graylikeme graylikeme reopened this Jul 18, 2018
@estebank
Copy link
Contributor

estebank commented Jan 8, 2019

It seems like cargo check doesn't run the lints by default, which it arguably should.

@estebank estebank added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jan 8, 2019
@ehuss
Copy link
Contributor

ehuss commented Jan 8, 2019

There are a few things that are not enabled for --emit=rmeta. There is a general issue for this at #49292 that lists some of the things that are not checked.

@RalfJung
Copy link
Member

@ehuss specifically for bitshift lints, there have been some fixes fairly recently (see #70660). Could you try with the latest beta?

@RalfJung
Copy link
Member

Sorry, pinged the wrong person -- @graylikeme could you test again with the latest beta?

Also it would help if you could distill this into a self-contained example so that we can reproduce the problem on the playground (https://play.rust-lang.org)

@RalfJung RalfJung added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 30, 2020
@ehuss
Copy link
Contributor

ehuss commented Apr 30, 2020

Here is an example, it passes with cargo check, but fails cargo build, latest nightly rustc 1.45.0-nightly (fa51f810e 2020-04-29).

fn main() {
    let a: u8 = 42;
    let b = ((a | 0x0F) - 1) >> 31 > 0;
    println!("{}", b);
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4998a76829fb44657cd8ed814fb2a191

@RalfJung
Copy link
Member

Thanks! This looks like we don't run MIR optimizations with cargo check... #70923 has some more concrete plans for this, so I am closing this here in favor of the other one even though that one is newer. I will post your example there.

@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
Projects
None yet
Development

No branches or pull requests

5 participants