File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
compiler/rustc_const_eval/src/check_consts Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 77
88use rustc_errors:: ErrorGuaranteed ;
99use rustc_hir:: LangItem ;
10+ use rustc_hir:: def:: DefKind ;
1011use rustc_infer:: infer:: TyCtxtInferExt ;
1112use rustc_middle:: mir:: * ;
1213use rustc_middle:: ty:: { self , AdtDef , Ty } ;
@@ -367,12 +368,14 @@ where
367368 // check performed after the promotion. Verify that with an assertion.
368369 assert ! ( promoted. is_none( ) || Q :: ALLOW_PROMOTED ) ;
369370
370- // Const items don't themselves have bodies -- they will have either a path or an anon const instead.
371- // FIXME(mgca): is this really the right behavior? should we return the qualifs of the anon const body instead?
372- // (note also that original code ignored trait assoc items)
371+ let is_type_const_item = matches ! ( cx. tcx. def_kind( def) , DefKind :: Const | DefKind :: AssocConst )
372+ && cx. tcx . has_attr ( def, sym:: type_const) ;
373+
374+ // Don't peak inside trait associated consatnts, also `#[type_const] const` items
375+ // don't have bodies so there's nothing to look at
373376 if promoted. is_none ( )
374377 && cx. tcx . trait_of_assoc ( def) . is_none ( )
375- && !cx . tcx . has_attr ( def , sym :: type_const )
378+ && !is_type_const_item
376379 {
377380 let qualifs = cx. tcx . at ( constant. span ) . mir_const_qualif ( def) ;
378381
You can’t perform that action at this time.
0 commit comments