File tree Expand file tree Collapse file tree 6 files changed +18
-4
lines changed
rustc_attr_parsing/src/attributes Expand file tree Collapse file tree 6 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for TrackCallerParser {
281
281
Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
282
282
Allow ( Target :: ForeignFn ) ,
283
283
Allow ( Target :: Closure ) ,
284
+ Warn ( Target :: MacroDef ) ,
284
285
] ) ;
285
286
const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: TrackCaller ;
286
287
}
@@ -303,6 +304,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for NoMangleParser {
303
304
Warn ( Target :: Impl { of_trait : true } ) ,
304
305
Warn ( Target :: Trait ) ,
305
306
Warn ( Target :: Mod ) ,
307
+ Warn ( Target :: Const ) ,
308
+ Warn ( Target :: Statement ) ,
309
+ Warn ( Target :: ForeignFn ) ,
310
+ Warn ( Target :: ForeignStatic ) ,
306
311
] ) ;
307
312
const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: NoMangle ;
308
313
}
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
59
59
Warn ( Target :: Expression ) ,
60
60
Warn ( Target :: Impl { of_trait : false } ) ,
61
61
Warn ( Target :: Impl { of_trait : true } ) ,
62
+ Warn ( Target :: Crate )
62
63
] ) ;
63
64
const TEMPLATE : AttributeTemplate = template ! (
64
65
Word ,
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ const MACRO_USE_ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
46
46
Warn ( Target :: TyAlias ) ,
47
47
Warn ( Target :: Impl { of_trait : false } ) ,
48
48
Warn ( Target :: Impl { of_trait : true } ) ,
49
+ Warn ( Target :: Use ) ,
49
50
] ) ;
50
51
51
52
impl < S : Stage > AttributeParser < S > for MacroUseParser {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ impl<S: Stage> SingleAttributeParser<S> for MustUseParser {
24
24
Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
25
25
Allow ( Target :: ForeignFn ) ,
26
26
Allow ( Target :: Trait ) ,
27
+ Warn ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
27
28
Warn ( Target :: Crate ) ,
28
29
Warn ( Target :: Mod ) ,
29
30
Warn ( Target :: TyAlias ) ,
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ pub enum Target {
63
63
// Used for attributes
64
64
MacroCall ,
65
65
Crate ,
66
+ Delegation ,
66
67
}
67
68
68
69
impl Display for Target {
@@ -106,7 +107,8 @@ impl Target {
106
107
| Target :: ExprField
107
108
| Target :: MacroCall
108
109
| Target :: Crate
109
- | Target :: WherePredicate => false ,
110
+ | Target :: WherePredicate
111
+ | Target :: Delegation => false ,
110
112
}
111
113
}
112
114
@@ -233,12 +235,13 @@ impl Target {
233
235
MethodKind :: Inherent
234
236
} ) ,
235
237
AssocItemKind :: Type ( _) => Target :: AssocTy ,
238
+ AssocItemKind :: Delegation ( _) => Target :: Delegation ,
236
239
_ => unreachable ! ( ) ,
237
240
}
238
241
}
239
242
240
243
pub fn from_expr ( expr : & ast:: Expr ) -> Self {
241
- if let ast:: ExprKind :: Closure ( ..) = expr. kind { Self :: Closure } else { Self :: Expression }
244
+ if let ast:: ExprKind :: Closure ( ..) | ast :: ExprKind :: Gen ( .. ) = expr. kind { Self :: Closure } else { Self :: Expression }
242
245
}
243
246
244
247
pub fn name ( self ) -> & ' static str {
@@ -287,6 +290,7 @@ impl Target {
287
290
Target :: WherePredicate => "where predicate" ,
288
291
Target :: MacroCall => "macro call" ,
289
292
Target :: Crate => "crate" ,
293
+ Target :: Delegation => "delegation" ,
290
294
}
291
295
}
292
296
}
Original file line number Diff line number Diff line change @@ -1057,7 +1057,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1057
1057
| Target :: PatField
1058
1058
| Target :: ExprField
1059
1059
| Target :: Crate
1060
- | Target :: MacroCall => None ,
1060
+ | Target :: MacroCall
1061
+ | Target :: Delegation => None ,
1061
1062
} {
1062
1063
tcx. dcx ( ) . emit_err ( errors:: DocAliasBadLocation { span, attr_str, location } ) ;
1063
1064
return ;
@@ -2329,7 +2330,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
2329
2330
| Target :: ExprField
2330
2331
| Target :: WherePredicate
2331
2332
| Target :: Crate
2332
- | Target :: MacroCall => {
2333
+ | Target :: MacroCall
2334
+ | Target :: Delegation => {
2333
2335
self . tcx . dcx ( ) . emit_err ( errors:: RustcUnstableFeatureBound { attr_span, span } ) ;
2334
2336
}
2335
2337
}
You can’t perform that action at this time.
0 commit comments