Skip to content

Check does not evaluate const assertion, build does #111240

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
matthiasbeyer opened this issue May 5, 2023 · 2 comments
Closed

Check does not evaluate const assertion, build does #111240

matthiasbeyer opened this issue May 5, 2023 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@matthiasbeyer
Copy link

matthiasbeyer commented May 5, 2023

I tried this code:

struct Check;
impl Check {
    const CHECK: () = assert!(1 == 2);
}

fn main() {
    let _ = Check::CHECK;
}

(playground)

Above code does not build if you use the playground "run" button.
But the "build" button, which seems to be the equivalent to cargo-check on above code, does "build" (typecheck and everything).

This is reproducible with:

  • cargo-build/cargo-run does fail the build, as expected
  • cargo-check does not fail the build, unexpectedly

Meta

rustc --version --verbose:

rustc 1.69.0 (84c898d65 2023-04-16)                                                                                                                                                                                                            
binary: rustc                                                                                                                                                                                                                                  
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc                                                                                                                                                                                          
commit-date: 2023-04-16                                                                                                                                                                                                                        
host: x86_64-unknown-linux-gnu                                                                                                                                                                                                                 
release: 1.69.0                                                                                                                                                                                                                                
LLVM version: 15.0.7  

On the playground:

  • stable as described above
  • beta as described above
  • nightly as expected: the "build" button (cargo-check as I assume), fails as expected

Found with @TheNeikos, also thanks to them for helping me reducing the code example.

@matthiasbeyer matthiasbeyer added the C-bug Category: This is a bug. label May 5, 2023
@TheNeikos
Copy link
Contributor

This might be related to #111202

@oli-obk
Copy link
Contributor

oli-obk commented May 5, 2023

Duplicate of #99682

@oli-obk oli-obk marked this as a duplicate of #99682 May 5, 2023
@oli-obk oli-obk closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants