@@ -28,15 +28,15 @@ use std::num::NonZeroU32;
28
28
29
29
#[ derive( PartialEq ) ]
30
30
enum AnnotationKind {
31
- // Annotation is required if not inherited from unstable parents
31
+ // Annotation is required if not inherited from unstable parents.
32
32
Required ,
33
- // Annotation is useless, reject it
33
+ // Annotation is useless: reject it.
34
34
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.
36
36
Container ,
37
37
}
38
38
39
- // A private tree-walker for producing an Index .
39
+ // A private tree-walker for producing an index .
40
40
struct Annotator < ' a , ' tcx > {
41
41
tcx : TyCtxt < ' tcx > ,
42
42
index : & ' a mut Index < ' tcx > ,
@@ -65,7 +65,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
65
65
self . tcx . sess . span_err (
66
66
item_sp,
67
67
"`#[deprecated]` cannot be used in staged API; \
68
- use `#[rustc_deprecated]` instead",
68
+ use `#[rustc_deprecated]` instead",
69
69
) ;
70
70
}
71
71
let ( stab, const_stab) =
@@ -81,7 +81,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
81
81
&& stab. level . is_stable ( )
82
82
&& stab. rustc_depr . is_none ( ) )
83
83
{
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 " ) ;
85
85
}
86
86
87
87
debug ! ( "annotate: found {:?}" , stab) ;
@@ -102,7 +102,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
102
102
& attr:: Stable { since : stab_since } ,
103
103
) = ( & stab. rustc_depr , & stab. level )
104
104
{
105
- // Explicit version of iter::order::lt to handle parse errors properly
105
+ // Explicit version of ` iter::order::lt` to handle parse errors properly.
106
106
for ( dep_v, stab_v) in
107
107
dep_since. as_str ( ) . split ( '.' ) . zip ( stab_since. as_str ( ) . split ( '.' ) )
108
108
{
@@ -111,8 +111,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
111
111
Ordering :: Less => {
112
112
self . tcx . sess . span_err (
113
113
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" ,
116
115
) ;
117
116
break ;
118
117
}
@@ -124,8 +123,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
124
123
// and this makes us not do anything else interesting.
125
124
self . tcx . sess . span_err (
126
125
item_sp,
127
- "Invalid stability or deprecation \
128
- version found",
126
+ "item has an invalid stability or deprecation version" ,
129
127
) ;
130
128
break ;
131
129
}
@@ -140,6 +138,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
140
138
} else {
141
139
debug ! ( "annotate: not found, parent = {:?}" , self . parent_stab) ;
142
140
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.
143
144
if stab. level . is_unstable ( ) {
144
145
self . index . stab_map . insert ( hir_id, stab) ;
145
146
}
@@ -179,7 +180,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
179
180
180
181
if let Some ( depr) = attr:: find_deprecation ( & self . tcx . sess . parse_sess , attrs, item_sp) {
181
182
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" ) ;
183
186
}
184
187
185
188
// `Deprecation` is just two pointers, no need to intern it
0 commit comments