Skip to content

Commit 5551143

Browse files
committed
Additional default type parameter stability tests
1 parent 8bcf35d commit 5551143

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

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

+19
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@ pub trait Trait2<T = ()> {
1414
#[stable(feature = "stable_test_feature", since = "1.0.0")]
1515
fn foo() -> T;
1616
}
17+
18+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
19+
pub struct Struct1<#[unstable(feature = "unstable_default", issue = "none")] T = usize> {
20+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
21+
pub field: T,
22+
}
23+
24+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
25+
pub struct Struct2<T = usize> {
26+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
27+
pub field: T,
28+
}
29+
30+
31+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
32+
pub const STRUCT1: Struct1 = Struct1 { field: 1 };
33+
34+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
35+
pub const STRUCT2: Struct2 = Struct2 { field: 1 };

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

+27-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
extern crate unstable_generic_param;
44

5-
use unstable_generic_param::{Trait1, Trait2};
5+
use unstable_generic_param::*;
66

77
struct R;
88

@@ -22,4 +22,30 @@ impl Trait2<usize> for S {
2222

2323
fn main() {
2424
let _ = S;
25+
26+
let _ = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
27+
let _: Struct1 = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
28+
let _: Struct1<usize> = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
29+
30+
let _ = STRUCT1;
31+
let _: Struct1 = STRUCT1; // ok
32+
let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
33+
let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
34+
let _ = STRUCT1.field; // ok
35+
let _: usize = STRUCT1.field; //~ ERROR use of unstable library feature 'unstable_default'
36+
let _ = STRUCT1.field + 1; //~ ERROR use of unstable library feature 'unstable_default'
37+
let _ = STRUCT1.field + 1usize; //~ ERROR use of unstable library feature 'unstable_default'
38+
39+
let _ = Struct2 { field: 1 }; // ok
40+
let _: Struct2 = Struct2 { field: 1 }; // ok
41+
let _: Struct2<usize> = Struct2 { field: 1 }; // ok
42+
43+
let _ = STRUCT2;
44+
let _: Struct2 = STRUCT2; // ok
45+
let _: Struct2<usize> = STRUCT2; // ok
46+
let _: Struct2<usize> = STRUCT2; // ok
47+
let _ = STRUCT2.field; // ok
48+
let _: usize = STRUCT2.field; // ok
49+
let _ = STRUCT2.field + 1; // ok
50+
let _ = STRUCT2.field + 1usize; // ok
2551
}

0 commit comments

Comments
 (0)