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

Commit f665ccd

Browse files
Avi-D-coderJacob Hughes
authored andcommitted
Add more tests
1 parent cb7264b commit f665ccd

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ pub struct Struct2<T = usize> {
3333
pub field: T,
3434
}
3535

36+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
37+
pub struct Struct3<A = isize, #[unstable(feature = "unstable_default", issue = "none")] B = usize> {
38+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
39+
pub field1: A,
40+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
41+
pub field2: B,
42+
}
3643

3744
#[stable(feature = "stable_test_feature", since = "1.0.0")]
3845
pub const STRUCT1: Struct1 = Struct1 { field: 1 };
3946

4047
#[stable(feature = "stable_test_feature", since = "1.0.0")]
4148
pub const STRUCT2: Struct2 = Struct2 { field: 1 };
49+
50+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
51+
pub const STRUCT3: Struct3 = Struct3 { field1: 1, field2: 2 };
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// ignore-tidy-linelength
2+
// aux-build:unstable_generic_param.rs
3+
4+
extern crate unstable_generic_param;
5+
6+
use unstable_generic_param::*;
7+
8+
impl<T> Trait3<usize> for T where T: Trait2<usize> { //~ ERROR use of unstable library feature 'unstable_default'
9+
fn foo() -> usize { T::foo() }
10+
}
11+
12+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0658]: use of unstable library feature 'unstable_default'
2+
--> $DIR/generics-default-stability-where.rs:8:45
3+
|
4+
LL | impl<T> Trait3<usize> for T where T: Trait2<usize> {
5+
| ^^^^^
6+
|
7+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0658`.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,19 @@ fn main() {
6161
let _: usize = STRUCT2.field; // ok
6262
let _ = STRUCT2.field + 1; // ok
6363
let _ = STRUCT2.field + 1usize; // ok
64+
65+
let _ = STRUCT3;
66+
let _: Struct3 = STRUCT3; // ok
67+
let _: Struct3<isize, usize> = STRUCT3; //~ ERROR use of unstable library feature 'unstable_default'
68+
let _: Struct3<isize> = STRUCT3; // ok
69+
let _: Struct3<isize, isize> = Struct3 { field1: 0, field2: 0 }; //~ ERROR use of unstable library feature 'unstable_default'
70+
let _: Struct3<usize, usize> = Struct3 { field1: 0, field2: 0 }; //~ ERROR use of unstable library feature 'unstable_default'
71+
let _ = STRUCT3.field1; // ok
72+
let _: isize = STRUCT3.field1; // ok
73+
let _ = STRUCT3.field1 + 1; // ok
74+
// Note the aforementioned leak.
75+
let _: usize = STRUCT3.field2; // ok
76+
let _: Struct3<usize> = Struct3 { field1: 0, field2: 0 }; // ok
77+
let _ = STRUCT3.field2 + 1; // ok
78+
let _ = STRUCT3.field2 + 1usize; // ok
6479
}

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ LL | let _: Struct1<isize> = Struct1 { field: 0 };
4646
|
4747
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
4848

49-
error: aborting due to 6 previous errors
49+
error[E0658]: use of unstable library feature 'unstable_default'
50+
--> $DIR/generics-default-stability.rs:67:27
51+
|
52+
LL | let _: Struct3<isize, usize> = STRUCT3;
53+
| ^^^^^
54+
|
55+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
56+
57+
error[E0658]: use of unstable library feature 'unstable_default'
58+
--> $DIR/generics-default-stability.rs:69:27
59+
|
60+
LL | let _: Struct3<isize, isize> = Struct3 { field1: 0, field2: 0 };
61+
| ^^^^^
62+
|
63+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
64+
65+
error[E0658]: use of unstable library feature 'unstable_default'
66+
--> $DIR/generics-default-stability.rs:70:27
67+
|
68+
LL | let _: Struct3<usize, usize> = Struct3 { field1: 0, field2: 0 };
69+
| ^^^^^
70+
|
71+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
72+
73+
error: aborting due to 9 previous errors
5074

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

0 commit comments

Comments
 (0)