File tree Expand file tree Collapse file tree
rustc_hir_analysis/src/collect
rustc_mir_build/src/builder/expr Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use core::ops::ControlFlow;
22
33use rustc_errors:: { Applicability , StashKey , Suggestions } ;
44use rustc_hir:: attrs:: AttributeKind ;
5+ use rustc_hir:: def:: DefKind ;
56use rustc_hir:: def_id:: { DefId , LocalDefId } ;
67use rustc_hir:: intravisit:: VisitorExt ;
78use rustc_hir:: { self as hir, AmbigArg , HirId , find_attr} ;
@@ -423,7 +424,8 @@ fn infer_placeholder_type<'tcx>(
423424 let tcx = cx. tcx ( ) ;
424425
425426 fn is_type_const < ' tcx > ( tcx : TyCtxt < ' tcx > , id : DefId ) -> bool {
426- find_attr ! ( tcx. get_all_attrs( id) , AttributeKind :: TypeConst ( _) )
427+ matches ! ( tcx. def_kind( id) , DefKind :: Const | DefKind :: AssocConst )
428+ && find_attr ! ( tcx. get_all_attrs( id) , AttributeKind :: TypeConst ( _) )
427429 }
428430
429431 // If the type is omitted on a [type_const] we can't run
Original file line number Diff line number Diff line change 33use rustc_abi:: Size ;
44use rustc_ast:: { self as ast} ;
55use rustc_hir:: attrs:: AttributeKind ;
6+ use rustc_hir:: def:: DefKind ;
67use rustc_hir:: def_id:: DefId ;
78use rustc_hir:: { LangItem , find_attr} ;
89use rustc_middle:: mir:: interpret:: { CTFE_ALLOC_SALT , LitToConstInput , Scalar } ;
@@ -51,7 +52,8 @@ pub(crate) fn as_constant_inner<'tcx>(
5152 let Expr { ty, temp_scope_id : _, span, ref kind } = * expr;
5253
5354 fn is_type_const < ' tcx > ( tcx : TyCtxt < ' tcx > , id : DefId ) -> bool {
54- find_attr ! ( tcx. get_all_attrs( id) , AttributeKind :: TypeConst ( _) )
55+ matches ! ( tcx. def_kind( id) , DefKind :: Const | DefKind :: AssocConst )
56+ && find_attr ! ( tcx. get_all_attrs( id) , AttributeKind :: TypeConst ( _) )
5557 }
5658
5759 match * kind {
You can’t perform that action at this time.
0 commit comments