You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running cargo check succeeds, while cargo build fails:
$ cargo build
Compiling check-panicking-const v0.1.0 (.../check-panicking-const)
error[E0080]: evaluation of constant value failed
--> src/lib.rs:6:21
|
6 | const FOO: () = unimplemented!();
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', src/lib.rs:6:21
|
= note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
note: erroneous constant used
--> src/lib.rs:10:17
|
10 | let _: () = <() as Foo>::FOO;
| ^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0080`.
error: could not compile `check-panicking-const` (lib) due to previous error
I would expect cargo build and cargo check to exhibit the same behavior.
This has practical implications. For example, I'm working on implementing this technique in zerocopy, which intentionally generates panicking constants when an unsound transmutation is attempted. The behavior mismatch between cargo check and cargo build means that unsound transmutes appear to compile until the user runs cargo build. For users who primarily use cargo check during development (I am included in this group), this can result in spending a lot of time going down a path that will end up with a dead end.
These errors are called "post monomophization errors" because they only appear once functions are monomorphized and generated. It's a known issue that they are not run during cargo check. Closing in favor of #99682. There's also #107510 which attempts to fix it
I have the following code:
Running
cargo check
succeeds, whilecargo build
fails:I would expect
cargo build
andcargo check
to exhibit the same behavior.This has practical implications. For example, I'm working on implementing this technique in zerocopy, which intentionally generates panicking constants when an unsound transmutation is attempted. The behavior mismatch between
cargo check
andcargo build
means that unsound transmutes appear to compile until the user runscargo build
. For users who primarily usecargo check
during development (I am included in this group), this can result in spending a lot of time going down a path that will end up with a dead end.This is an instance of #70923.
Version
The text was updated successfully, but these errors were encountered: