Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
20cb59b
bootstrap: respect modern jobserver
haampie Feb 3, 2026
5c64b89
DOC: do not link to "nightly" in Iterator::by_ref() docstring
mgeier Feb 18, 2026
a9e6a89
bootstrap: add snapshot tests for {`install`, `install src`}
jieyouxu Feb 19, 2026
ede7279
Clarify some variable names in the query proc-macro
Zalathar Feb 18, 2026
27c0476
Fix typo in doc for core::mem::type_info::Struct
apasel422 Feb 19, 2026
aebafba
resolve: do not suggest `_` for unresolved imports
ozankenangungor Feb 19, 2026
4ab6d1f
std::ops::ControlFlow - use "a" before `Result`
DanielEScherzer Feb 19, 2026
be83f55
std::ops::ControlFlow - use normal comment for internal methods
DanielEScherzer Feb 20, 2026
5978115
Deny final not followed by item
mu001999 Feb 20, 2026
c3fe049
change find_attr macro to search tcx.get_all_attrs automatically
jdonszelmann Feb 5, 2026
63edc91
change all uses
jdonszelmann Feb 5, 2026
07f46ce
Convenience matcher in find_attrs for crate attrs
jdonszelmann Feb 5, 2026
9a94439
change all uses
jdonszelmann Feb 5, 2026
7477a5b
update docs
jdonszelmann Feb 5, 2026
54d673d
deprecate functions
jdonszelmann Feb 5, 2026
04f762d
allow deprecated for some valid uses
jdonszelmann Feb 5, 2026
a2367ec
star-import AttributeKind
jdonszelmann Feb 13, 2026
2bed584
add lint for using AttributeKind in find_attr
jdonszelmann Feb 13, 2026
decec17
remove AttributeKind everywhere
jdonszelmann Feb 13, 2026
be4f92f
emit unreachable pattern lint
jdonszelmann Feb 13, 2026
df23df5
tidy
jdonszelmann Feb 17, 2026
8e7bc3c
fix src/tools
jdonszelmann Feb 18, 2026
19e0c62
Rename `DepGraphQuery` to `RetainedDepGraph`
Zalathar Feb 19, 2026
c0fe694
Rollup merge of #152759 - jdonszelmann:simpler-get-attrs, r=jonathanb…
JonathanBrouwer Feb 20, 2026
12c80d2
Rollup merge of #152057 - haampie:hs/fix/bootstrap-respect-jobserver-…
JonathanBrouwer Feb 20, 2026
cfc274c
Rollup merge of #152818 - mgeier:doc-by_ref-link, r=scottmcm
JonathanBrouwer Feb 20, 2026
29871ea
Rollup merge of #152840 - jieyouxu:bootstrap-install-src-no-docs, r=c…
JonathanBrouwer Feb 20, 2026
eb5f275
Rollup merge of #152844 - Zalathar:retain-dep-graph, r=JonathanBrouwer
JonathanBrouwer Feb 20, 2026
412b0c3
Rollup merge of #152846 - Zalathar:query-proc-macro, r=nnethercote
JonathanBrouwer Feb 20, 2026
e21941a
Rollup merge of #152858 - apasel422:patch-1, r=oli-obk
JonathanBrouwer Feb 20, 2026
c013bcc
Rollup merge of #152861 - ozankenangungor:fix-underscore-import-sugge…
JonathanBrouwer Feb 20, 2026
be34085
Rollup merge of #152873 - DanielEScherzer:patch-2, r=jhpratt
JonathanBrouwer Feb 20, 2026
a2abf2a
Rollup merge of #152877 - DanielEScherzer:patch-3, r=scottmcm
JonathanBrouwer Feb 20, 2026
a196a00
Rollup merge of #152883 - mu001999-contrib:fix/final-bad-use, r=Kivooeo
JonathanBrouwer Feb 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
.flatten()
})
.flatten(),
None => self
.tcx
.get_all_attrs(*def_id)
.iter()
.find(|base_attr| (addition_info.equals)(base_attr)),
None =>
{
#[allow(deprecated)]
self.tcx
.get_all_attrs(*def_id)
.iter()
.find(|base_attr| (addition_info.equals)(base_attr))
}
};

