@@ -6,8 +6,9 @@ use rustc_abi::{Align, Size};
66use rustc_ast:: Mutability ;
77use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap , IndexEntry } ;
88use rustc_errors:: inline_fluent;
9+ use rustc_hir:: attrs:: AttributeKind ;
910use rustc_hir:: def_id:: { DefId , LocalDefId } ;
10- use rustc_hir:: { self as hir, CRATE_HIR_ID , LangItem } ;
11+ use rustc_hir:: { self as hir, CRATE_HIR_ID , LangItem , find_attr } ;
1112use rustc_middle:: mir:: AssertMessage ;
1213use rustc_middle:: mir:: interpret:: { Pointer , ReportedErrorInfo } ;
1314use rustc_middle:: query:: TyCtxtAt ;
@@ -440,7 +441,9 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
440441 // sensitive check here. But we can at least rule out functions that are not const at
441442 // all. That said, we have to allow calling functions inside a `const trait`. These
442443 // *are* const-checked!
443- if !ecx. tcx . is_const_fn ( def) || ecx. tcx . has_attr ( def, sym:: rustc_do_not_const_check) {
444+ if !ecx. tcx . is_const_fn ( def)
445+ || find_attr ! ( ecx. tcx. get_all_attrs( def) , AttributeKind :: RustcDoNotConstCheck )
446+ {
444447 // We certainly do *not* want to actually call the fn
445448 // though, so be sure we return here.
446449 throw_unsup_format ! ( "calling non-const function `{}`" , instance)
0 commit comments