@@ -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,9 @@ pub fn find_const_stability(
286
284
break ;
287
285
}
288
286
289
- if let Some ( ( feature , level) ) = parse_unstability ( sess, attr) {
287
+ if let Some ( level) = parse_unstability ( sess, attr) {
290
288
const_stab =
291
- Some ( ( ConstStability { level, feature , promotable : false } , attr. span ) ) ;
289
+ Some ( ( ConstStability { level, promotable : false } , attr. span ) ) ;
292
290
}
293
291
}
294
292
sym:: rustc_const_stable => {
@@ -297,9 +295,9 @@ pub fn find_const_stability(
297
295
. emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
298
296
break ;
299
297
}
300
- if let Some ( ( feature , level) ) = parse_stability ( sess, attr) {
298
+ if let Some ( level) = parse_stability ( sess, attr) {
301
299
const_stab =
302
- Some ( ( ConstStability { level, feature , promotable : false } , attr. span ) ) ;
300
+ Some ( ( ConstStability { level, promotable : false } , attr. span ) ) ;
303
301
}
304
302
}
305
303
_ => { }
@@ -337,8 +335,8 @@ pub fn find_body_stability(
337
335
break ;
338
336
}
339
337
340
- if let Some ( ( feature , level) ) = parse_unstability ( sess, attr) {
341
- body_stab = Some ( ( DefaultBodyStability { level, feature } , attr. span ) ) ;
338
+ if let Some ( level) = parse_unstability ( sess, attr) {
339
+ body_stab = Some ( ( DefaultBodyStability { level } , attr. span ) ) ;
342
340
}
343
341
}
344
342
}
@@ -364,7 +362,7 @@ fn insert_or_error(sess: &Session, meta: &MetaItem, item: &mut Option<Symbol>) -
364
362
365
363
/// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
366
364
/// its stability information.
367
- fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
365
+ fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < StabilityLevel > {
368
366
let meta = attr. meta ( ) ?;
369
367
let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
370
368
@@ -418,17 +416,16 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
418
416
} ;
419
417
420
418
match feature {
421
- Ok ( feature) => {
422
- let level = StabilityLevel :: Stable { since, allowed_through_unstable_modules : false } ;
423
- Some ( ( feature, level) )
419
+ Ok ( _feature) => {
420
+ Some ( StabilityLevel :: Stable { since, allowed_through_unstable_modules : false } )
424
421
}
425
422
Err ( ErrorGuaranteed { .. } ) => None ,
426
423
}
427
424
}
428
425
429
426
/// Read the content of a `unstable`/`rustc_const_unstable`/`rustc_default_body_unstable`
430
427
/// attribute, and return the feature name and its stability information.
431
- fn parse_unstability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
428
+ fn parse_unstability ( sess : & Session , attr : & Attribute ) -> Option < StabilityLevel > {
432
429
let meta = attr. meta ( ) ?;
433
430
let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
434
431
@@ -508,12 +505,13 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
508
505
match ( feature, issue) {
509
506
( Ok ( feature) , Ok ( _) ) => {
510
507
let level = StabilityLevel :: Unstable {
508
+ feature,
511
509
reason : UnstableReason :: from_opt_reason ( reason) ,
512
510
issue : issue_num,
513
511
is_soft,
514
512
implied_by,
515
513
} ;
516
- Some ( ( feature , level) )
514
+ Some ( level)
517
515
}
518
516
( Err ( ErrorGuaranteed { .. } ) , _) | ( _, Err ( ErrorGuaranteed { .. } ) ) => None ,
519
517
}
0 commit comments