@@ -226,8 +226,8 @@ impl UnstableReason {
226226 }
227227}
228228
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.
231231pub fn find_stability (
232232 sess : & Session ,
233233 attrs : & [ Attribute ] ,
@@ -280,8 +280,8 @@ pub fn find_stability(
280280 stab
281281}
282282
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.
285285pub fn find_const_stability (
286286 sess : & Session ,
287287 attrs : & [ Attribute ] ,
@@ -329,7 +329,7 @@ pub fn find_const_stability(
329329 const_stab
330330}
331331
332- /// Collects stability info from all stability attributes in `attrs`.
332+ /// Collects stability info from `rustc_default_body_unstable` attributes in `attrs`.
333333/// Returns `None` if no stability attributes are found.
334334pub fn find_body_stability (
335335 sess : & Session ,
@@ -353,10 +353,12 @@ pub fn find_body_stability(
353353 body_stab
354354}
355355
356+ /// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
357+ /// its stability information.
356358fn parse_stability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
357359 let meta = attr. meta ( ) ?;
358360 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 > | {
360362 if item. is_some ( ) {
361363 handle_errors (
362364 & sess. parse_sess ,
@@ -388,12 +390,12 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
388390
389391 match mi. name_or_empty ( ) {
390392 sym:: feature => {
391- if !insert ( mi, & mut feature) {
393+ if !insert_or_error ( mi, & mut feature) {
392394 return None ;
393395 }
394396 }
395397 sym:: since => {
396- if !insert ( mi, & mut since) {
398+ if !insert_or_error ( mi, & mut since) {
397399 return None ;
398400 }
399401 }
@@ -431,10 +433,12 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
431433 }
432434}
433435
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.
434438fn parse_unstability ( sess : & Session , attr : & Attribute ) -> Option < ( Symbol , StabilityLevel ) > {
435439 let meta = attr. meta ( ) ?;
436440 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 > | {
438442 if item. is_some ( ) {
439443 handle_errors (
440444 & sess. parse_sess ,
@@ -470,21 +474,21 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
470474
471475 match mi. name_or_empty ( ) {
472476 sym:: feature => {
473- if !insert ( mi, & mut feature) {
477+ if !insert_or_error ( mi, & mut feature) {
474478 return None ;
475479 }
476480 }
477481 sym:: reason => {
478- if !insert ( mi, & mut reason) {
482+ if !insert_or_error ( mi, & mut reason) {
479483 return None ;
480484 }
481485 }
482486 sym:: issue => {
483- if !insert ( mi, & mut issue) {
487+ if !insert_or_error ( mi, & mut issue) {
484488 return None ;
485489 }
486490
487- // These unwraps are safe because `insert ` ensures the meta item
491+ // These unwraps are safe because `insert_or_error ` ensures the meta item
488492 // is a name/value pair string literal.
489493 issue_num = match issue. unwrap ( ) . as_str ( ) {
490494 "none" => None ,
@@ -512,7 +516,7 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
512516 is_soft = true ;
513517 }
514518 sym:: implied_by => {
515- if !insert ( mi, & mut implied_by) {
519+ if !insert_or_error ( mi, & mut implied_by) {
516520 return None ;
517521 }
518522 }
0 commit comments