Skip to content

Commit 5e695bb

Browse files
committed
Update CTFE to allow fns marked with the attr
1 parent 554fad7 commit 5e695bb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

compiler/rustc_mir/src/const_eval/machine.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
235235
// sensitive check here. But we can at least rule out functions that are not const
236236
// at all.
237237
if !ecx.tcx.is_const_fn_raw(def.did) {
238-
// Some functions we support even if they are non-const -- but avoid testing
239-
// that for const fn!
240-
ecx.hook_panic_fn(instance, args)?;
241-
// We certainly do *not* want to actually call the fn
242-
// though, so be sure we return here.
243-
throw_unsup_format!("calling non-const function `{}`", instance)
238+
// allow calling functions marked with #[default_method_body_is_const].
239+
if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) {
240+
// Some functions we support even if they are non-const -- but avoid testing
241+
// that for const fn!
242+
ecx.hook_panic_fn(instance, args)?;
243+
// We certainly do *not* want to actually call the fn
244+
// though, so be sure we return here.
245+
throw_unsup_format!("calling non-const function `{}`", instance)
246+
}
244247
}
245248
}
246249
// This is a const fn. Call it.

0 commit comments

Comments
 (0)