@@ -70,7 +70,6 @@ pub enum OptimizeAttr {
7070#[ derive( HashStable_Generic ) ]
7171pub struct Stability {
7272 pub level : StabilityLevel ,
73- pub feature : Symbol ,
7473}
7574
7675impl Stability {
@@ -92,7 +91,6 @@ impl Stability {
9291#[ derive( HashStable_Generic ) ]
9392pub struct ConstStability {
9493 pub level : StabilityLevel ,
95- pub feature : Symbol ,
9694 /// whether the function has a `#[rustc_promotable]` attribute
9795 pub promotable : bool ,
9896}
@@ -112,7 +110,6 @@ impl ConstStability {
112110#[ derive( HashStable_Generic ) ]
113111pub struct DefaultBodyStability {
114112 pub level : StabilityLevel ,
115- pub feature : Symbol ,
116113}
117114
118115/// The available stability levels.
@@ -121,6 +118,7 @@ pub struct DefaultBodyStability {
121118pub enum StabilityLevel {
122119 /// `#[unstable]`
123120 Unstable {
121+ feature : Symbol ,
124122 /// Reason for the current stability level.
125123 reason : UnstableReason ,
126124 /// Relevant `rust-lang/rust` issue.
@@ -229,8 +227,8 @@ pub fn find_stability(
229227 break ;
230228 }
231229
232- if let Some ( ( feature , level) ) = parse_unstability ( sess, attr) {
233- stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
230+ if let Some ( level) = parse_unstability ( sess, attr) {
231+ stab = Some ( ( Stability { level } , attr. span ) ) ;
234232 }
235233 }
236234 sym:: stable => {
@@ -239,8 +237,8 @@ pub fn find_stability(
239237 . emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
240238 break ;
241239 }
242- if let Some ( ( feature , level) ) = parse_stability ( sess, attr) {
243- stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
240+ if let Some ( level) = parse_stability ( sess, attr) {
241+ stab = Some ( ( Stability { level } , attr. span ) ) ;
244242 }
245243 }
246244 _ => { }
@@ -286,9 +284,8 @@ pub fn find_const_stability(
286284 break ;
287285 }
288286
289- if let Some ( ( feature, level) ) = parse_unstability ( sess, attr) {
290- const_stab =
291- Some ( ( ConstStability { level, feature, promotable : false } , attr. span ) ) ;
287+ if let Some ( level) = parse_unstability ( sess, attr) {
288+ const_stab = Some ( ( ConstStability { level, promotable : false } , attr. span ) ) ;
292289 }
293290 }
294291 sym:: rustc_const_stable => {
@@ -297,9 +294,8 @@ pub fn find_const_stability(
297294 . emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
298295 break ;
299296 }
300- if let Some ( ( feature, level) ) = parse_stability ( sess, attr) {
301- const_stab =
302- Some ( ( ConstStability { level, feature, promotable : false } , attr. span ) ) ;
297+ if let Some ( level) = parse_stability ( sess, attr) {
298+ const_stab = Some ( ( ConstStability { level, promotable : false } , attr. span ) ) ;
303299 }
304300 }
305301 _ => { }
@@ -337,8 +333,8 @@ pub fn find_body_stability(
337333 break ;
338334 }
339335
340- if let Some ( ( feature , level) ) = parse_unstability ( sess, attr) {
341- body_stab = Some ( ( DefaultBodyStability { level, feature } , attr. span ) ) ;
336+ if let Some ( level) = parse_unstability ( sess, attr) {
337+ body_stab = Some ( ( DefaultBodyStability { level } , attr. span ) ) ;
342338 }
343339 }
344340 }
@@ -364,7 +360,7 @@ fn insert_or_error(sess: &Session, meta: &MetaItem, item: &mut Option<Symbol>) -
364360
365361/// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
366362/// its stability information.
367- fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
363+ fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < StabilityLevel > {
368364 let meta = attr. meta ( ) ?;
369365 let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
370366
@@ -418,17 +414,16 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
418414 } ;
419415
420416 match feature {
421- Ok ( feature) => {
422- let level = StabilityLevel :: Stable { since, allowed_through_unstable_modules : false } ;
423- Some ( ( feature, level) )
417+ Ok ( _feature) => {
418+ Some ( StabilityLevel :: Stable { since, allowed_through_unstable_modules : false } )
424419 }
425420 Err ( ErrorGuaranteed { .. } ) => None ,
426421 }
427422}
428423
429424/// Read the content of a `unstable`/`rustc_const_unstable`/`rustc_default_body_unstable`
430425/// attribute, and return the feature name and its stability information.
431- fn parse_unstability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
426+ fn parse_unstability ( sess : & Session , attr : & Attribute ) -> Option < StabilityLevel > {
432427 let meta = attr. meta ( ) ?;
433428 let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
434429
@@ -508,12 +503,13 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
508503 match ( feature, issue) {
509504 ( Ok ( feature) , Ok ( _) ) => {
510505 let level = StabilityLevel :: Unstable {
506+ feature,
511507 reason : UnstableReason :: from_opt_reason ( reason) ,
512508 issue : issue_num,
513509 is_soft,
514510 implied_by,
515511 } ;
516- Some ( ( feature , level) )
512+ Some ( level)
517513 }
518514 ( Err ( ErrorGuaranteed { .. } ) , _) | ( _, Err ( ErrorGuaranteed { .. } ) ) => None ,
519515 }
0 commit comments