@@ -336,7 +336,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
336336 self . check_generic_attr_unparsed ( hir_id, attr, target, Target :: Fn )
337337 }
338338 [ sym:: automatically_derived, ..] => {
339- self . check_generic_attr_unparsed ( hir_id, attr, target, Target :: Impl )
339+ self . check_generic_attr_unparsed ( hir_id, attr, target, Target :: Impl { of_trait : true } )
340340 }
341341 [ sym:: proc_macro, ..] => {
342342 self . check_proc_macro ( hir_id, target, ProcMacroKind :: FunctionLike )
@@ -470,7 +470,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
470470 attr : & Attribute ,
471471 item : Option < ItemLike < ' _ > > ,
472472 ) {
473- if !matches ! ( target, Target :: Impl )
473+ if !matches ! ( target, Target :: Impl { .. } )
474474 || matches ! (
475475 item,
476476 Some ( ItemLike :: Item ( hir:: Item { kind: hir:: ItemKind :: Impl ( _impl) , .. } ) )
@@ -574,7 +574,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
574574 Target :: Fn
575575 | Target :: Closure
576576 | Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent )
577- | Target :: Impl
577+ | Target :: Impl { .. }
578578 | Target :: Mod => return ,
579579
580580 // These are "functions", but they aren't allowed because they don't
@@ -965,9 +965,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
965965 let span = meta. span ( ) ;
966966 if let Some ( location) = match target {
967967 Target :: AssocTy => {
968- let parent_def_id = self . tcx . hir_get_parent_item ( hir_id ) . def_id ;
969- let containing_item = self . tcx . hir_expect_item ( parent_def_id ) ;
970- if Target :: from_item ( containing_item ) == Target :: Impl {
968+ if let DefKind :: Impl { .. } =
969+ self . tcx . def_kind ( self . tcx . local_parent ( hir_id . owner . def_id ) )
970+ {
971971 Some ( "type alias in implementation block" )
972972 } else {
973973 None
@@ -990,7 +990,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
990990 | Target :: Arm
991991 | Target :: ForeignMod
992992 | Target :: Closure
993- | Target :: Impl
993+ | Target :: Impl { .. }
994994 | Target :: WherePredicate => Some ( target. name ( ) ) ,
995995 Target :: ExternCrate
996996 | Target :: Use
@@ -1566,7 +1566,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
15661566 let article = match target {
15671567 Target :: ExternCrate
15681568 | Target :: Enum
1569- | Target :: Impl
1569+ | Target :: Impl { .. }
15701570 | Target :: Expression
15711571 | Target :: Arm
15721572 | Target :: AssocConst
0 commit comments