Skip to content

Commit 68fb752

Browse files
committed
Do not fetch HIR to check target features.
1 parent e49e7f6 commit 68fb752

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use rustc_attr::InstructionSetAttr;
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_data_structures::fx::FxHashSet;
55
use rustc_errors::Applicability;
6-
use rustc_hir as hir;
6+
use rustc_hir::def::DefKind;
77
use rustc_hir::def_id::DefId;
88
use rustc_hir::def_id::LocalDefId;
99
use rustc_hir::def_id::LOCAL_CRATE;
1010
use rustc_middle::ty::query::Providers;
11-
use rustc_middle::ty::TyCtxt;
11+
use rustc_middle::ty::{DefIdTree, TyCtxt};
1212
use rustc_session::parse::feature_err;
1313
use rustc_session::Session;
1414
use rustc_span::symbol::sym;
@@ -440,12 +440,9 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxHashSet<Symbol> {
440440
/// Checks the function annotated with `#[target_feature]` is not a safe
441441
/// trait method implementation, reporting an error if it is.
442442
pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
443-
let hir_id = tcx.hir().local_def_id_to_hir_id(id);
444-
let node = tcx.hir().get(hir_id);
445-
if let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) = node {
446-
let parent_id = tcx.hir().get_parent_item(hir_id);
447-
let parent_item = tcx.hir().expect_item(parent_id.def_id);
448-
if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = parent_item.kind {
443+
if let DefKind::AssocFn = tcx.def_kind(id) {
444+
let parent_id = tcx.local_parent(id);
445+
if let DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {
449446
tcx.sess
450447
.struct_span_err(
451448
attr_span,

0 commit comments

Comments
 (0)