Skip to content

Commit 200e7a1

Browse files
committed
dont use has_attr as it doesnt work with new style attrs
1 parent 2f908c1 commit 200e7a1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use rustc_errors::ErrorGuaranteed;
99
use rustc_hir::LangItem;
1010
use rustc_hir::def::DefKind;
11+
use rustc_hir::attrs::AttributeKind;
12+
use rustc_hir::find_attr;
1113
use rustc_infer::infer::TyCtxtInferExt;
1214
use rustc_middle::mir::*;
1315
use rustc_middle::ty::{self, AdtDef, Ty};
@@ -369,7 +371,7 @@ where
369371
assert!(promoted.is_none() || Q::ALLOW_PROMOTED);
370372

371373
let is_type_const_item = matches!(cx.tcx.def_kind(def), DefKind::Const | DefKind::AssocConst)
372-
&& cx.tcx.has_attr(def, sym::type_const);
374+
&& find_attr!(cx.tcx.get_all_attrs(def), AttributeKind::TypeConst(_));
373375

374376
// Don't peak inside trait associated consatnts, also `#[type_const] const` items
375377
// don't have bodies so there's nothing to look at

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ pub use errors::NoVariantNamed;
9393
use rustc_abi::{CVariadicStatus, ExternAbi};
9494
use rustc_hir::def::DefKind;
9595
use rustc_hir::lints::DelayedLint;
96+
use rustc_hir::attrs::AttributeKind;
97+
use rustc_hir::find_attr;
9698
use rustc_hir::{self as hir};
9799
use rustc_middle::mir::interpret::GlobalId;
98100
use rustc_middle::query::Providers;
@@ -229,7 +231,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
229231
}
230232
DefKind::Const
231233
if !tcx.generics_of(item_def_id).own_requires_monomorphization()
232-
&& !tcx.has_attr(item_def_id, sym::type_const) =>
234+
&& !find_attr!(tcx.get_all_attrs(item_def_id), AttributeKind::TypeConst(_)) =>
233235
{
234236
// FIXME(generic_const_items): Passing empty instead of identity args is fishy but
235237
// seems to be fine for now. Revisit this!

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,12 +1605,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16051605
record!(self.tables.anon_const_kind[def_id] <- self.tcx.anon_const_kind(def_id));
16061606
}
16071607
if let DefKind::Const = def_kind
1608-
&& tcx.has_attr(def_id, sym::type_const)
1608+
&& find_attr!(tcx.get_all_attrs(def_id), AttributeKind::TypeConst(_))
16091609
{
16101610
record!(self.tables.const_of_item[def_id] <- self.tcx.const_of_item(def_id));
16111611
}
16121612
if let DefKind::AssocConst = def_kind
1613-
&& tcx.has_attr(def_id, sym::type_const)
1613+
&& find_attr!(tcx.get_all_attrs(def_id), AttributeKind::TypeConst(_))
16141614
{
16151615
let assoc_item = tcx.associated_item(def_id);
16161616
let should_encode = match assoc_item.container {

0 commit comments

Comments
 (0)