@@ -131,6 +131,14 @@ impl ConstStability {
131
131
}
132
132
}
133
133
134
+ /// Represents the `#[rustc_default_body_unstable]` attribute.
135
+ #[ derive( Encodable , Decodable , Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
136
+ #[ derive( HashStable_Generic ) ]
137
+ pub struct DefaultBodyStability {
138
+ pub level : StabilityLevel ,
139
+ pub feature : Symbol ,
140
+ }
141
+
134
142
/// The available stability levels.
135
143
#[ derive( Encodable , Decodable , PartialEq , Copy , Clone , Debug , Eq , Hash ) ]
136
144
#[ derive( HashStable_Generic ) ]
@@ -214,22 +222,24 @@ pub fn find_stability(
214
222
sess : & Session ,
215
223
attrs : & [ Attribute ] ,
216
224
item_sp : Span ,
217
- ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > ) {
225
+ ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > , Option < ( DefaultBodyStability , Span ) > )
226
+ {
218
227
find_stability_generic ( sess, attrs. iter ( ) , item_sp)
219
228
}
220
229
221
230
fn find_stability_generic < ' a , I > (
222
231
sess : & Session ,
223
232
attrs_iter : I ,
224
233
item_sp : Span ,
225
- ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > )
234
+ ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > , Option < ( DefaultBodyStability , Span ) > )
226
235
where
227
236
I : Iterator < Item = & ' a Attribute > ,
228
237
{
229
238
use StabilityLevel :: * ;
230
239
231
240
let mut stab: Option < ( Stability , Span ) > = None ;
232
241
let mut const_stab: Option < ( ConstStability , Span ) > = None ;
242
+ let mut body_stab: Option < ( DefaultBodyStability , Span ) > = None ;
233
243
let mut promotable = false ;
234
244
let mut allowed_through_unstable_modules = false ;
235
245
@@ -243,6 +253,7 @@ where
243
253
sym:: stable,
244
254
sym:: rustc_promotable,
245
255
sym:: rustc_allowed_through_unstable_modules,
256
+ sym:: rustc_default_body_unstable,
246
257
]
247
258
. iter ( )
248
259
. any ( |& s| attr. has_name ( s) )
@@ -280,7 +291,7 @@ where
280
291
281
292
let meta_name = meta. name_or_empty ( ) ;
282
293
match meta_name {
283
- sym:: rustc_const_unstable | sym:: unstable => {
294
+ sym:: rustc_const_unstable | sym:: rustc_default_body_unstable | sym :: unstable => {
284
295
if meta_name == sym:: unstable && stab. is_some ( ) {
285
296
handle_errors (
286
297
& sess. parse_sess ,
@@ -295,6 +306,13 @@ where
295
306
AttrError :: MultipleStabilityLevels ,
296
307
) ;
297
308
break ;
309
+ } else if meta_name == sym:: rustc_default_body_unstable && body_stab. is_some ( ) {
310
+ handle_errors (
311
+ & sess. parse_sess ,
312
+ attr. span ,
313
+ AttrError :: MultipleStabilityLevels ,
314
+ ) ;
315
+ break ;
298
316
}
299
317
300
318
let mut feature = None ;
@@ -405,11 +423,14 @@ where
405
423
} ;
406
424
if sym:: unstable == meta_name {
407
425
stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
408
- } else {
426
+ } else if sym :: rustc_const_unstable == meta_name {
409
427
const_stab = Some ( (
410
428
ConstStability { level, feature, promotable : false } ,
411
429
attr. span ,
412
430
) ) ;
431
+ } else {
432
+ body_stab =
433
+ Some ( ( DefaultBodyStability { level, feature } , attr. span ) ) ;
413
434
}
414
435
}
415
436
( None , _, _) => {
@@ -542,7 +563,7 @@ where
542
563
}
543
564
}
544
565
545
- ( stab, const_stab)
566
+ ( stab, const_stab, body_stab )
546
567
}
547
568
548
569
pub fn find_crate_name ( sess : & Session , attrs : & [ Attribute ] ) -> Option < Symbol > {
0 commit comments