-
Notifications
You must be signed in to change notification settings - Fork 348
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
Incorrect detection of compilation failures when there's a panic in const evaluation. #2923
Comments
The problem isn't with doctests, it's a fundamental problem with how Miri works (currently?). Your example can be rewritten as: pub struct Foo<const N: usize>;
impl<const N: usize> Foo<N> {
const N_GT_ZERO: () = assert!(N > 0);
pub fn new() -> Self {
// This will cause a panic at const-time if `N == 0`
let _ = Self::N_GT_ZERO;
Self
}
}
fn main() {
let foo = Foo::<0>::new();
} Then if you try to run it with
The program "builds" successfully, and fails at runtime. All const eval and post-mono errors are runtime errors to Miri. |
compile_fail
doctests when there's a panic in const evaluation.
@saethlin Thanks for the insight! I amended the title to make the situation a bit clearer. Feel free to modify it further if it's not appropriate. I imagine the next step is to determine if this is a "wontfix" or if there's an actionable path forward. |
I think this is a duplicate of #2423 (I looked for that issue earlier and came up empty). That other Miri issue links to a rust-lang/rust issue which has some PRs linked to it. We'd like to fix this, but don't hold your breath. You might be able to use |
Doctests that yield a compile-time error due to a panic in a const evaluation are buggy under MIRI. As an example, consider the following code:
Running
cargo test
informs us that the one doc test passed.Now, running
cargo +nightly miri test
instead marks the test as failed (i.e. MIRI thinks it somehow compiled successfully)Removing the
compile_fail
annotation and rerunning miri also fails (because of the intended compilation error).It seems like there might be a wart in how
compile_fail
doctests are handled by MIRI.The text was updated successfully, but these errors were encountered: