Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a1892f1

Browse files
Avi-D-coderJacob Hughes
authored andcommitted
Test stability on default parameter of deprecated
1 parent f665ccd commit a1892f1

File tree

3 files changed

+170
-1
lines changed

3 files changed

+170
-1
lines changed

src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ pub struct Struct3<A = isize, #[unstable(feature = "unstable_default", issue = "
4141
pub field2: B,
4242
}
4343

44+
#[rustc_deprecated(since = "1.1.0", reason = "test")]
45+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
46+
pub struct Struct4<A = usize> {
47+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
48+
pub field: A,
49+
}
50+
51+
#[rustc_deprecated(since = "1.1.0", reason = "test")]
52+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
53+
pub struct Struct5<#[unstable(feature = "unstable_default", issue = "none")] A = usize> {
54+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
55+
pub field: A,
56+
}
57+
4458
#[stable(feature = "stable_test_feature", since = "1.0.0")]
4559
pub const STRUCT1: Struct1 = Struct1 { field: 1 };
4660

@@ -49,3 +63,9 @@ pub const STRUCT2: Struct2 = Struct2 { field: 1 };
4963

5064
#[stable(feature = "stable_test_feature", since = "1.0.0")]
5165
pub const STRUCT3: Struct3 = Struct3 { field1: 1, field2: 2 };
66+
67+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
68+
pub const STRUCT4: Struct4 = Struct4 { field: 1 };
69+
70+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
71+
pub const STRUCT5: Struct5 = Struct5 { field: 1 };

src/test/ui/stability-attribute/generics-default-stability.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,31 @@ fn main() {
7676
let _: Struct3<usize> = Struct3 { field1: 0, field2: 0 }; // ok
7777
let _ = STRUCT3.field2 + 1; // ok
7878
let _ = STRUCT3.field2 + 1usize; // ok
79+
80+
let _ = STRUCT4;
81+
let _: Struct4<isize> = Struct4 { field: 1 };
82+
//~^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
83+
//~^^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
84+
//~^^^ use of deprecated item 'unstable_generic_param::Struct4::field': test [deprecated]
85+
let _ = STRUCT4;
86+
let _: Struct4 = STRUCT4; //~ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
87+
let _: Struct4<usize> = STRUCT4; //~ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
88+
let _: Struct4<isize> = Struct4 { field: 0 };
89+
//~^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
90+
//~^^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
91+
//~^^^ use of deprecated item 'unstable_generic_param::Struct4::field': test [deprecated]
92+
93+
let _ = STRUCT5;
94+
let _: Struct5<isize> = Struct5 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
95+
//~^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
96+
//~^^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
97+
//~^^^ use of deprecated item 'unstable_generic_param::Struct5::field': test [deprecated]
98+
let _ = STRUCT5;
99+
let _: Struct5 = STRUCT5; //~ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
100+
let _: Struct5<usize> = STRUCT5; //~ ERROR use of unstable library feature 'unstable_default'
101+
//~^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
102+
let _: Struct5<isize> = Struct5 { field: 0 }; //~ ERROR use of unstable library feature 'unstable_default'
103+
//~^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
104+
//~^^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
105+
//~^^^ use of deprecated item 'unstable_generic_param::Struct5::field': test [deprecated]
79106
}

