diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-07-27 19:52:46 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-27 19:52:46 +0900 |
| commit | d25439481cd442dec4991f5bd0082c8b71004889 (patch) | |
| tree | 27e2c876cc7fd6f612143e693e5cef0afdcc5fbf | |
| parent | 90f6d7becb6bce73b8a8a709c76c23554f859770 (diff) | |
| parent | 3b9f8116a2d82ad2a0c10f5cc7d45fb344d77f0e (diff) | |
| download | rust-d25439481cd442dec4991f5bd0082c8b71004889.tar.gz rust-d25439481cd442dec4991f5bd0082c8b71004889.zip | |
Rollup merge of #87427 - RalfJung:no-mir-for, r=oli-obk
get rid of NoMirFor error variant The only place where we throw that error, it is very quickly caught again and turned into a different error. So raise that other error immediately.
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/error.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/machine.rs | 19 |
2 files changed, 4 insertions, 18 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 94ac303b109..dad23d6255a 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -402,8 +402,6 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> { pub enum UnsupportedOpInfo { /// Free-form case. Only for errors that are never caught! Unsupported(String), - /// Could not find MIR for a function. - NoMirFor(DefId), /// Encountered a pointer where we needed raw bytes. ReadPointerAsBytes, // @@ -421,7 +419,6 @@ impl fmt::Display for UnsupportedOpInfo { match self { Unsupported(ref msg) => write!(f, "{}", msg), ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did), - NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did), ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",), ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did), } diff --git a/compiler/rustc_mir/src/const_eval/machine.rs b/compiler/rustc_mir/src/const_eval/machine.rs index c809f4f273a..daaf68c1d2b 100644 --- a/compiler/rustc_mir/src/const_eval/machine.rs +++ b/compiler/rustc_mir/src/const_eval/machine.rs @@ -212,7 +212,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, if ecx.tcx.is_ctfe_mir_available(def.did) { Ok(ecx.tcx.mir_for_ctfe_opt_const_arg(def)) } else { - throw_unsup!(NoMirFor(def.did)) + let path = ecx.tcx.def_path_str(def.did); + Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path)) + .into()) } } _ => Ok(ecx.tcx.instance_mir(instance)), @@ -247,20 +249,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, } } // This is a const fn. Call it. - Ok(Some(match ecx.load_mir(instance.def, None) { - Ok(body) => body, - Err(err) => { - if let err_unsup!(NoMirFor(did)) = err.kind() { - let path = ecx.tcx.def_path_str(*did); - return Err(ConstEvalErrKind::NeedsRfc(format!( - "calling extern function `{}`", - path - )) - .into()); - } - return Err(err); - } - })) + Ok(Some(ecx.load_mir(instance.def, None)?)) } fn call_intrinsic( |
