@@ -338,7 +338,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
338338 self . check_generic_attr_unparsed ( hir_id, attr, target, Target :: Fn )
339339 }
340340 [ sym:: automatically_derived, ..] => {
341- self . check_generic_attr_unparsed ( hir_id, attr, target, Target :: Impl )
341+ self . check_generic_attr_unparsed ( hir_id, attr, target, Target :: Impl { of_trait : true } )
342342 }
343343 [ sym:: proc_macro, ..] => {
344344 self . check_proc_macro ( hir_id, target, ProcMacroKind :: FunctionLike )
@@ -479,7 +479,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
479479 attr : & Attribute ,
480480 item : Option < ItemLike < ' _ > > ,
481481 ) {
482- if !matches ! ( target, Target :: Impl )
482+ if !matches ! ( target, Target :: Impl { .. } )
483483 || matches ! (
484484 item,
485485 Some ( ItemLike :: Item ( hir:: Item { kind: hir:: ItemKind :: Impl ( _impl) , .. } ) )
@@ -583,7 +583,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
583583 Target :: Fn
584584 | Target :: Closure
585585 | Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent )
586- | Target :: Impl
586+ | Target :: Impl { .. }
587587 | Target :: Mod => return ,
588588
589589 // These are "functions", but they aren't allowed because they don't
@@ -974,9 +974,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
974974 let span = meta. span ( ) ;
975975 if let Some ( location) = match target {
976976 Target :: AssocTy => {
977- let parent_def_id = self . tcx . hir_get_parent_item ( hir_id ) . def_id ;
978- let containing_item = self . tcx . hir_expect_item ( parent_def_id ) ;
979- if Target :: from_item ( containing_item ) == Target :: Impl {
977+ if let DefKind :: Impl { .. } =
978+ self . tcx . def_kind ( self . tcx . local_parent ( hir_id . owner . def_id ) )
979+ {
980980 Some ( "type alias in implementation block" )
981981 } else {
982982 None
@@ -999,7 +999,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
999999 | Target :: Arm
10001000 | Target :: ForeignMod
10011001 | Target :: Closure
1002- | Target :: Impl
1002+ | Target :: Impl { .. }
10031003 | Target :: WherePredicate => Some ( target. name ( ) ) ,
10041004 Target :: ExternCrate
10051005 | Target :: Use
@@ -1575,7 +1575,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
15751575 let article = match target {
15761576 Target :: ExternCrate
15771577 | Target :: Enum
1578- | Target :: Impl
1578+ | Target :: Impl { .. }
15791579 | Target :: Expression
15801580 | Target :: Arm
15811581 | Target :: AssocConst
0 commit comments