@@ -3,12 +3,12 @@ use rustc_attr::InstructionSetAttr;
33use rustc_data_structures:: fx:: FxHashMap ;
44use rustc_data_structures:: fx:: FxHashSet ;
55use rustc_errors:: Applicability ;
6- use rustc_hir as hir ;
6+ use rustc_hir:: def :: DefKind ;
77use rustc_hir:: def_id:: DefId ;
88use rustc_hir:: def_id:: LocalDefId ;
99use rustc_hir:: def_id:: LOCAL_CRATE ;
1010use rustc_middle:: ty:: query:: Providers ;
11- use rustc_middle:: ty:: TyCtxt ;
11+ use rustc_middle:: ty:: { DefIdTree , TyCtxt } ;
1212use rustc_session:: parse:: feature_err;
1313use rustc_session:: Session ;
1414use 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.
442442pub 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