@@ -226,8 +226,8 @@ impl UnstableReason {
226
226
}
227
227
}
228
228
229
- /// Collects stability info from all stability attributes in `attrs`.
230
- /// Returns `None` if no stability attributes are found.
229
+ /// Collects stability info from `stable`/`unstable`/`rustc_allowed_through_unstable_modules`
230
+ /// attributes in `attrs`. Returns `None` if no stability attributes are found.
231
231
pub fn find_stability (
232
232
sess : & Session ,
233
233
attrs : & [ Attribute ] ,
@@ -280,8 +280,8 @@ pub fn find_stability(
280
280
stab
281
281
}
282
282
283
- /// Collects stability info from all stability attributes in `attrs`.
284
- /// Returns `None` if no stability attributes are found.
283
+ /// Collects stability info from `rustc_const_stable`/`rustc_const_unstable`/`rustc_promotable`
284
+ /// attributes in `attrs`. Returns `None` if no stability attributes are found.
285
285
pub fn find_const_stability (
286
286
sess : & Session ,
287
287
attrs : & [ Attribute ] ,
@@ -329,7 +329,7 @@ pub fn find_const_stability(
329
329
const_stab
330
330
}
331
331
332
- /// Collects stability info from all stability attributes in `attrs`.
332
+ /// Collects stability info from `rustc_default_body_unstable` attributes in `attrs`.
333
333
/// Returns `None` if no stability attributes are found.
334
334
pub fn find_body_stability (
335
335
sess : & Session ,
@@ -353,10 +353,12 @@ pub fn find_body_stability(
353
353
body_stab
354
354
}
355
355
356
+ /// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
357
+ /// its stability information.
356
358
fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
357
359
let meta = attr. meta ( ) ?;
358
360
let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
359
- let insert = |meta : & MetaItem , item : & mut Option < Symbol > | {
361
+ let insert_or_error = |meta : & MetaItem , item : & mut Option < Symbol > | {
360
362
if item. is_some ( ) {
361
363
handle_errors (
362
364
& sess. parse_sess ,
@@ -388,12 +390,12 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
388
390
389
391
match mi. name_or_empty ( ) {
390
392
sym:: feature => {
391
- if !insert ( mi, & mut feature) {
393
+ if !insert_or_error ( mi, & mut feature) {
392
394
return None ;
393
395
}
394
396
}
395
397
sym:: since => {
396
- if !insert ( mi, & mut since) {
398
+ if !insert_or_error ( mi, & mut since) {
397
399
return None ;
398
400
}
399
401
}
@@ -431,10 +433,12 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
431
433
}
432
434
}
433
435
436
+ /// Read the content of a `unstable`/`rustc_const_unstable`/`rustc_default_body_unstable`
437
+ /// attribute, and return the feature name and its stability information.
434
438
fn parse_unstability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
435
439
let meta = attr. meta ( ) ?;
436
440
let MetaItem { kind : MetaItemKind :: List ( ref metas) , .. } = meta else { return None } ;
437
- let insert = |meta : & MetaItem , item : & mut Option < Symbol > | {
441
+ let insert_or_error = |meta : & MetaItem , item : & mut Option < Symbol > | {
438
442
if item. is_some ( ) {
439
443
handle_errors (
440
444
& sess. parse_sess ,
@@ -470,21 +474,21 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
470
474
471
475
match mi. name_or_empty ( ) {
472
476
sym:: feature => {
473
- if !insert ( mi, & mut feature) {
477
+ if !insert_or_error ( mi, & mut feature) {
474
478
return None ;
475
479
}
476
480
}
477
481
sym:: reason => {
478
- if !insert ( mi, & mut reason) {
482
+ if !insert_or_error ( mi, & mut reason) {
479
483
return None ;
480
484
}
481
485
}
482
486
sym:: issue => {
483
- if !insert ( mi, & mut issue) {
487
+ if !insert_or_error ( mi, & mut issue) {
484
488
return None ;
485
489
}
486
490
487
- // These unwraps are safe because `insert ` ensures the meta item
491
+ // These unwraps are safe because `insert_or_error ` ensures the meta item
488
492
// is a name/value pair string literal.
489
493
issue_num = match issue. unwrap ( ) . as_str ( ) {
490
494
"none" => None ,
@@ -512,7 +516,7 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
512
516
is_soft = true ;
513
517
}
514
518
sym:: implied_by => {
515
- if !insert ( mi, & mut implied_by) {
519
+ if !insert_or_error ( mi, & mut implied_by) {
516
520
return None ;
517
521
}
518
522
}
0 commit comments