Update CTFE to allow fns marked with the attr
This commit is contained in:
@@ -235,6 +235,8 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
|||||||
// sensitive check here. But we can at least rule out functions that are not const
|
// sensitive check here. But we can at least rule out functions that are not const
|
||||||
// at all.
|
// at all.
|
||||||
if !ecx.tcx.is_const_fn_raw(def.did) {
|
if !ecx.tcx.is_const_fn_raw(def.did) {
|
||||||
|
// allow calling functions marked with #[default_method_body_is_const].
|
||||||
|
if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) {
|
||||||
// Some functions we support even if they are non-const -- but avoid testing
|
// Some functions we support even if they are non-const -- but avoid testing
|
||||||
// that for const fn!
|
// that for const fn!
|
||||||
ecx.hook_panic_fn(instance, args)?;
|
ecx.hook_panic_fn(instance, args)?;
|
||||||
@@ -243,6 +245,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
|||||||
throw_unsup_format!("calling non-const function `{}`", instance)
|
throw_unsup_format!("calling non-const function `{}`", instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// This is a const fn. Call it.
|
// This is a const fn. Call it.
|
||||||
Ok(Some(match ecx.load_mir(instance.def, None) {
|
Ok(Some(match ecx.load_mir(instance.def, None) {
|
||||||
Ok(body) => body,
|
Ok(body) => body,
|
||||||
|
|||||||
Reference in New Issue
Block a user