src/test/ui/stability-attribute/generics-default-stability.stderr

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,80 @@ LL | impl Trait2<usize> for S {
2222
|
2323
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
2424

25+
warning: use of deprecated item 'unstable_generic_param::Struct4': test
26+
--> $DIR/generics-default-stability.rs:81:29
27+
|
28+
LL | let _: Struct4<isize> = Struct4 { field: 1 };
29+
| ^^^^^^^
30+
|
31+
= note: `#[warn(deprecated)]` on by default
32+
33+
warning: use of deprecated item 'unstable_generic_param::Struct4': test
34+
--> $DIR/generics-default-stability.rs:81:12
35+
|
36+
LL | let _: Struct4<isize> = Struct4 { field: 1 };
37+
| ^^^^^^^^^^^^^^
38+
39+
warning: use of deprecated item 'unstable_generic_param::Struct4': test
40+
--> $DIR/generics-default-stability.rs:86:12
41+
|
42+
LL | let _: Struct4 = STRUCT4;
43+
| ^^^^^^^
44+
45+
warning: use of deprecated item 'unstable_generic_param::Struct4': test
46+
--> $DIR/generics-default-stability.rs:87:12
47+
|
48+
LL | let _: Struct4<usize> = STRUCT4;
49+
| ^^^^^^^^^^^^^^
50+
51+
warning: use of deprecated item 'unstable_generic_param::Struct4': test
52+
--> $DIR/generics-default-stability.rs:88:29
53+
|
54+
LL | let _: Struct4<isize> = Struct4 { field: 0 };
55+
| ^^^^^^^
56+
57+
warning: use of deprecated item 'unstable_generic_param::Struct4': test
58+
--> $DIR/generics-default-stability.rs:88:12
59+
|
60+
LL | let _: Struct4<isize> = Struct4 { field: 0 };
61+
| ^^^^^^^^^^^^^^
62+
63+
warning: use of deprecated item 'unstable_generic_param::Struct5': test
64+
--> $DIR/generics-default-stability.rs:94:29
65+
|
66+
LL | let _: Struct5<isize> = Struct5 { field: 1 };
67+
| ^^^^^^^
68+
69+
warning: use of deprecated item 'unstable_generic_param::Struct5': test
70+
--> $DIR/generics-default-stability.rs:94:12
71+
|
72+
LL | let _: Struct5<isize> = Struct5 { field: 1 };
73+
| ^^^^^^^^^^^^^^
74+
75+
warning: use of deprecated item 'unstable_generic_param::Struct5': test
76+
--> $DIR/generics-default-stability.rs:99:12
77+
|
78+
LL | let _: Struct5 = STRUCT5;
79+
| ^^^^^^^
80+
81+
warning: use of deprecated item 'unstable_generic_param::Struct5': test
82+
--> $DIR/generics-default-stability.rs:100:12
83+
|
84+
LL | let _: Struct5<usize> = STRUCT5;
85+
| ^^^^^^^^^^^^^^
86+
87+
warning: use of deprecated item 'unstable_generic_param::Struct5': test
88+
--> $DIR/generics-default-stability.rs:102:29
89+
|
90+
LL | let _: Struct5<isize> = Struct5 { field: 0 };
91+
| ^^^^^^^
92+
93+
warning: use of deprecated item 'unstable_generic_param::Struct5': test
94+
--> $DIR/generics-default-stability.rs:102:12
95+
|
96+
LL | let _: Struct5<isize> = Struct5 { field: 0 };
97+
| ^^^^^^^^^^^^^^
98+
2599
error[E0658]: use of unstable library feature 'unstable_default'
26100
--> $DIR/generics-default-stability.rs:35:20
27101
|
@@ -70,6 +144,54 @@ LL | let _: Struct3<usize, usize> = Struct3 { field1: 0, field2: 0 };
70144
|
71145
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
72146

73-
error: aborting due to 9 previous errors
147+
error[E0658]: use of unstable library feature 'unstable_default'
148+
--> $DIR/generics-default-stability.rs:94:20
149+
|
150+
LL | let _: Struct5<isize> = Struct5 { field: 1 };
151+
| ^^^^^
152+
|
153+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
154+
155+
error[E0658]: use of unstable library feature 'unstable_default'
156+
--> $DIR/generics-default-stability.rs:100:20
157+
|
158+
LL | let _: Struct5<usize> = STRUCT5;
159+
| ^^^^^
160+
|
161+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
162+
163+
error[E0658]: use of unstable library feature 'unstable_default'
164+
--> $DIR/generics-default-stability.rs:102:20
165+
|
166+
LL | let _: Struct5<isize> = Struct5 { field: 0 };
167+
| ^^^^^
168+
|
169+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
170+
171+
warning: use of deprecated item 'unstable_generic_param::Struct4::field': test
172+
--> $DIR/generics-default-stability.rs:81:39
173+
|
174+
LL | let _: Struct4<isize> = Struct4 { field: 1 };
175+
| ^^^^^^^^
176+
177+
warning: use of deprecated item 'unstable_generic_param::Struct4::field': test
178+
--> $DIR/generics-default-stability.rs:88:39
179+
|
180+
LL | let _: Struct4<isize> = Struct4 { field: 0 };
181+
| ^^^^^^^^
182+
183+
warning: use of deprecated item 'unstable_generic_param::Struct5::field': test
184+
--> $DIR/generics-default-stability.rs:94:39
185+
|
186+
LL | let _: Struct5<isize> = Struct5 { field: 1 };
187+
| ^^^^^^^^
188+
189+
warning: use of deprecated item 'unstable_generic_param::Struct5::field': test
190+
--> $DIR/generics-default-stability.rs:102:39
191+
|
192+
LL | let _: Struct5<isize> = Struct5 { field: 0 };
193+
| ^^^^^^^^
194+
195+
error: aborting due to 12 previous errors; 16 warnings emitted
74196

75197
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)