diff options
| author | Ralf Jung <post@ralfj.de> | 2021-07-24 14:08:04 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2021-07-24 14:08:04 +0200 |
| commit | 3b9f8116a2d82ad2a0c10f5cc7d45fb344d77f0e (patch) | |
| tree | f1eae224e2bda31a53f3a5ea7ae9db5c10d2b609 /compiler/rustc_mir/src/const_eval | |
| parent | 1c66d11a34047be1eb6c50703f8ba6689a15e716 (diff) | |
get rid of NoMirFor error variant
Diffstat (limited to 'compiler/rustc_mir/src/const_eval')
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/machine.rs | 19 |
1 files changed, 4 insertions, 15 deletions
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( |
