@@ -161,6 +161,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
161161 Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) ) => {
162162 self . check_applied_to_fn_or_method ( hir_id, * attr_span, span, target)
163163 }
164+ & Attribute :: Parsed ( AttributeKind :: MayDangle ( attr_span) ) => {
165+ self . check_may_dangle ( hir_id, attr_span)
166+ }
164167 Attribute :: Unparsed ( _) => {
165168 match attr. path ( ) . as_slice ( ) {
166169 [ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -234,7 +237,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
234237 [ sym:: collapse_debuginfo, ..] => self . check_collapse_debuginfo ( attr, span, target) ,
235238 [ sym:: must_not_suspend, ..] => self . check_must_not_suspend ( attr, span, target) ,
236239 [ sym:: must_use, ..] => self . check_must_use ( hir_id, attr, target) ,
237- [ sym:: may_dangle, ..] => self . check_may_dangle ( hir_id, attr) ,
238240 [ sym:: rustc_pass_by_value, ..] => self . check_pass_by_value ( attr, span, target) ,
239241 [ sym:: rustc_allow_incoherent_impl, ..] => {
240242 self . check_allow_incoherent_impl ( attr, span, target)
@@ -1616,7 +1618,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
16161618 }
16171619
16181620 /// Checks if `#[may_dangle]` is applied to a lifetime or type generic parameter in `Drop` impl.
1619- fn check_may_dangle ( & self , hir_id : HirId , attr : & Attribute ) {
1621+ fn check_may_dangle ( & self , hir_id : HirId , attr_span : Span ) {
16201622 if let hir:: Node :: GenericParam ( param) = self . tcx . hir_node ( hir_id)
16211623 && matches ! (
16221624 param. kind,
@@ -1633,7 +1635,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
16331635 return ;
16341636 }
16351637
1636- self . dcx ( ) . emit_err ( errors:: InvalidMayDangle { attr_span : attr . span ( ) } ) ;
1638+ self . dcx ( ) . emit_err ( errors:: InvalidMayDangle { attr_span } ) ;
16371639 }
16381640
16391641 /// Checks if `#[cold]` is applied to a non-function.
0 commit comments