about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAvi Dessauer <avi.the.coder@gmail.com>2020-06-01 11:51:35 -0400
committerJacob Hughes <j@jacobhughes.me>2020-09-22 21:54:04 -0400
commiteb7abb9e32a2ba10d0c083b13bb1a2dcd1d22b5d (patch)
tree9acbd2cc4e68a7f9ccc336918c972b786c4c40b3
parent88b77b6534d5353a16e597451a22322cc7d92063 (diff)
downloadrust-eb7abb9e32a2ba10d0c083b13bb1a2dcd1d22b5d.tar.gz
rust-eb7abb9e32a2ba10d0c083b13bb1a2dcd1d22b5d.zip
Unstable default types leak in public fields
-rw-r--r--src/test/ui/stability-attribute/generics-default-stability.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/test/ui/stability-attribute/generics-default-stability.rs b/src/test/ui/stability-attribute/generics-default-stability.rs
index f99ce6da198..bacbc64ab47 100644
--- a/src/test/ui/stability-attribute/generics-default-stability.rs
+++ b/src/test/ui/stability-attribute/generics-default-stability.rs
@@ -32,18 +32,22 @@ impl Trait3<usize> for S {
 fn main() {
     let _ = S;
 
-    let _ = Struct1 { field: 1 }; // ERROR use of unstable library feature 'unstable_default'
-    let _: Struct1 = Struct1 { field: 1 }; // ERROR use of unstable library feature 'unstable_default'
     let _: Struct1<isize> = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
 
     let _ = STRUCT1; // ok
     let _: Struct1 = STRUCT1; // ok
     let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
-    let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
-    let _ = STRUCT1.field; // ok
-    let _: usize = STRUCT1.field; // ERROR use of unstable library feature 'unstable_default'
-    let _ = STRUCT1.field + 1; // ERROR use of unstable library feature 'unstable_default'
-    let _ = STRUCT1.field + 1usize; // ERROR use of unstable library feature 'unstable_default'
+    let _: Struct1<isize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
+
+    // Instability is not enforced for generic type parameters used in public fields.
+    // Note how the unstable type default `usize` leaks,
+    // and can be used without the 'unstable_default' feature.
+    let _ = STRUCT1.field;
+    let _ = Struct1 { field: 1 };
+    let _: Struct1 = Struct1 { field: 1 };
+    let _: usize = STRUCT1.field;
+    let _ = STRUCT1.field + 1;
+    let _ = STRUCT1.field + 1usize;
 
     let _ = Struct2 { field: 1 }; // ok
     let _: Struct2 = Struct2 { field: 1 }; // ok