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 {
281281 Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
282282 Allow ( Target :: ForeignFn ) ,
283283 Allow ( Target :: Closure ) ,
284+ Warn ( Target :: MacroDef ) ,
284285 ] ) ;
285286 const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: TrackCaller ;
286287}
@@ -303,6 +304,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for NoMangleParser {
303304 Warn ( Target :: Impl { of_trait : true } ) ,
304305 Warn ( Target :: Trait ) ,
305306 Warn ( Target :: Mod ) ,
307+ Warn ( Target :: Const ) ,
308+ Warn ( Target :: Statement ) ,
309+ Warn ( Target :: ForeignFn ) ,
310+ Warn ( Target :: ForeignStatic ) ,
306311 ] ) ;
307312 const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: NoMangle ;
308313}
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
5959 Warn ( Target :: Expression ) ,
6060 Warn ( Target :: Impl { of_trait : false } ) ,
6161 Warn ( Target :: Impl { of_trait : true } ) ,
62+ Warn ( Target :: Crate )
6263 ] ) ;
6364 const TEMPLATE : AttributeTemplate = template ! (
6465 Word ,
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ const MACRO_USE_ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
4646 Warn ( Target :: TyAlias ) ,
4747 Warn ( Target :: Impl { of_trait : false } ) ,
4848 Warn ( Target :: Impl { of_trait : true } ) ,
49+ Warn ( Target :: Use ) ,
4950] ) ;
5051
5152impl < 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 {
2424 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
2525 Allow ( Target :: ForeignFn ) ,
2626 Allow ( Target :: Trait ) ,
27+ Warn ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
2728 Warn ( Target :: Crate ) ,
2829 Warn ( Target :: Mod ) ,
2930 Warn ( Target :: TyAlias ) ,
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ pub enum Target {
6363 // Used for attributes
6464 MacroCall ,
6565 Crate ,
66+ Delegation ,
6667}
6768
6869impl Display for Target {
@@ -106,7 +107,8 @@ impl Target {
106107 | Target :: ExprField
107108 | Target :: MacroCall
108109 | Target :: Crate
109- | Target :: WherePredicate => false ,
110+ | Target :: WherePredicate
111+ | Target :: Delegation => false ,
110112 }
111113 }
112114
@@ -233,12 +235,13 @@ impl Target {
233235 MethodKind :: Inherent
234236 } ) ,
235237 AssocItemKind :: Type ( _) => Target :: AssocTy ,
238+ AssocItemKind :: Delegation ( _) => Target :: Delegation ,
236239 _ => unreachable ! ( ) ,
237240 }
238241 }
239242
240243 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 }
242245 }
243246
244247 pub fn name ( self ) -> & ' static str {
@@ -287,6 +290,7 @@ impl Target {
287290 Target :: WherePredicate => "where predicate" ,
288291 Target :: MacroCall => "macro call" ,
289292 Target :: Crate => "crate" ,
293+ Target :: Delegation => "delegation" ,
290294 }
291295 }
292296}
Original file line number Diff line number Diff line change @@ -1057,7 +1057,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
10571057 | Target :: PatField
10581058 | Target :: ExprField
10591059 | Target :: Crate
1060- | Target :: MacroCall => None ,
1060+ | Target :: MacroCall
1061+ | Target :: Delegation => None ,
10611062 } {
10621063 tcx. dcx ( ) . emit_err ( errors:: DocAliasBadLocation { span, attr_str, location } ) ;
10631064 return ;
@@ -2329,7 +2330,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23292330 | Target :: ExprField
23302331 | Target :: WherePredicate
23312332 | Target :: Crate
2332- | Target :: MacroCall => {
2333+ | Target :: MacroCall
2334+ | Target :: Delegation => {
23332335 self . tcx . dcx ( ) . emit_err ( errors:: RustcUnstableFeatureBound { attr_span, span } ) ;
23342336 }
23352337 }
You can’t perform that action at this time.
0 commit comments