From 257f06587c7cb271517ca9a02c4ed3fd4581f71e Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 16 Mar 2022 20:49:54 +1100 Subject: Remove `#[default..]` and add `#[const_trait]` --- compiler/rustc_const_eval/src/const_eval/machine.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_const_eval/src/const_eval') diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 9de5541bfe3..8bd8280497c 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -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) -- cgit 1.4.1-3-g733a5