-
Notifications
You must be signed in to change notification settings - Fork 360
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
Improve errors when invoked with wrong sysroot (missing MIR) #1834
Comments
It shouldn't even be possible to install miri on stable AFAIK.
I guess this error could be better. The sysroot needs to be compiled with |
Indeed, how did you install this?
Yeah... we used to have a nicer error but that probably bitrotted now that |
It appears to come by default via the standalone installers: $ curl https://static.rust-lang.org/dist/rust-1.52.1-x86_64-unknown-linux-gnu.tar.gz | tar xz
$ rust-1.52.1-x86_64-unknown-linux-gnu/install.sh
$ miri
error: the option `Z` is only accepted on the nightly compiler
$ RUSTC_BOOTSTRAP=1 miri --version
rustc 1.52.1 (9bc8c42bb 2021-05-09) |
oops that's a bug. I reported an issue for this: rust-lang/rust#86286. Good thing that Miri dosn't work there, it's not supposed to even be part of this release. ;) |
For the ICE when a MIR body is missing, we need to check --- a/compiler/rustc_mir/src/interpret/machine.rs
+++ b/compiler/rustc_mir/src/interpret/machine.rs
@@ -144,7 +144,13 @@ fn load_mir(
ecx: &InterpCx<'mir, 'tcx, Self>,
instance: ty::InstanceDef<'tcx>,
) -> InterpResult<'tcx, &'tcx mir::Body<'tcx>> {
- Ok(ecx.tcx.instance_mir(instance))
+ let def_id = instance.def_id();
+ // Avoid ICE when MIR is missing: first check if it is available.
+ if ecx.tcx.is_mir_available(def_id) {
+ Ok(ecx.tcx.instance_mir(instance))
+ } else {
+ throw_unsup!(NoMirFor(def_id))
+ }
}
/// Entry point to all function calls. This will now ICE for shims because they claim to have no MIR available. @oli-obk any suggestions for what to do here? I'd rather not duplicate the entire logic of |
that would invoke is_mir_available on every instance_mir call, probably not a problem, but should bench it at least. |
I'm open to other options. :D |
I see what you did there, but libcore only has Option Make instance_mir_inner that does the main logic and takes a closure argument for loading the MIR. instance_mir calls it and passes Some(optimized_mir()) and unwraps the result of instance_mir_inner. |
Honestly I didn't even see what I did there. Now I do. ;) Can't the queries called by |
if you add _opt to their name and add inherent functions of the original name that unwrap, i think that would be fine |
Yeah that sounds like the best approach to me then. |
Maybe you could show a warning at startup if |
FWIW, this is the backtrace of the ICE:
|
miri
behaves like a strangerustc
driver:The text was updated successfully, but these errors were encountered: