@@ -161,6 +161,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
161
161
Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) ) => {
162
162
self . check_applied_to_fn_or_method ( hir_id, * attr_span, span, target)
163
163
}
164
+ & Attribute :: Parsed ( AttributeKind :: MayDangle ( attr_span) ) => {
165
+ self . check_may_dangle ( hir_id, attr_span)
166
+ }
164
167
Attribute :: Unparsed ( _) => {
165
168
match attr. path ( ) . as_slice ( ) {
166
169
[ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -234,7 +237,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
234
237
[ sym:: collapse_debuginfo, ..] => self . check_collapse_debuginfo ( attr, span, target) ,
235
238
[ sym:: must_not_suspend, ..] => self . check_must_not_suspend ( attr, span, target) ,
236
239
[ sym:: must_use, ..] => self . check_must_use ( hir_id, attr, target) ,
237
- [ sym:: may_dangle, ..] => self . check_may_dangle ( hir_id, attr) ,
238
240
[ sym:: rustc_pass_by_value, ..] => self . check_pass_by_value ( attr, span, target) ,
239
241
[ sym:: rustc_allow_incoherent_impl, ..] => {
240
242
self . check_allow_incoherent_impl ( attr, span, target)
@@ -1616,7 +1618,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1616
1618
}
1617
1619
1618
1620
/// 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 ) {
1620
1622
if let hir:: Node :: GenericParam ( param) = self . tcx . hir_node ( hir_id)
1621
1623
&& matches ! (
1622
1624
param. kind,
@@ -1633,7 +1635,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1633
1635
return ;
1634
1636
}
1635
1637
1636
- self . dcx ( ) . emit_err ( errors:: InvalidMayDangle { attr_span : attr . span ( ) } ) ;
1638
+ self . dcx ( ) . emit_err ( errors:: InvalidMayDangle { attr_span } ) ;
1637
1639
}
1638
1640
1639
1641
/// Checks if `#[cold]` is applied to a non-function.
0 commit comments