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

Miri does not get entirely unleashed #71630

Closed
RalfJung opened this issue Apr 28, 2020 · 4 comments · Fixed by #71631
Closed

Miri does not get entirely unleashed #71630

RalfJung opened this issue Apr 28, 2020 · 4 comments · Fixed by #71631
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-miri Area: The miri tool C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@RalfJung
Copy link
Member

I tried this code on nightly with -Zunleash-the-miri-inside-of-you:

#![allow(const_err)]
#![feature(const_raw_ptr_deref)]

use std::cell::UnsafeCell;


struct Meh {
    x: UnsafeCell<i32>,
}

unsafe impl Sync for Meh {}

static MEH: Meh = Meh {
    x: UnsafeCell::new(42),
};

const WRITE: () = unsafe {
    *MEH.x.get() = 12;
};


fn main() {
}

I expected that that should try to mutate a global, and show an error along those lines. But instead, const-checking gets in the way, even though "unleash Miri" should disable that:

warning: skipping const checks
  --> unleash.rs:18:6
   |
18 |     *MEH.x.get() = 12;
   |      ^^^

error[E0019]: constant contains unimplemented expression type
  --> unleash.rs:18:5
   |
18 |     *MEH.x.get() = 12;
   |     ^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0019`.
@RalfJung
Copy link
Member Author

Cc @rust-lang/wg-const-eval

@RalfJung
Copy link
Member Author

Ah, I need to add the const_mut_refs feature gate. But that's basically impossible to figure out without reading the rustc sources.

I think unleashing miri should ignore all those feature gates. IMO it makes little sense to let this unleash features that do not even have a feature gate yet, but not let it unleash features that do.

@ecstatic-morse
Copy link
Contributor

Cross posting from #71631:

The goal of the current behavior is to prevent unnecessary use of -Zunleash in the test suite when feature gates would suffice. Requiring that test writers use feature gates makes it easy to see what tests no longer need -Zunleash when a new feature is implemented on nightly.

Without a diagnostics bug--we were not suggesting that nightly users enable #![feature(const_mut_refs)] when we saw a deref of a mutable reference--the solution to the problem you encountered would have been clear. We should fix this instead.

@RalfJung
Copy link
Member Author

(I responded there, summary: I disagree.)

@RalfJung RalfJung added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-miri Area: The miri tool C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Apr 29, 2020
@bors bors closed this as completed in a0c61a9 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-miri Area: The miri tool C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants