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

Commit eb7abb9

Browse files
Avi-D-coderJacob Hughes
authored andcommitted
Unstable default types leak in public fields
1 parent 88b77b6 commit eb7abb9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ impl Trait3<usize> for S {
3232
fn main() {
3333
let _ = S;
3434

35-
let _ = Struct1 { field: 1 }; // ERROR use of unstable library feature 'unstable_default'
36-
let _: Struct1 = Struct1 { field: 1 }; // ERROR use of unstable library feature 'unstable_default'
3735
let _: Struct1<isize> = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
3836

3937
let _ = STRUCT1; // ok
4038
let _: Struct1 = STRUCT1; // ok
4139
let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
42-
let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
43-
let _ = STRUCT1.field; // ok
44-
let _: usize = STRUCT1.field; // ERROR use of unstable library feature 'unstable_default'
45-
let _ = STRUCT1.field + 1; // ERROR use of unstable library feature 'unstable_default'
46-
let _ = STRUCT1.field + 1usize; // ERROR use of unstable library feature 'unstable_default'
40+
let _: Struct1<isize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
41+
42+
// Instability is not enforced for generic type parameters used in public fields.
43+
// Note how the unstable type default `usize` leaks,
44+
// and can be used without the 'unstable_default' feature.
45+
let _ = STRUCT1.field;
46+
let _ = Struct1 { field: 1 };
47+
let _: Struct1 = Struct1 { field: 1 };
48+
let _: usize = STRUCT1.field;
49+
let _ = STRUCT1.field + 1;
50+
let _ = STRUCT1.field + 1usize;
4751

4852
let _ = Struct2 { field: 1 }; // ok
4953
let _: Struct2 = Struct2 { field: 1 }; // ok

0 commit comments

Comments
 (0)