Skip to content

Commit 269ce59

Browse files
committed
fix qualifs
1 parent 7adc2bb commit 269ce59

File tree

1 file changed

+7
-4
lines changed
  • compiler/rustc_const_eval/src/check_consts

1 file changed

+7
-4
lines changed

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use rustc_errors::ErrorGuaranteed;
99
use rustc_hir::LangItem;
10+
use rustc_hir::def::DefKind;
1011
use rustc_infer::infer::TyCtxtInferExt;
1112
use rustc_middle::mir::*;
1213
use 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

0 commit comments

Comments
 (0)