@@ -163,6 +163,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
163163                Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) )  => { 
164164                    self . check_applied_to_fn_or_method ( hir_id,  * attr_span,  span,  target) 
165165                } 
166+                 & Attribute :: Parsed ( AttributeKind :: MayDangle ( attr_span) )  => { 
167+                     self . check_may_dangle ( hir_id,  attr_span) 
168+                 } 
166169                Attribute :: Unparsed ( _)  => { 
167170                    match  attr. path ( ) . as_slice ( )  { 
168171                        [ sym:: diagnostic,  sym:: do_not_recommend,  ..]  => { 
@@ -236,7 +239,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
236239                        [ sym:: collapse_debuginfo,  ..]  => self . check_collapse_debuginfo ( attr,  span,  target) , 
237240                        [ sym:: must_not_suspend,  ..]  => self . check_must_not_suspend ( attr,  span,  target) , 
238241                        [ sym:: must_use,  ..]  => self . check_must_use ( hir_id,  attr,  target) , 
239-                         [ sym:: may_dangle,  ..]  => self . check_may_dangle ( hir_id,  attr) , 
240242                        [ sym:: rustc_pass_by_value,  ..]  => self . check_pass_by_value ( attr,  span,  target) , 
241243                        [ sym:: rustc_allow_incoherent_impl,  ..]  => { 
242244                            self . check_allow_incoherent_impl ( attr,  span,  target) 
@@ -1619,7 +1621,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
16191621    } 
16201622
16211623    /// Checks if `#[may_dangle]` is applied to a lifetime or type generic parameter in `Drop` impl. 
1622-      fn  check_may_dangle ( & self ,  hir_id :  HirId ,  attr :   & Attribute )  { 
1624+      fn  check_may_dangle ( & self ,  hir_id :  HirId ,  attr_span :   Span )  { 
16231625        if  let  hir:: Node :: GenericParam ( param)  = self . tcx . hir_node ( hir_id) 
16241626            && matches ! ( 
16251627                param. kind, 
@@ -1636,7 +1638,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
16361638            return ; 
16371639        } 
16381640
1639-         self . dcx ( ) . emit_err ( errors:: InvalidMayDangle  {  attr_span :  attr . span ( )  } ) ; 
1641+         self . dcx ( ) . emit_err ( errors:: InvalidMayDangle  {  attr_span } ) ; 
16401642    } 
16411643
16421644    /// Checks if `#[cold]` is applied to a non-function. 
0 commit comments