if let Some(original_attr) = original_attr {
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use rustc_ast_pretty::pprust::expr_to_string;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::msg;
use rustc_hir as hir;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::definitions::DefPathData;
use rustc_hir::{HirId, Target, find_attr};
Expand Down Expand Up @@ -805,7 +804,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
) {
if self.tcx.features().async_fn_track_caller()
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
&& find_attr!(*attrs, AttributeKind::TrackCaller(_))
&& find_attr!(*attrs, TrackCaller(_))
{
let unstable_span = self.mark_span_with_reason(
DesugaringKind::Async,
Expand Down Expand Up @@ -1072,8 +1071,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (binder_clause, generic_params) = self.lower_closure_binder(binder);

let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {

let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));
let mut coroutine_kind = find_attr!(attrs, Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));

// FIXME(contracts): Support contracts on closures?
let body_id = this.lower_fn_body(decl, None, |this| {
Expand Down
13 changes: 4 additions & 9 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
vis_span,
span: self.lower_span(i.span),
has_delayed_lints: !self.delayed_lints.is_empty(),
eii: find_attr!(attrs, AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)),
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
};
self.arena.alloc(item)
}
Expand Down Expand Up @@ -707,10 +707,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
vis_span,
span: this.lower_span(use_tree.span),
has_delayed_lints: !this.delayed_lints.is_empty(),
eii: find_attr!(
attrs,
AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)
),
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
};
hir::OwnerNode::Item(this.arena.alloc(item))
});
Expand Down Expand Up @@ -1415,9 +1412,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// create a fake body so that the entire rest of the compiler doesn't have to deal with
// this as a special case.
return self.lower_fn_body(decl, contract, |this| {
if find_attr!(attrs, AttributeKind::RustcIntrinsic)
|| this.tcx.is_sdylib_interface_build()
{
if find_attr!(attrs, RustcIntrinsic) || this.tcx.is_sdylib_interface_build() {
let span = this.lower_span(span);
let empty_block = hir::Block {
hir_id: this.next_id(),
Expand Down Expand Up @@ -1695,7 +1690,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let safety = self.lower_safety(h.safety, default_safety);

// Treat safe `#[target_feature]` functions as unsafe, but also remember that we did so.
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { was_forced: false, .. })
let safety = if find_attr!(attrs, TargetFeature { was_forced: false, .. })
&& safety.is_safe()
&& !self.tcx.sess.target.is_like_wasm
{
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::spawn;
use rustc_data_structures::tagged_ptr::TaggedRef;
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
Expand Down Expand Up @@ -255,10 +254,10 @@ impl ResolverAstLowering {
return None;
}

// we can use parsed attrs here since for other crates they're already available
find_attr!(
// we can use parsed attrs here since for other crates they're already available
tcx.get_all_attrs(def_id),
AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
tcx, def_id,
RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
)
.map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
}
Expand Down
37 changes: 18 additions & 19 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ impl<S: Stage> CombineAttributeParser<S> for RustcMirParser {
.collect()
}
}

pub(crate) struct RustcNonConstTraitMethodParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcNonConstTraitMethodParser {
Expand Down Expand Up @@ -1252,24 +1251,6 @@ impl<S: Stage> SingleAttributeParser<S> for RustcDefPath {
}
}

pub(crate) struct RustcIntrinsicParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
const PATH: &[Symbol] = &[sym::rustc_intrinsic];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
}

pub(crate) struct RustcIntrinsicConstStableIndirectParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
}

pub(crate) struct RustcStrictCoherenceParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcStrictCoherenceParser {
Expand Down Expand Up @@ -1343,3 +1324,21 @@ impl<S: Stage> SingleAttributeParser<S> for RustcDocPrimitiveParser {
Some(AttributeKind::RustcDocPrimitive(cx.attr_span, value_str))
}
}

pub(crate) struct RustcIntrinsicParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
const PATH: &[Symbol] = &[sym::rustc_intrinsic];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
}

pub(crate) struct RustcIntrinsicConstStableIndirectParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
}
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::str::FromStr;

