Skip to content

Commit 223f580

Browse files
committed
Remove is_const_fn in find_mir_or_eval_fn
1 parent cc4345a commit 223f580

File tree

1 file changed

+3
-9
lines changed
  • compiler/rustc_const_eval/src/const_eval

1 file changed

+3
-9
lines changed

compiler/rustc_const_eval/src/const_eval/machine.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -265,24 +265,18 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
265265

266266
// Only check non-glue functions
267267
if let ty::InstanceDef::Item(def) = instance.def {
268-
let mut is_const_fn = true;
269-
270268
// Execution might have wandered off into other crates, so we cannot do a stability-
271269
// sensitive check here. But we can at least rule out functions that are not const
272270
// at all.
273271
if !ecx.tcx.is_const_fn_raw(def.did) {
274272
// allow calling functions marked with #[default_method_body_is_const].
275273
if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) {
276-
is_const_fn = false;
274+
// We certainly do *not* want to actually call the fn
275+
// though, so be sure we return here.
276+
throw_unsup_format!("calling non-const function `{}`", instance)
277277
}
278278
}
279279

280-
if !is_const_fn {
281-
// We certainly do *not* want to actually call the fn
282-
// though, so be sure we return here.
283-
throw_unsup_format!("calling non-const function `{}`", instance)
284-
}
285-
286280
if let Some(new_instance) = ecx.hook_special_const_fn(instance, args)? {
287281
// We call another const fn instead.
288282
return Self::find_mir_or_eval_fn(ecx, new_instance, _abi, args, _ret, _unwind);

0 commit comments

Comments
 (0)