@@ -70,7 +70,6 @@ pub enum OptimizeAttr {
70
70
#[ derive( HashStable_Generic ) ]
71
71
pub struct Stability {
72
72
pub level : StabilityLevel ,
73
- pub feature : Symbol ,
74
73
}
75
74
76
75
impl Stability {
@@ -92,7 +91,6 @@ impl Stability {
92
91
#[ derive( HashStable_Generic ) ]
93
92
pub struct ConstStability {
94
93
pub level : StabilityLevel ,
95
- pub feature : Symbol ,
96
94
/// whether the function has a `#[rustc_promotable]` attribute
97
95
pub promotable : bool ,
98
96
}
@@ -112,7 +110,6 @@ impl ConstStability {
112
110
#[ derive( HashStable_Generic ) ]
113
111
pub struct DefaultBodyStability {
114
112
pub level : StabilityLevel ,
115
- pub feature : Symbol ,
116
113
}
117
114
118
115
/// The available stability levels.
@@ -121,6 +118,7 @@ pub struct DefaultBodyStability {
121
118
pub enum StabilityLevel {
122
119
/// `#[unstable]`
123
120
Unstable {
121
+ feature : Symbol ,
124
122
/// Reason for the current stability level.
125
123
reason : UnstableReason ,
126
124
/// Relevant `rust-lang/rust` issue.
@@ -229,8 +227,8 @@ pub fn find_stability(
229
227
break ;
230
228
}
231
229
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 ) ) ;
234
232
}
235
233
}
236
234
sym:: stable => {
@@ -239,8 +237,8 @@ pub fn find_stability(
239
237
. emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
240
238
break ;
241
239
}
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 ) ) ;
244
242
}
245
243
}
246
244
_ => { }
@@ -286,9 +284,8 @@ pub fn find_const_stability(
286
284
break ;
287
285
}
288
286
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 ) ) ;
292
289
}
293
290
}
294
291
sym:: rustc_const_stable => {
@@ -297,9 +294,8 @@ pub fn find_const_stability(
297
294
. emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
298
295
break ;
299
296
}
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 ) ) ;
303
299
}
304
300
}
305
301
_ => { }
@@ -337,8 +333,8 @@ pub fn find_body_stability(
337
333
break ;
338
334
}
339
335
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 ) ) ;
342
338
}
343
339
}
344
340
}
@@ -364,7 +360,7 @@ fn insert_or_error(sess: &Session, meta: &MetaItem, item: &mut Option<Symbol>) -
364
360
365
361
/// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
366
362
/// its stability information.
367
- fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
363
+ fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < StabilityLevel > {
368
364
let meta = attr. meta ( ) ?;
369
365
let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
370
366
@@ -418,17 +414,16 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
418
414
} ;
419
415
420
416
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 } )
424
419
}
425
420
Err ( ErrorGuaranteed { .. } ) => None ,
426
421
}
427
422
}
428
423
429
424
/// Read the content of a `unstable`/`rustc_const_unstable`/`rustc_default_body_unstable`
430
425
/// 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 > {
432
427
let meta = attr. meta ( ) ?;
433
428
let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
434
429
@@ -508,12 +503,13 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
508
503
match ( feature, issue) {
509
504
( Ok ( feature) , Ok ( _) ) => {
510
505
let level = StabilityLevel :: Unstable {
506
+ feature,
511
507
reason : UnstableReason :: from_opt_reason ( reason) ,
512
508
issue : issue_num,
513
509
is_soft,
514
510
implied_by,
515
511
} ;
516
- Some ( ( feature , level) )
512
+ Some ( level)
517
513
}
518
514
( Err ( ErrorGuaranteed { .. } ) , _) | ( _, Err ( ErrorGuaranteed { .. } ) ) => None ,
519
515
}
0 commit comments