use polonius_engine::{Algorithm, AllFacts, Output};
use rustc_data_structures::frozen::Frozen;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::find_attr;
use rustc_index::IndexSlice;
use rustc_middle::mir::pretty::PrettyPrintMirOptions;
Expand Down Expand Up @@ -296,7 +295,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
) {
let tcx = infcx.tcx;
let base_def_id = tcx.typeck_root_def_id(body.source.def_id());
if !find_attr!(tcx.get_all_attrs(base_def_id), AttributeKind::RustcRegions) {
if !find_attr!(tcx, base_def_id, RustcRegions) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
{
to_add.push(create_alloc_family_attr(cx.llcx));
if let Some(instance) = instance
&& let Some(name) = find_attr!(tcx.get_all_attrs(instance.def_id()), rustc_hir::attrs::AttributeKind::RustcAllocatorZeroedVariant {name} => name)
&& let Some(name) =
find_attr!(tcx, instance.def_id(), RustcAllocatorZeroedVariant {name} => name)
{
to_add.push(llvm::CreateAttrStringValue(
cx.llcx,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::fmt;

use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::{DiagArgValue, IntoDiagArg};
use rustc_hir::attrs::{AttributeKind, CguFields, CguKind};
use rustc_hir::attrs::{CguFields, CguKind};
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::{self as hir, find_attr};
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
Expand Down Expand Up @@ -89,7 +89,7 @@ struct AssertModuleSource<'tcx> {
impl<'tcx> AssertModuleSource<'tcx> {
fn check_attrs(&mut self, attrs: &[hir::Attribute]) {
for &(span, cgu_fields) in find_attr!(attrs,
AttributeKind::RustcCguTestAttr(e) => e)
RustcCguTestAttr(e) => e)
.into_iter()
.flatten()
{
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use rustc_errors::{
Level, MultiSpan, Style, Suggestions, catch_fatal_errors,
};
use rustc_fs_util::link_or_copy;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::find_attr;
use rustc_incremental::{
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
Expand Down Expand Up @@ -454,8 +453,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
) -> OngoingCodegen<B> {
let (coordinator_send, coordinator_receive) = channel();

let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
let no_builtins = find_attr!(crate_attrs, AttributeKind::NoBuiltins);
let no_builtins = find_attr!(tcx, crate, NoBuiltins);

let crate_info = CrateInfo::new(tcx, target_cpu);

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
use rustc_data_structures::unord::UnordMap;
use rustc_hir::attrs::{AttributeKind, DebuggerVisualizerType, OptimizeAttr};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE};
use rustc_hir::attrs::{DebuggerVisualizerType, OptimizeAttr};
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_hir::lang_items::LangItem;
use rustc_hir::{ItemId, Target, find_attr};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
Expand Down Expand Up @@ -894,7 +894,7 @@ impl CrateInfo {
let linked_symbols =
crate_types.iter().map(|&c| (c, crate::back::linker::linked_symbols(tcx, c))).collect();
let local_crate_name = tcx.crate_name(LOCAL_CRATE);
let windows_subsystem = find_attr!(tcx.get_all_attrs(CRATE_DEF_ID), AttributeKind::WindowsSubsystem(kind, _) => *kind);
let windows_subsystem = find_attr!(tcx, crate, WindowsSubsystem(kind, _) => *kind);

// This list is used when generating the command line to pass through to
// system linker. The linker expects undefined symbols on the left of the
Expand Down
18 changes: 8 additions & 10 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ fn process_builtin_attrs(
for i in impls {
let foreign_item = match i.resolution {
EiiImplResolution::Macro(def_id) => {
let Some(extern_item) = find_attr!(
tcx.get_all_attrs(def_id),
AttributeKind::EiiDeclaration(target) => target.foreign_item
let Some(extern_item) = find_attr!(tcx, def_id, EiiDeclaration(target) => target.foreign_item
) else {
tcx.dcx().span_delayed_bug(
i.span,
Expand Down Expand Up @@ -352,8 +350,7 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code

// When `no_builtins` is applied at the crate level, we should add the
// `no-builtins` attribute to each function to ensure it takes effect in LTO.
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
let no_builtins = find_attr!(crate_attrs, AttributeKind::NoBuiltins);
let no_builtins = find_attr!(tcx, crate, NoBuiltins);
if no_builtins {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_BUILTINS;
}
Expand Down Expand Up @@ -483,9 +480,8 @@ fn check_result(
.map(|features| (features.name.as_str(), true))
.collect(),
) {
let span =
find_attr!(tcx.get_all_attrs(did), AttributeKind::TargetFeature{attr_span: span, ..} => *span)
.unwrap_or_else(|| tcx.def_span(did));
let span = find_attr!(tcx, did, TargetFeature{attr_span: span, ..} => *span)
.unwrap_or_else(|| tcx.def_span(did));

tcx.dcx()
.create_err(errors::TargetFeatureDisableOrEnable {
Expand All @@ -504,7 +500,7 @@ fn handle_lang_items(
attrs: &[Attribute],
codegen_fn_attrs: &mut CodegenFnAttrs,
) {
let lang_item = find_attr!(attrs, AttributeKind::Lang(lang, _) => lang);
let lang_item = find_attr!(attrs, Lang(lang, _) => lang);

// Weak lang items have the same semantics as "std internal" symbols in the
// sense that they're preserved through all our LTO passes and only
Expand Down Expand Up @@ -583,7 +579,8 @@ fn sanitizer_settings_for(tcx: TyCtxt<'_>, did: LocalDefId) -> SanitizerFnAttrs
};

// Check for a sanitize annotation directly on this def.
if let Some((on_set, off_set, rtsan)) = find_attr!(tcx.get_all_attrs(did), AttributeKind::Sanitize {on_set, off_set, rtsan, ..} => (on_set, off_set, rtsan))
if let Some((on_set, off_set, rtsan)) =
find_attr!(tcx, did, Sanitize {on_set, off_set, rtsan, ..} => (on_set, off_set, rtsan))
{
// the on set is the set of sanitizers explicitly enabled.
// we mask those out since we want the set of disabled sanitizers here
Expand Down Expand Up @@ -624,6 +621,7 @@ fn inherited_align<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Align> {
/// panic, unless we introduced a bug when parsing the autodiff macro.
//FIXME(jdonszelmann): put in the main loop. No need to have two..... :/ Let's do that when we make autodiff parsed.
pub fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> {
#[allow(deprecated)]
let attrs = tcx.get_attrs(id, sym::rustc_autodiff);

let attrs = attrs.filter(|attr| attr.has_name(sym::rustc_autodiff)).collect::<Vec<_>>();
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::ops::Deref;

use rustc_data_structures::assert_matches;
use rustc_errors::{Diag, ErrorGuaranteed};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, LangItem, find_attr};
Expand Down Expand Up @@ -216,7 +215,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
return;
}

if !find_attr!(tcx.get_all_attrs(def_id), AttributeKind::RustcDoNotConstCheck) {
if !find_attr!(tcx, def_id, RustcDoNotConstCheck) {
self.visit_body(body);
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_const_eval/src/check_consts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! it finds operations that are invalid in a certain context.

use rustc_errors::DiagCtxtHandle;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, find_attr};
use rustc_middle::ty::{self, PolyFnSig, TyCtxt};
Expand Down Expand Up @@ -81,9 +80,7 @@ pub fn rustc_allow_const_fn_unstable(
def_id: LocalDefId,
feature_gate: Symbol,
) -> bool {
let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(def_id));

find_attr!(attrs, AttributeKind::RustcAllowConstFnUnstable(syms, _) if syms.contains(&feature_gate))
find_attr!(tcx, def_id, RustcAllowConstFnUnstable(syms, _) if syms.contains(&feature_gate))
}

/// Returns `true` if the given `def_id` (trait or function) is "safe to expose on stable".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_hir::attrs::AttributeKind;
use rustc_hir::find_attr;
use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{self, BasicBlock, Location};
Expand Down Expand Up @@ -36,7 +35,7 @@ pub fn check_live_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
return;
}

if find_attr!(tcx.get_all_attrs(body.source.def_id()), AttributeKind::RustcDoNotConstCheck) {
if find_attr!(tcx, body.source.def_id(), RustcDoNotConstCheck) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_const_eval/src/const_eval/fn_queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{
Constness, ExprKind, ForeignItemKind, ImplItem, ImplItemImplKind, ImplItemKind, Item, ItemKind,
Expand Down Expand Up @@ -38,7 +37,7 @@ fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Constness {
}
}
Node::TraitItem(ti @ TraitItem { kind: TraitItemKind::Fn(..), .. }) => {
if find_attr!(tcx.hir_attrs(ti.hir_id()), AttributeKind::RustcNonConstTraitMethod) {
if find_attr!(tcx.hir_attrs(ti.hir_id()), RustcNonConstTraitMethod) {
Constness::NotConst
} else {
tcx.trait_def(tcx.local_parent(def_id)).constness
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rustc_abi::{Align, Size};
use rustc_ast::Mutability;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, IndexEntry};
use rustc_errors::msg;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem, find_attr};
use rustc_middle::mir::AssertMessage;
Expand Down Expand Up @@ -441,9 +440,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
// sensitive check here. But we can at least rule out functions that are not const at
// all. That said, we have to allow calling functions inside a `const trait`. These
// *are* const-checked!
if !ecx.tcx.is_const_fn(def)
|| find_attr!(ecx.tcx.get_all_attrs(def), AttributeKind::RustcDoNotConstCheck)
{
if !ecx.tcx.is_const_fn(def) || find_attr!(ecx.tcx, def, RustcDoNotConstCheck) {
// We certainly do *not* want to actually call the fn
// though, so be sure we return here.
throw_unsup_format!("calling non-const function `{}`", instance)
Expand Down
Loading
Loading