@@ -95,15 +95,13 @@ pub enum OptimizeAttr {
9595#[ derive( HashStable_Generic ) ]
9696pub struct Stability {
9797 pub level : StabilityLevel ,
98- pub feature : Symbol ,
9998}
10099
101100/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
102101#[ derive( Encodable , Decodable , Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
103102#[ derive( HashStable_Generic ) ]
104103pub struct ConstStability {
105104 pub level : StabilityLevel ,
106- pub feature : Symbol ,
107105 /// whether the function has a `#[rustc_promotable]` attribute
108106 pub promotable : bool ,
109107}
@@ -113,8 +111,18 @@ pub struct ConstStability {
113111#[ derive( HashStable_Generic ) ]
114112pub enum StabilityLevel {
115113 // Reason for the current stability level and the relevant rust-lang issue
116- Unstable { reason : Option < Symbol > , issue : Option < NonZeroU32 > , is_soft : bool } ,
117- Stable { since : Symbol } ,
114+ Unstable {
115+ reason : Option < Symbol > ,
116+ feature : Symbol ,
117+ issue : Option < NonZeroU32 > ,
118+ is_soft : bool ,
119+ } ,
120+ Stable {
121+ since : Symbol ,
122+ // feature flag, should not be set when the feature name remains in use
123+ // for unstable items (i.e. when partially stabilizing a feature)
124+ feature : Option < Symbol > ,
125+ } ,
118126}
119127
120128impl StabilityLevel {
@@ -309,14 +317,12 @@ where
309317 ) ;
310318 continue ;
311319 }
312- let level = Unstable { reason, issue : issue_num, is_soft } ;
320+ let level = Unstable { reason, feature , issue : issue_num, is_soft } ;
313321 if sym:: unstable == meta_name {
314- stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
322+ stab = Some ( ( Stability { level } , attr. span ) ) ;
315323 } else {
316- const_stab = Some ( (
317- ConstStability { level, feature, promotable : false } ,
318- attr. span ,
319- ) ) ;
324+ const_stab =
325+ Some ( ( ConstStability { level, promotable : false } , attr. span ) ) ;
320326 }
321327 }
322328 ( None , _, _) => {
@@ -385,22 +391,16 @@ where
385391 }
386392 }
387393
388- match ( feature , since) {
389- ( Some ( feature ) , Some ( since) ) => {
390- let level = Stable { since } ;
394+ match since {
395+ Some ( since) => {
396+ let level = Stable { since, feature } ;
391397 if sym:: stable == meta_name {
392- stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
398+ stab = Some ( ( Stability { level } , attr. span ) ) ;
393399 } else {
394- const_stab = Some ( (
395- ConstStability { level, feature, promotable : false } ,
396- attr. span ,
397- ) ) ;
400+ const_stab =
401+ Some ( ( ConstStability { level, promotable : false } , attr. span ) ) ;
398402 }
399403 }
400- ( None , _) => {
401- handle_errors ( & sess. parse_sess , attr. span , AttrError :: MissingFeature ) ;
402- continue ;
403- }
404404 _ => {
405405 handle_errors ( & sess. parse_sess , attr. span , AttrError :: MissingSince ) ;
406406 continue ;
0 commit comments