1
Fork 0

Remove #[default..] and add #[const_trait]

This commit is contained in:
Deadbeef 2022-03-16 20:49:54 +11:00 committed by Oli Scherer
parent f558990814
commit 257f06587c
30 changed files with 74 additions and 250 deletions

View file

@ -277,8 +277,9 @@ 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
// at all.
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) {
// allow calling functions inside a trait marked with #[const_trait].
if !matches!(ecx.tcx.trait_of_item(def.did), Some(trait_id) if ecx.tcx.has_attr(trait_id, sym::const_trait))
{
// 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)