@@ -131,6 +131,14 @@ impl ConstStability {
131131 }
132132}
133133
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+
134142/// The available stability levels.
135143#[ derive( Encodable , Decodable , PartialEq , Copy , Clone , Debug , Eq , Hash ) ]
136144#[ derive( HashStable_Generic ) ]
@@ -214,22 +222,24 @@ pub fn find_stability(
214222 sess : & Session ,
215223 attrs : & [ Attribute ] ,
216224 item_sp : Span ,
217- ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > ) {
225+ ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > , Option < ( DefaultBodyStability , Span ) > )
226+ {
218227 find_stability_generic ( sess, attrs. iter ( ) , item_sp)
219228}
220229
221230fn find_stability_generic < ' a , I > (
222231 sess : & Session ,
223232 attrs_iter : I ,
224233 item_sp : Span ,
225- ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > )
234+ ) -> ( Option < ( Stability , Span ) > , Option < ( ConstStability , Span ) > , Option < ( DefaultBodyStability , Span ) > )
226235where
227236 I : Iterator < Item = & ' a Attribute > ,
228237{
229238 use StabilityLevel :: * ;
230239
231240 let mut stab: Option < ( Stability , Span ) > = None ;
232241 let mut const_stab: Option < ( ConstStability , Span ) > = None ;
242+ let mut body_stab: Option < ( DefaultBodyStability , Span ) > = None ;
233243 let mut promotable = false ;
234244 let mut allowed_through_unstable_modules = false ;
235245
@@ -243,6 +253,7 @@ where
243253 sym:: stable,
244254 sym:: rustc_promotable,
245255 sym:: rustc_allowed_through_unstable_modules,
256+ sym:: rustc_default_body_unstable,
246257 ]
247258 . iter ( )
248259 . any ( |& s| attr. has_name ( s) )
@@ -280,7 +291,7 @@ where
280291
281292 let meta_name = meta. name_or_empty ( ) ;
282293 match meta_name {
283- sym:: rustc_const_unstable | sym:: unstable => {
294+ sym:: rustc_const_unstable | sym:: rustc_default_body_unstable | sym :: unstable => {
284295 if meta_name == sym:: unstable && stab. is_some ( ) {
285296 handle_errors (
286297 & sess. parse_sess ,
@@ -295,6 +306,13 @@ where
295306 AttrError :: MultipleStabilityLevels ,
296307 ) ;
297308 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 ;
298316 }
299317
300318 let mut feature = None ;
@@ -405,11 +423,14 @@ where
405423 } ;
406424 if sym:: unstable == meta_name {
407425 stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
408- } else {
426+ } else if sym :: rustc_const_unstable == meta_name {
409427 const_stab = Some ( (
410428 ConstStability { level, feature, promotable : false } ,
411429 attr. span ,
412430 ) ) ;
431+ } else {
432+ body_stab =
433+ Some ( ( DefaultBodyStability { level, feature } , attr. span ) ) ;
413434 }
414435 }
415436 ( None , _, _) => {
@@ -542,7 +563,7 @@ where
542563 }
543564 }
544565
545- ( stab, const_stab)
566+ ( stab, const_stab, body_stab )
546567}
547568
548569pub fn find_crate_name ( sess : & Session , attrs : & [ Attribute ] ) -> Option < Symbol > {
0 commit comments