@@ -28,15 +28,15 @@ use std::num::NonZeroU32;
2828
2929#[ derive( PartialEq ) ]
3030enum AnnotationKind {
31- // Annotation is required if not inherited from unstable parents
31+ // Annotation is required if not inherited from unstable parents.
3232 Required ,
33- // Annotation is useless, reject it
33+ // Annotation is useless: reject it.
3434 Prohibited ,
35- // Annotation itself is useless, but it can be propagated to children
35+ // Annotation itself is useless, but it can be propagated to children.
3636 Container ,
3737}
3838
39- // A private tree-walker for producing an Index .
39+ // A private tree-walker for producing an index .
4040struct Annotator < ' a , ' tcx > {
4141 tcx : TyCtxt < ' tcx > ,
4242 index : & ' a mut Index < ' tcx > ,
@@ -65,7 +65,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
6565 self . tcx . sess . span_err (
6666 item_sp,
6767 "`#[deprecated]` cannot be used in staged API; \
68- use `#[rustc_deprecated]` instead",
68+ use `#[rustc_deprecated]` instead",
6969 ) ;
7070 }
7171 let ( stab, const_stab) =
@@ -81,7 +81,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
8181 && stab. level . is_stable ( )
8282 && stab. rustc_depr . is_none ( ) )
8383 {
84- self . tcx . sess . span_err ( item_sp, "This stability annotation is useless " ) ;
84+ self . tcx . sess . span_err ( item_sp, "item does not require a stability annotation " ) ;
8585 }
8686
8787 debug ! ( "annotate: found {:?}" , stab) ;
@@ -102,7 +102,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
102102 & attr:: Stable { since : stab_since } ,
103103 ) = ( & stab. rustc_depr , & stab. level )
104104 {
105- // Explicit version of iter::order::lt to handle parse errors properly
105+ // Explicit version of ` iter::order::lt` to handle parse errors properly.
106106 for ( dep_v, stab_v) in
107107 dep_since. as_str ( ) . split ( '.' ) . zip ( stab_since. as_str ( ) . split ( '.' ) )
108108 {
@@ -111,8 +111,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
111111 Ordering :: Less => {
112112 self . tcx . sess . span_err (
113113 item_sp,
114- "An API can't be stabilized \
115- after it is deprecated",
114+ "an API cannot be stabilized after it has been deprecated" ,
116115 ) ;
117116 break ;
118117 }
@@ -124,8 +123,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
124123 // and this makes us not do anything else interesting.
125124 self . tcx . sess . span_err (
126125 item_sp,
127- "Invalid stability or deprecation \
128- version found",
126+ "item has an invalid stability or deprecation version" ,
129127 ) ;
130128 break ;
131129 }
@@ -140,6 +138,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
140138 } else {
141139 debug ! ( "annotate: not found, parent = {:?}" , self . parent_stab) ;
142140 if let Some ( stab) = self . parent_stab {
141+ // Instability (but not stability) is inherited from the parent.
142+ // If something is unstable, everything inside it should also be
143+ // considered unstable.
143144 if stab. level . is_unstable ( ) {
144145 self . index . stab_map . insert ( hir_id, stab) ;
145146 }
@@ -179,7 +180,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
179180
180181 if let Some ( depr) = attr:: find_deprecation ( & self . tcx . sess . parse_sess , attrs, item_sp) {
181182 if kind == AnnotationKind :: Prohibited {
182- self . tcx . sess . span_err ( item_sp, "This deprecation annotation is useless" ) ;
183+ self . tcx
184+ . sess
185+ . span_err ( item_sp, "item does not require a deprecation annotation" ) ;
183186 }
184187
185188 // `Deprecation` is just two pointers, no need to intern it
0 commit comments