Update CTFE to allow fns marked with the attr
This commit is contained in:
parent
554fad7bda
commit
5e695bbba1
1 changed files with 9 additions and 6 deletions
|
@ -235,12 +235,15 @@ 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) {
|
||||||
// Some functions we support even if they are non-const -- but avoid testing
|
// allow calling functions marked with #[default_method_body_is_const].
|
||||||
// that for const fn!
|
if !ecx.tcx.has_attr(def.did, sym::default_method_body_is_const) {
|
||||||
ecx.hook_panic_fn(instance, args)?;
|
// Some functions we support even if they are non-const -- but avoid testing
|
||||||
// We certainly do *not* want to actually call the fn
|
// that for const fn!
|
||||||
// though, so be sure we return here.
|
ecx.hook_panic_fn(instance, args)?;
|
||||||
throw_unsup_format!("calling non-const function `{}`", instance)
|
// We certainly do *not* want to actually call the fn
|
||||||
|
// though, so be sure we return here.
|
||||||
|
throw_unsup_format!("calling non-const function `{}`", instance)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This is a const fn. Call it.
|
// This is a const fn. Call it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue