forked from rust-lang/rust
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stability annotations on generic trait parameters
- Loading branch information
1 parent
6d3acf5
commit a7a2086
Showing
8 changed files
with
226 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![crate_type = "lib"] | ||
#![feature(staged_api)] | ||
|
||
#![stable(feature = "stable_test_feature", since = "1.0.0")] | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub trait Trait1<#[unstable(feature = "unstable_default", issue = "none")] T = ()> { | ||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
fn foo() -> T; | ||
} | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
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; | ||
} | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub struct Struct1<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { | ||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub field: T, | ||
} | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub struct Struct2<T = usize> { | ||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub field: T, | ||
} | ||
|
||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub const STRUCT1: Struct1 = Struct1 { field: 1 }; | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0.0")] | ||
pub const STRUCT2: Struct2 = Struct2 { field: 1 }; |
59 changes: 59 additions & 0 deletions
59
src/test/ui/stability-attribute/generics-default-stability.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// aux-build:unstable_generic_param.rs | ||
|
||
extern crate unstable_generic_param; | ||
|
||
use unstable_generic_param::*; | ||
|
||
struct R; | ||
|
||
impl Trait1 for S { | ||
fn foo() -> () { () } // ok | ||
} | ||
|
||
struct S; | ||
|
||
impl Trait1<usize> for S { //~ ERROR use of unstable library feature 'unstable_default' | ||
fn foo() -> usize { 0 } | ||
} | ||
|
||
impl Trait1<isize> for S { //~ ERROR use of unstable library feature 'unstable_default' | ||
fn foo() -> isize { 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 | ||
} | ||
|
||
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 _ = Struct2 { field: 1 }; // ok | ||
// let _: Struct2 = Struct2 { field: 1 }; // ok | ||
// let _: Struct2<usize> = Struct2 { field: 1 }; // ok | ||
|
||
// let _ = STRUCT2; | ||
// let _: Struct2 = STRUCT2; // ok | ||
// let _: Struct2<usize> = STRUCT2; // ok | ||
// let _: Struct2<usize> = STRUCT2; // ok | ||
// let _ = STRUCT2.field; // ok | ||
// let _: usize = STRUCT2.field; // ok | ||
// let _ = STRUCT2.field + 1; // ok | ||
// let _ = STRUCT2.field + 1usize; // ok | ||
} |
Oops, something went wrong.