@@ -3,12 +3,12 @@ use rustc_attr::InstructionSetAttr;
3
3
use rustc_data_structures:: fx:: FxHashMap ;
4
4
use rustc_data_structures:: fx:: FxHashSet ;
5
5
use rustc_errors:: Applicability ;
6
- use rustc_hir as hir ;
6
+ use rustc_hir:: def :: DefKind ;
7
7
use rustc_hir:: def_id:: DefId ;
8
8
use rustc_hir:: def_id:: LocalDefId ;
9
9
use rustc_hir:: def_id:: LOCAL_CRATE ;
10
10
use rustc_middle:: ty:: query:: Providers ;
11
- use rustc_middle:: ty:: TyCtxt ;
11
+ use rustc_middle:: ty:: { DefIdTree , TyCtxt } ;
12
12
use rustc_session:: parse:: feature_err;
13
13
use rustc_session:: Session ;
14
14
use rustc_span:: symbol:: sym;
@@ -440,12 +440,9 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxHashSet<Symbol> {
440
440
/// Checks the function annotated with `#[target_feature]` is not a safe
441
441
/// trait method implementation, reporting an error if it is.
442
442
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) {
449
446
tcx. sess
450
447
. struct_span_err (
451
448
attr_span,
0 commit comments