Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a0d66b5

Browse files
committedMar 5, 2021
Auto merge of #71481 - estebank:inherit-stability, r=nikomatsakis
Inherit `#[stable(..)]` annotations in enum variants and fields from its item Lint changes for #65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
2 parents 45b3c28 + 49310ce commit a0d66b5

17 files changed

+290
-188
lines changed
 

‎compiler/rustc_attr/src/builtin.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,24 @@ pub fn find_stability(
176176
sess: &Session,
177177
attrs: &[Attribute],
178178
item_sp: Span,
179-
) -> (Option<Stability>, Option<ConstStability>) {
179+
) -> (Option<(Stability, Span)>, Option<(ConstStability, Span)>) {
180180
find_stability_generic(sess, attrs.iter(), item_sp)
181181
}
182182

183183
fn find_stability_generic<'a, I>(
184184
sess: &Session,
185185
attrs_iter: I,
186186
item_sp: Span,
187-
) -> (Option<Stability>, Option<ConstStability>)
187+
) -> (Option<(Stability, Span)>, Option<(ConstStability, Span)>)
188188
where
189189
I: Iterator<Item = &'a Attribute>,
190190
{
191191
use StabilityLevel::*;
192192

193-
let mut stab: Option<Stability> = None;
194-
let mut const_stab: Option<ConstStability> = None;
193+
let mut stab: Option<(Stability, Span)> = None;
194+
let mut const_stab: Option<(ConstStability, Span)> = None;
195195
let mut promotable = false;
196+
196197
let diagnostic = &sess.parse_sess.span_diagnostic;
197198

198199
'outer: for attr in attrs_iter {
@@ -356,10 +357,12 @@ where
356357
}
357358
let level = Unstable { reason, issue: issue_num, is_soft };
358359
if sym::unstable == meta_name {
359-
stab = Some(Stability { level, feature });
360+
stab = Some((Stability { level, feature }, attr.span));
360361
} else {
361-
const_stab =
362-
Some(ConstStability { level, feature, promotable: false });
362+
const_stab = Some((
363+
ConstStability { level, feature, promotable: false },
364+
attr.span,
365+
));
363366
}
364367
}
365368
(None, _, _) => {
@@ -432,10 +435,12 @@ where
432435
(Some(feature), Some(since)) => {
433436
let level = Stable { since };
434437
if sym::stable == meta_name {
435-
stab = Some(Stability { level, feature });
438+
stab = Some((Stability { level, feature }, attr.span));
436439
} else {
437-
const_stab =
438-
Some(ConstStability { level, feature, promotable: false });
440+
const_stab = Some((
441+
ConstStability { level, feature, promotable: false },
442+
attr.span,
443+
));
439444
}
440445
}
441446
(None, _) => {
@@ -455,7 +460,7 @@ where
455460

456461
// Merge the const-unstable info into the stability info
457462
if promotable {
458-
if let Some(ref mut stab) = const_stab {
463+
if let Some((ref mut stab, _)) = const_stab {
459464
stab.promotable = promotable;
460465
} else {
461466
struct_span_err!(

‎compiler/rustc_expand/src/base.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,10 +774,16 @@ impl SyntaxExtension {
774774
.find_by_name(attrs, sym::rustc_builtin_macro)
775775
.map(|a| a.value_str().unwrap_or(name));
776776
let (stability, const_stability) = attr::find_stability(&sess, attrs, span);
777-
if const_stability.is_some() {
777+
if let Some((_, sp)) = const_stability {
778778
sess.parse_sess
779779
.span_diagnostic
780-
.span_err(span, "macros cannot have const stability attributes");
780+
.struct_span_err(sp, "macros cannot have const stability attributes")
781+
.span_label(sp, "invalid const stability attribute")
782+
.span_label(
783+
sess.source_map().guess_head_span(span),
784+
"const stability attribute affects this macro",
785+
)
786+
.emit();
781787
}
782788

783789
SyntaxExtension {
@@ -786,7 +792,7 @@ impl SyntaxExtension {
786792
allow_internal_unstable,
787793
allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe),
788794
local_inner_macros,
789-
stability,
795+
stability: stability.map(|(s, _)| s),
790796
deprecation: attr::find_deprecation(&sess, attrs).map(|(d, _)| d),
791797
helper_attrs,
792798
edition,

‎compiler/rustc_passes/src/lib_features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl LibFeatureCollector<'tcx> {
109109
}
110110

111111
fn span_feature_error(&self, span: Span, msg: &str) {
112-
struct_span_err!(self.tcx.sess, span, E0711, "{}", &msg,).emit();
112+
struct_span_err!(self.tcx.sess, span, E0711, "{}", &msg).emit();
113113
}
114114
}
115115

‎compiler/rustc_passes/src/stability.rs

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ impl InheritConstStability {
7070
}
7171
}
7272

73+
enum InheritStability {
74+
Yes,
75+
No,
76+
}
77+
78+
impl InheritStability {
79+
fn yes(&self) -> bool {
80+
matches!(self, InheritStability::Yes)
81+
}
82+
}
83+
7384
// A private tree-walker for producing an Index.
7485
struct Annotator<'a, 'tcx> {
7586
tcx: TyCtxt<'tcx>,
@@ -91,6 +102,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
91102
kind: AnnotationKind,
92103
inherit_deprecation: InheritDeprecation,
93104
inherit_const_stability: InheritConstStability,
105+
inherit_from_parent: InheritStability,
94106
visit_children: F,
95107
) where
96108
F: FnOnce(&mut Self),
@@ -131,12 +143,13 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
131143
}
132144

133145
if self.tcx.features().staged_api {
134-
if let Some(..) = attrs.iter().find(|a| self.tcx.sess.check_name(a, sym::deprecated)) {
135-
self.tcx.sess.span_err(
136-
item_sp,
137-
"`#[deprecated]` cannot be used in staged API; \
138-
use `#[rustc_deprecated]` instead",
139-
);
146+
if let Some(a) = attrs.iter().find(|a| self.tcx.sess.check_name(a, sym::deprecated)) {
147+
self.tcx
148+
.sess
149+
.struct_span_err(a.span, "`#[deprecated]` cannot be used in staged API")
150+
.span_label(a.span, "use `#[rustc_deprecated]` instead")
151+
.span_label(item_sp, "")
152+
.emit();
140153
}
141154
} else {
142155
self.recurse_with_stability_attrs(
@@ -150,7 +163,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
150163

151164
let (stab, const_stab) = attr::find_stability(&self.tcx.sess, attrs, item_sp);
152165

153-
let const_stab = const_stab.map(|const_stab| {
166+
let const_stab = const_stab.map(|(const_stab, _)| {
154167
let const_stab = self.tcx.intern_const_stability(const_stab);
155168
self.index.const_stab_map.insert(hir_id, const_stab);
156169
const_stab
@@ -180,12 +193,15 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
180193
}
181194
}
182195

183-
let stab = stab.map(|stab| {
196+
let stab = stab.map(|(stab, span)| {
184197
// Error if prohibited, or can't inherit anything from a container.
185198
if kind == AnnotationKind::Prohibited
186199
|| (kind == AnnotationKind::Container && stab.level.is_stable() && is_deprecated)
187200
{
188-
self.tcx.sess.span_err(item_sp, "This stability annotation is useless");
201+
self.tcx.sess.struct_span_err(span,"this stability annotation is useless")
202+
.span_label(span, "useless stability annotation")
203+
.span_label(item_sp, "the stability attribute annotates this item")
204+
.emit();
189205
}
190206

191207
debug!("annotate: found {:?}", stab);
@@ -202,26 +218,30 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
202218
{
203219
match stab_v.parse::<u64>() {
204220
Err(_) => {
205-
self.tcx.sess.span_err(item_sp, "Invalid stability version found");
221+
self.tcx.sess.struct_span_err(span, "invalid stability version found")
222+
.span_label(span, "invalid stability version")
223+
.span_label(item_sp, "the stability attribute annotates this item")
224+
.emit();
206225
break;
207226
}
208227
Ok(stab_vp) => match dep_v.parse::<u64>() {
209228
Ok(dep_vp) => match dep_vp.cmp(&stab_vp) {
210229
Ordering::Less => {
211-
self.tcx.sess.span_err(
212-
item_sp,
213-
"An API can't be stabilized after it is deprecated",
214-
);
230+
self.tcx.sess.struct_span_err(span, "an API can't be stabilized after it is deprecated")
231+
.span_label(span, "invalid version")
232+
.span_label(item_sp, "the stability attribute annotates this item")
233+
.emit();
215234
break;
216235
}
217236
Ordering::Equal => continue,
218237
Ordering::Greater => break,
219238
},
220239
Err(_) => {
221240
if dep_v != "TBD" {
222-
self.tcx
223-
.sess
224-
.span_err(item_sp, "Invalid deprecation version found");
241+
self.tcx.sess.struct_span_err(span, "invalid deprecation version found")
242+
.span_label(span, "invalid deprecation version")
243+
.span_label(item_sp, "the stability attribute annotates this item")
244+
.emit();
225245
}
226246
break;
227247
}
@@ -237,7 +257,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
237257
if stab.is_none() {
238258
debug!("annotate: stab not found, parent = {:?}", self.parent_stab);
239259
if let Some(stab) = self.parent_stab {
240-
if inherit_deprecation.yes() && stab.level.is_unstable() {
260+
if inherit_deprecation.yes() && stab.level.is_unstable()
261+
|| inherit_from_parent.yes()
262+
{
241263
self.index.stab_map.insert(hir_id, stab);
242264
}
243265
}
@@ -368,6 +390,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
368390
AnnotationKind::Required,
369391
InheritDeprecation::Yes,
370392
InheritConstStability::No,
393+
InheritStability::Yes,
371394
|_| {},
372395
)
373396
}
@@ -382,6 +405,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
382405
kind,
383406
InheritDeprecation::Yes,
384407
const_stab_inherit,
408+
InheritStability::No,
385409
|v| intravisit::walk_item(v, i),
386410
);
387411
self.in_trait_impl = orig_in_trait_impl;
@@ -395,6 +419,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
395419
AnnotationKind::Required,
396420
InheritDeprecation::Yes,
397421
InheritConstStability::No,
422+
InheritStability::No,
398423
|v| {
399424
intravisit::walk_trait_item(v, ti);
400425
},
@@ -411,6 +436,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
411436
kind,
412437
InheritDeprecation::Yes,
413438
InheritConstStability::No,
439+
InheritStability::No,
414440
|v| {
415441
intravisit::walk_impl_item(v, ii);
416442
},
@@ -425,6 +451,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
425451
AnnotationKind::Required,
426452
InheritDeprecation::Yes,
427453
InheritConstStability::No,
454+
InheritStability::Yes,
428455
|v| {
429456
if let Some(ctor_hir_id) = var.data.ctor_hir_id() {
430457
v.annotate(
@@ -434,6 +461,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
434461
AnnotationKind::Required,
435462
InheritDeprecation::Yes,
436463
InheritConstStability::No,
464+
InheritStability::No,
437465
|_| {},
438466
);
439467
}
@@ -451,6 +479,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
451479
AnnotationKind::Required,
452480
InheritDeprecation::Yes,
453481
InheritConstStability::No,
482+
InheritStability::Yes,
454483
|v| {
455484
intravisit::walk_struct_field(v, s);
456485
},
@@ -465,6 +494,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
465494
AnnotationKind::Required,
466495
InheritDeprecation::Yes,
467496
InheritConstStability::No,
497+
InheritStability::No,
468498
|v| {
469499
intravisit::walk_foreign_item(v, i);
470500
},
@@ -479,6 +509,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
479509
AnnotationKind::Required,
480510
InheritDeprecation::Yes,
481511
InheritConstStability::No,
512+
InheritStability::No,
482513
|_| {},
483514
);
484515
}
@@ -499,6 +530,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
499530
kind,
500531
InheritDeprecation::No,
501532
InheritConstStability::No,
533+
InheritStability::No,
502534
|v| {
503535
intravisit::walk_generic_param(v, p);
504536
},
@@ -669,6 +701,7 @@ fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
669701
AnnotationKind::Required,
670702
InheritDeprecation::Yes,
671703
InheritConstStability::No,
704+
InheritStability::No,
672705
|v| intravisit::walk_crate(v, krate),
673706
);
674707
}
@@ -729,18 +762,13 @@ impl Visitor<'tcx> for Checker<'tcx> {
729762
// error if all involved types and traits are stable, because
730763
// it will have no effect.
731764
// See: https://github.com/rust-lang/rust/issues/55436
732-
if let (Some(Stability { level: attr::Unstable { .. }, .. }), _) =
765+
if let (Some((Stability { level: attr::Unstable { .. }, .. }, span)), _) =
733766
attr::find_stability(&self.tcx.sess, &item.attrs, item.span)
734767
{
735768
let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true };
736769
c.visit_ty(self_ty);
737770
c.visit_trait_ref(t);
738771
if c.fully_stable {
739-
let span = item
740-
.attrs
741-
.iter()
742-
.find(|a| a.has_name(sym::unstable))
743-
.map_or(item.span, |a| a.span);
744772
self.tcx.struct_span_lint_hir(
745773
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
746774
item.hir_id(),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[rustc_const_stable(feature = "foo", since = "0")]
2+
//~^ ERROR macros cannot have const stability attributes
3+
macro_rules! foo {
4+
() => {};
5+
}
6+
7+
#[rustc_const_unstable(feature = "bar", issue="none")]
8+
//~^ ERROR macros cannot have const stability attributes
9+
macro_rules! bar {
10+
() => {};
11+
}
12+
13+
fn main() {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: macros cannot have const stability attributes
2+
--> $DIR/const-stability-on-macro.rs:1:1
3+
|
4+
LL | #[rustc_const_stable(feature = "foo", since = "0")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute
6+
LL |
7+
LL | macro_rules! foo {
8+
| ---------------- const stability attribute affects this macro
9+
10+
error: macros cannot have const stability attributes
11+
--> $DIR/const-stability-on-macro.rs:7:1
12+
|
13+
LL | #[rustc_const_unstable(feature = "bar", issue="none")]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid const stability attribute
15+
LL |
16+
LL | macro_rules! bar {
17+
| ---------------- const stability attribute affects this macro
18+
19+
error: aborting due to 2 previous errors
20+
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// #[deprecated] cannot be used in staged API
2-
31
#![feature(staged_api)]
4-
52
#![stable(feature = "stable_test_feature", since = "1.0.0")]
6-
7-
#[deprecated]
8-
fn main() { } //~ ERROR `#[deprecated]` cannot be used in staged API
3+
#[deprecated] //~ ERROR `#[deprecated]` cannot be used in staged API
4+
fn main() {}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error: `#[deprecated]` cannot be used in staged API; use `#[rustc_deprecated]` instead
2-
--> $DIR/deprecation-in-staged-api.rs:8:1
1+
error: `#[deprecated]` cannot be used in staged API
2+
--> $DIR/deprecation-in-staged-api.rs:3:1
33
|
4-
LL | fn main() { }
5-
| ^^^^^^^^^^^^^
4+
LL | #[deprecated]
5+
| ^^^^^^^^^^^^^ use `#[rustc_deprecated]` instead
6+
LL | fn main() {}
7+
| ------------
68

79
error: aborting due to previous error
810

‎src/test/ui/lint/auxiliary/lint_stability_fields.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,35 @@
33

44
#[stable(feature = "rust1", since = "1.0.0")]
55
pub struct Stable {
6-
#[stable(feature = "rust1", since = "1.0.0")]
7-
pub inherit: u8, // it's a lie (stable doesn't inherit)
6+
pub inherit: u8,
87
#[unstable(feature = "unstable_test_feature", issue = "none")]
98
pub override1: u8,
109
#[rustc_deprecated(since = "1.0.0", reason = "text")]
1110
#[unstable(feature = "unstable_test_feature", issue = "none")]
1211
pub override2: u8,
12+
#[stable(feature = "rust2", since = "2.0.0")]
13+
pub override3: u8,
1314
}
1415

1516
#[stable(feature = "rust1", since = "1.0.0")]
16-
pub struct Stable2(#[stable(feature = "rust1", since = "1.0.0")] pub u8,
17+
pub struct Stable2(#[stable(feature = "rust2", since = "2.0.0")] pub u8,
1718
#[unstable(feature = "unstable_test_feature", issue = "none")] pub u8,
1819
#[unstable(feature = "unstable_test_feature", issue = "none")]
19-
#[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8);
20+
#[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8,
21+
pub u8);
22+
23+
#[stable(feature = "rust1", since = "1.0.0")]
24+
pub enum Stable3 {
25+
Inherit(u8),
26+
InheritOverride(#[stable(feature = "rust2", since = "2.0.0")] u8),
27+
#[stable(feature = "rust2", since = "2.0.0")]
28+
Override1,
29+
#[unstable(feature = "unstable_test_feature", issue = "none")]
30+
Override2,
31+
#[rustc_deprecated(since = "1.0.0", reason = "text")]
32+
#[unstable(feature = "unstable_test_feature", issue = "none")]
33+
Override3,
34+
}
2035

2136
#[unstable(feature = "unstable_test_feature", issue = "none")]
2237
pub struct Unstable {

‎src/test/ui/lint/lint-stability-fields-deprecated.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,38 @@ mod cross_crate {
1717
override1: 2,
1818
override2: 3,
1919
//~^ ERROR use of deprecated field
20+
override3: 4,
2021
};
2122

2223
let _ = x.inherit;
2324
let _ = x.override1;
2425
let _ = x.override2;
2526
//~^ ERROR use of deprecated field
27+
let _ = x.override3;
2628

2729
let Stable {
2830
inherit: _,
2931
override1: _,
30-
override2: _
32+
override2: _,
3133
//~^ ERROR use of deprecated field
34+
override3: _,
3235
} = x;
3336
// all fine
3437
let Stable { .. } = x;
3538

36-
let x = Stable2(1, 2, 3);
39+
let x = Stable2(1, 2, 3, 4);
3740

3841
let _ = x.0;
3942
let _ = x.1;
4043
let _ = x.2;
4144
//~^ ERROR use of deprecated field
45+
let _ = x.3;
4246

4347
let Stable2(_,
4448
_,
49+
_,
50+
//~^ ERROR use of deprecated field
4551
_)
46-
//~^ ERROR use of deprecated field
4752
= x;
4853
// all fine
4954
let Stable2(..) = x;

‎src/test/ui/lint/lint-stability-fields-deprecated.stderr

Lines changed: 63 additions & 63 deletions
Large diffs are not rendered by default.

‎src/test/ui/lint/lint-stability-fields.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,34 @@ mod cross_crate {
2020
inherit: 1,
2121
override1: 2, //~ ERROR use of unstable
2222
override2: 3, //~ ERROR use of unstable
23+
override3: 4,
2324
};
2425

2526
let _ = x.inherit;
2627
let _ = x.override1; //~ ERROR use of unstable
2728
let _ = x.override2; //~ ERROR use of unstable
29+
let _ = x.override3;
2830

2931
let Stable {
3032
inherit: _,
3133
override1: _, //~ ERROR use of unstable
32-
override2: _ //~ ERROR use of unstable
34+
override2: _, //~ ERROR use of unstable
35+
override3: _
3336
} = x;
3437
// all fine
3538
let Stable { .. } = x;
3639

37-
let x = Stable2(1, 2, 3);
40+
let x = Stable2(1, 2, 3, 4);
3841

3942
let _ = x.0;
4043
let _ = x.1; //~ ERROR use of unstable
4144
let _ = x.2; //~ ERROR use of unstable
45+
let _ = x.3;
4246

4347
let Stable2(_,
4448
_, //~ ERROR use of unstable
45-
_) //~ ERROR use of unstable
49+
_, //~ ERROR use of unstable
50+
_)
4651
= x;
4752
// all fine
4853
let Stable2(..) = x;
@@ -133,11 +138,13 @@ mod this_crate {
133138
#[rustc_deprecated(since = "1.0.0", reason = "text")]
134139
#[unstable(feature = "unstable_test_feature", issue = "none")]
135140
override2: u8,
141+
#[stable(feature = "rust2", since = "2.0.0")]
142+
override3: u8,
136143
}
137144

138145
#[stable(feature = "rust1", since = "1.0.0")]
139146
struct Stable2(u8,
140-
#[stable(feature = "rust1", since = "1.0.0")] u8,
147+
#[stable(feature = "rust2", since = "2.0.0")] u8,
141148
#[unstable(feature = "unstable_test_feature", issue = "none")]
142149
#[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
143150

@@ -178,16 +185,19 @@ mod this_crate {
178185
inherit: 1,
179186
override1: 2,
180187
override2: 3,
188+
override3: 4,
181189
};
182190

183191
let _ = x.inherit;
184192
let _ = x.override1;
185193
let _ = x.override2;
194+
let _ = x.override3;
186195

187196
let Stable {
188197
inherit: _,
189198
override1: _,
190-
override2: _
199+
override2: _,
200+
override3: _
191201
} = x;
192202
// all fine
193203
let Stable { .. } = x;

‎src/test/ui/lint/lint-stability-fields.stderr

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
error[E0658]: use of unstable library feature 'unstable_test_feature'
2-
--> $DIR/lint-stability-fields.rs:51:17
2+
--> $DIR/lint-stability-fields.rs:56:17
33
|
44
LL | let x = Unstable {
55
| ^^^^^^^^
66
|
77
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
88

99
error[E0658]: use of unstable library feature 'unstable_test_feature'
10-
--> $DIR/lint-stability-fields.rs:61:13
10+
--> $DIR/lint-stability-fields.rs:66:13
1111
|
1212
LL | let Unstable {
1313
| ^^^^^^^^
1414
|
1515
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
1616

1717
error[E0658]: use of unstable library feature 'unstable_test_feature'
18-
--> $DIR/lint-stability-fields.rs:67:13
18+
--> $DIR/lint-stability-fields.rs:72:13
1919
|
2020
LL | let Unstable
2121
| ^^^^^^^^
2222
|
2323
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
2424

2525
error[E0658]: use of unstable library feature 'unstable_test_feature'
26-
--> $DIR/lint-stability-fields.rs:72:17
26+
--> $DIR/lint-stability-fields.rs:77:17
2727
|
2828
LL | let x = reexport::Unstable2(1, 2, 3);
2929
| ^^^^^^^^^^^^^^^^^^^
3030
|
3131
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
3232

3333
error[E0658]: use of unstable library feature 'unstable_test_feature'
34-
--> $DIR/lint-stability-fields.rs:74:17
34+
--> $DIR/lint-stability-fields.rs:79:17
3535
|
3636
LL | let x = Unstable2(1, 2, 3);
3737
| ^^^^^^^^^
3838
|
3939
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
4040

4141
error[E0658]: use of unstable library feature 'unstable_test_feature'
42-
--> $DIR/lint-stability-fields.rs:80:13
42+
--> $DIR/lint-stability-fields.rs:85:13
4343
|
4444
LL | let Unstable2
4545
| ^^^^^^^^^
4646
|
4747
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
4848

4949
error[E0658]: use of unstable library feature 'unstable_test_feature'
50-
--> $DIR/lint-stability-fields.rs:85:13
50+
--> $DIR/lint-stability-fields.rs:90:13
5151
|
5252
LL | let Unstable2
5353
| ^^^^^^^^^
5454
|
5555
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
5656

5757
error[E0658]: use of unstable library feature 'unstable_test_feature'
58-
--> $DIR/lint-stability-fields.rs:90:17
58+
--> $DIR/lint-stability-fields.rs:95:17
5959
|
6060
LL | let x = Deprecated {
6161
| ^^^^^^^^^^
6262
|
6363
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
6464

6565
error[E0658]: use of unstable library feature 'unstable_test_feature'
66-
--> $DIR/lint-stability-fields.rs:100:13
66+
--> $DIR/lint-stability-fields.rs:105:13
6767
|
6868
LL | let Deprecated {
6969
| ^^^^^^^^^^
7070
|
7171
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
7272

7373
error[E0658]: use of unstable library feature 'unstable_test_feature'
74-
--> $DIR/lint-stability-fields.rs:106:13
74+
--> $DIR/lint-stability-fields.rs:111:13
7575
|
7676
LL | let Deprecated
7777
| ^^^^^^^^^^
7878
|
7979
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
8080

8181
error[E0658]: use of unstable library feature 'unstable_test_feature'
82-
--> $DIR/lint-stability-fields.rs:110:17
82+
--> $DIR/lint-stability-fields.rs:115:17
8383
|
8484
LL | let x = Deprecated2(1, 2, 3);
8585
| ^^^^^^^^^^^
8686
|
8787
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
8888

8989
error[E0658]: use of unstable library feature 'unstable_test_feature'
90-
--> $DIR/lint-stability-fields.rs:116:13
90+
--> $DIR/lint-stability-fields.rs:121:13
9191
|
9292
LL | let Deprecated2
9393
| ^^^^^^^^^^^
9494
|
9595
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
9696

9797
error[E0658]: use of unstable library feature 'unstable_test_feature'
98-
--> $DIR/lint-stability-fields.rs:121:13
98+
--> $DIR/lint-stability-fields.rs:126:13
9999
|
100100
LL | let Deprecated2
101101
| ^^^^^^^^^^^
@@ -119,223 +119,223 @@ LL | override2: 3,
119119
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
120120

121121
error[E0658]: use of unstable library feature 'unstable_test_feature'
122-
--> $DIR/lint-stability-fields.rs:26:17
122+
--> $DIR/lint-stability-fields.rs:27:17
123123
|
124124
LL | let _ = x.override1;
125125
| ^^^^^^^^^^^
126126
|
127127
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
128128

129129
error[E0658]: use of unstable library feature 'unstable_test_feature'
130-
--> $DIR/lint-stability-fields.rs:27:17
130+
--> $DIR/lint-stability-fields.rs:28:17
131131
|
132132
LL | let _ = x.override2;
133133
| ^^^^^^^^^^^
134134
|
135135
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
136136

137137
error[E0658]: use of unstable library feature 'unstable_test_feature'
138-
--> $DIR/lint-stability-fields.rs:31:13
138+
--> $DIR/lint-stability-fields.rs:33:13
139139
|
140140
LL | override1: _,
141141
| ^^^^^^^^^^^^
142142
|
143143
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
144144

145145
error[E0658]: use of unstable library feature 'unstable_test_feature'
146-
--> $DIR/lint-stability-fields.rs:32:13
146+
--> $DIR/lint-stability-fields.rs:34:13
147147
|
148-
LL | override2: _
148+
LL | override2: _,
149149
| ^^^^^^^^^^^^
150150
|
151151
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
152152

153153
error[E0658]: use of unstable library feature 'unstable_test_feature'
154-
--> $DIR/lint-stability-fields.rs:40:17
154+
--> $DIR/lint-stability-fields.rs:43:17
155155
|
156156
LL | let _ = x.1;
157157
| ^^^
158158
|
159159
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
160160

161161
error[E0658]: use of unstable library feature 'unstable_test_feature'
162-
--> $DIR/lint-stability-fields.rs:41:17
162+
--> $DIR/lint-stability-fields.rs:44:17
163163
|
164164
LL | let _ = x.2;
165165
| ^^^
166166
|
167167
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
168168

169169
error[E0658]: use of unstable library feature 'unstable_test_feature'
170-
--> $DIR/lint-stability-fields.rs:44:20
170+
--> $DIR/lint-stability-fields.rs:48:20
171171
|
172172
LL | _,
173173
| ^
174174
|
175175
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
176176

177177
error[E0658]: use of unstable library feature 'unstable_test_feature'
178-
--> $DIR/lint-stability-fields.rs:45:20
178+
--> $DIR/lint-stability-fields.rs:49:20
179179
|
180-
LL | _)
180+
LL | _,
181181
| ^
182182
|
183183
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
184184

185185
error[E0658]: use of unstable library feature 'unstable_test_feature'
186-
--> $DIR/lint-stability-fields.rs:52:13
186+
--> $DIR/lint-stability-fields.rs:57:13
187187
|
188188
LL | inherit: 1,
189189
| ^^^^^^^^^^
190190
|
191191
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
192192

193193
error[E0658]: use of unstable library feature 'unstable_test_feature'
194-
--> $DIR/lint-stability-fields.rs:54:13
194+
--> $DIR/lint-stability-fields.rs:59:13
195195
|
196196
LL | override2: 3,
197197
| ^^^^^^^^^^^^
198198
|
199199
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
200200

201201
error[E0658]: use of unstable library feature 'unstable_test_feature'
202-
--> $DIR/lint-stability-fields.rs:57:17
202+
--> $DIR/lint-stability-fields.rs:62:17
203203
|
204204
LL | let _ = x.inherit;
205205
| ^^^^^^^^^
206206
|
207207
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
208208

209209
error[E0658]: use of unstable library feature 'unstable_test_feature'
210-
--> $DIR/lint-stability-fields.rs:59:17
210+
--> $DIR/lint-stability-fields.rs:64:17
211211
|
212212
LL | let _ = x.override2;
213213
| ^^^^^^^^^^^
214214
|
215215
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
216216

217217
error[E0658]: use of unstable library feature 'unstable_test_feature'
218-
--> $DIR/lint-stability-fields.rs:62:13
218+
--> $DIR/lint-stability-fields.rs:67:13
219219
|
220220
LL | inherit: _,
221221
| ^^^^^^^^^^
222222
|
223223
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
224224

225225
error[E0658]: use of unstable library feature 'unstable_test_feature'
226-
--> $DIR/lint-stability-fields.rs:64:13
226+
--> $DIR/lint-stability-fields.rs:69:13
227227
|
228228
LL | override2: _
229229
| ^^^^^^^^^^^^
230230
|
231231
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
232232

233233
error[E0658]: use of unstable library feature 'unstable_test_feature'
234-
--> $DIR/lint-stability-fields.rs:76:17
234+
--> $DIR/lint-stability-fields.rs:81:17
235235
|
236236
LL | let _ = x.0;
237237
| ^^^
238238
|
239239
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
240240

241241
error[E0658]: use of unstable library feature 'unstable_test_feature'
242-
--> $DIR/lint-stability-fields.rs:78:17
242+
--> $DIR/lint-stability-fields.rs:83:17
243243
|
244244
LL | let _ = x.2;
245245
| ^^^
246246
|
247247
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
248248

249249
error[E0658]: use of unstable library feature 'unstable_test_feature'
250-
--> $DIR/lint-stability-fields.rs:81:14
250+
--> $DIR/lint-stability-fields.rs:86:14
251251
|
252252
LL | (_,
253253
| ^
254254
|
255255
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
256256

257257
error[E0658]: use of unstable library feature 'unstable_test_feature'
258-
--> $DIR/lint-stability-fields.rs:83:14
258+
--> $DIR/lint-stability-fields.rs:88:14
259259
|
260260
LL | _)
261261
| ^
262262
|
263263
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
264264

265265
error[E0658]: use of unstable library feature 'unstable_test_feature'
266-
--> $DIR/lint-stability-fields.rs:91:13
266+
--> $DIR/lint-stability-fields.rs:96:13
267267
|
268268
LL | inherit: 1,
269269
| ^^^^^^^^^^
270270
|
271271
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
272272

273273
error[E0658]: use of unstable library feature 'unstable_test_feature'
274-
--> $DIR/lint-stability-fields.rs:93:13
274+
--> $DIR/lint-stability-fields.rs:98:13
275275
|
276276
LL | override2: 3,
277277
| ^^^^^^^^^^^^
278278
|
279279
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
280280

281281
error[E0658]: use of unstable library feature 'unstable_test_feature'
282-
--> $DIR/lint-stability-fields.rs:96:17
282+
--> $DIR/lint-stability-fields.rs:101:17
283283
|
284284
LL | let _ = x.inherit;
285285
| ^^^^^^^^^
286286
|
287287
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
288288

289289
error[E0658]: use of unstable library feature 'unstable_test_feature'
290-
--> $DIR/lint-stability-fields.rs:98:17
290+
--> $DIR/lint-stability-fields.rs:103:17
291291
|
292292
LL | let _ = x.override2;
293293
| ^^^^^^^^^^^
294294
|
295295
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
296296

297297
error[E0658]: use of unstable library feature 'unstable_test_feature'
298-
--> $DIR/lint-stability-fields.rs:101:13
298+
--> $DIR/lint-stability-fields.rs:106:13
299299
|
300300
LL | inherit: _,
301301
| ^^^^^^^^^^
302302
|
303303
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
304304

305305
error[E0658]: use of unstable library feature 'unstable_test_feature'
306-
--> $DIR/lint-stability-fields.rs:103:13
306+
--> $DIR/lint-stability-fields.rs:108:13
307307
|
308308
LL | override2: _
309309
| ^^^^^^^^^^^^
310310
|
311311
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
312312

313313
error[E0658]: use of unstable library feature 'unstable_test_feature'
314-
--> $DIR/lint-stability-fields.rs:112:17
314+
--> $DIR/lint-stability-fields.rs:117:17
315315
|
316316
LL | let _ = x.0;
317317
| ^^^
318318
|
319319
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
320320

321321
error[E0658]: use of unstable library feature 'unstable_test_feature'
322-
--> $DIR/lint-stability-fields.rs:114:17
322+
--> $DIR/lint-stability-fields.rs:119:17
323323
|
324324
LL | let _ = x.2;
325325
| ^^^
326326
|
327327
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
328328

329329
error[E0658]: use of unstable library feature 'unstable_test_feature'
330-
--> $DIR/lint-stability-fields.rs:117:14
330+
--> $DIR/lint-stability-fields.rs:122:14
331331
|
332332
LL | (_,
333333
| ^
334334
|
335335
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
336336

337337
error[E0658]: use of unstable library feature 'unstable_test_feature'
338-
--> $DIR/lint-stability-fields.rs:119:14
338+
--> $DIR/lint-stability-fields.rs:124:14
339339
|
340340
LL | _)
341341
| ^
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
// check-pass
12
#![feature(staged_api)]
23
#![stable(feature = "test", since = "0")]
34

45
#[stable(feature = "test", since = "0")]
5-
pub struct Reverse<T>(pub T); //~ ERROR field has missing stability attribute
6+
pub struct A<T>(pub T);
7+
8+
#[stable(feature = "test", since = "0")]
9+
pub struct B<T>(#[stable(feature = "test", since = "0")] pub T);
610

711
fn main() {
812
// Make sure the field is used to fill the stability cache
9-
Reverse(0).0;
13+
A(0).0;
14+
B(0).0;
1015
}

‎src/test/ui/stability-attribute/stability-attribute-issue-43027.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎src/test/ui/stability-attribute/stability-attribute-sanity.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ fn multiple2() { }
5757
#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
5858
fn multiple3() { }
5959

60-
#[stable(feature = "a", since = "b")]
60+
#[stable(feature = "a", since = "b")] //~ ERROR invalid stability version found
6161
#[rustc_deprecated(since = "b", reason = "text")]
6262
#[rustc_deprecated(since = "b", reason = "text")] //~ ERROR multiple deprecated attributes
6363
#[rustc_const_unstable(feature = "c", issue = "none")]
6464
#[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels
6565
pub const fn multiple4() { }
66-
//~^ ERROR Invalid stability version found
6766

68-
#[stable(feature = "a", since = "1.0.0")]
67+
#[stable(feature = "a", since = "1.0.0")] //~ ERROR invalid deprecation version found
6968
#[rustc_deprecated(since = "invalid", reason = "text")]
70-
fn invalid_deprecation_version() {} //~ ERROR Invalid deprecation version found
69+
fn invalid_deprecation_version() {}
7170

7271
#[rustc_deprecated(since = "a", reason = "text")]
7372
fn deprecated_without_unstable_or_stable() { }

‎src/test/ui/stability-attribute/stability-attribute-sanity.stderr

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,26 @@ error[E0544]: multiple stability levels
9696
LL | #[rustc_const_unstable(feature = "d", issue = "none")]
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9898

99-
error: Invalid stability version found
100-
--> $DIR/stability-attribute-sanity.rs:65:1
99+
error: invalid stability version found
100+
--> $DIR/stability-attribute-sanity.rs:60:1
101101
|
102+
LL | #[stable(feature = "a", since = "b")]
103+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid stability version
104+
...
102105
LL | pub const fn multiple4() { }
103-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106+
| ---------------------------- the stability attribute annotates this item
104107

105-
error: Invalid deprecation version found
106-
--> $DIR/stability-attribute-sanity.rs:70:1
108+
error: invalid deprecation version found
109+
--> $DIR/stability-attribute-sanity.rs:67:1
107110
|
111+
LL | #[stable(feature = "a", since = "1.0.0")]
112+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid deprecation version
113+
LL | #[rustc_deprecated(since = "invalid", reason = "text")]
108114
LL | fn invalid_deprecation_version() {}
109-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115+
| ----------------------------------- the stability attribute annotates this item
110116

111117
error[E0549]: rustc_deprecated attribute must be paired with either stable or unstable attribute
112-
--> $DIR/stability-attribute-sanity.rs:72:1
118+
--> $DIR/stability-attribute-sanity.rs:71:1
113119
|
114120
LL | #[rustc_deprecated(since = "a", reason = "text")]
115121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)
Please sign in to comment.