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