Skip to content

Commit 074ef54

Browse files
committed
Additional trait default parameter stability tests
1 parent 5551143 commit 074ef54

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ pub trait Trait1<#[unstable(feature = "unstable_default", issue = "none")] T = (
1010
}
1111

1212
#[stable(feature = "stable_test_feature", since = "1.0.0")]
13-
pub trait Trait2<T = ()> {
13+
pub trait Trait2<#[unstable(feature = "unstable_default", issue = "none")] T = usize> {
14+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
15+
fn foo() -> T;
16+
}
17+
18+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
19+
pub trait Trait3<T = ()> {
1420
#[stable(feature = "stable_test_feature", since = "1.0.0")]
1521
fn foo() -> T;
1622
}

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ impl Trait1<usize> for S { //~ ERROR use of unstable library feature 'unstable_d
1616
fn foo() -> usize { 0 }
1717
}
1818

19-
impl Trait2<usize> for S {
19+
impl Trait1<isize> for S { //~ ERROR use of unstable library feature 'unstable_default'
20+
fn foo() -> usize { 0 }
21+
}
22+
23+
impl Trait2<usize> for S { //~ ERROR use of unstable library feature 'unstable_default'
24+
fn foo() -> usize { 0 }
25+
}
26+
27+
impl Trait3<usize> for S {
2028
fn foo() -> usize { 0 } // ok
2129
}
2230

@@ -25,9 +33,9 @@ fn main() {
2533

2634
let _ = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
2735
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'
36+
let _: Struct1<isize> = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
2937

30-
let _ = STRUCT1;
38+
let _ = STRUCT1; // ok
3139
let _: Struct1 = STRUCT1; // ok
3240
let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'
3341
let _: Struct1<usize> = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default'

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ LL | impl Trait1<usize> for S {
66
|
77
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
88

9-
error: aborting due to previous error
9+
error[E0658]: use of unstable library feature 'unstable_default'
10+
--> $DIR/generics-default-stability.rs:19:13
11+
|
12+
LL | impl Trait1<isize> for S {
13+
| ^^^^^
14+
|
15+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
16+
17+
error[E0658]: use of unstable library feature 'unstable_default'
18+
--> $DIR/generics-default-stability.rs:23:13
19+
|
20+
LL | impl Trait2<usize> for S {
21+
| ^^^^^
22+
|
23+
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
24+
25+
error: aborting due to 3 previous errors
1026

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

0 commit comments

Comments
 (0)