Skip to content

Commit

Permalink
Additional trait default parameter stability tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder committed Jan 24, 2020
1 parent 5551143 commit 074ef54
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ pub trait Trait1<#[unstable(feature = "unstable_default", issue = "none")] T = (
}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub trait Trait2<T = ()> {
pub trait Trait2<#[unstable(feature = "unstable_default", issue = "none")] T = usize> {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
fn foo() -> T;
}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub trait Trait3<T = ()> {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
fn foo() -> T;
}
Expand Down
14 changes: 11 additions & 3 deletions src/test/ui/stability-attribute/generics-default-stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ impl Trait1<usize> for S { //~ ERROR use of unstable library feature 'unstable_d
fn foo() -> usize { 0 }
}

impl Trait2<usize> for S {
impl Trait1<isize> for S { //~ ERROR use of unstable library feature 'unstable_default'
fn foo() -> usize { 0 }
}

impl Trait2<usize> for S { //~ ERROR use of unstable library feature 'unstable_default'
fn foo() -> usize { 0 }
}

impl Trait3<usize> for S {
fn foo() -> usize { 0 } // ok
}

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

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<usize> = 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;
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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ LL | impl Trait1<usize> for S {
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable

error: aborting due to previous error
error[E0658]: use of unstable library feature 'unstable_default'
--> $DIR/generics-default-stability.rs:19:13
|
LL | impl Trait1<isize> for S {
| ^^^^^
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'unstable_default'
--> $DIR/generics-default-stability.rs:23:13
|
LL | impl Trait2<usize> for S {
| ^^^^^
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable

error: aborting due to 3 previous errors

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

0 comments on commit 074ef54

Please sign in to comment.