1
Fork 0

Add more tests

This commit is contained in:
Avi Dessauer 2020-06-22 00:08:54 -04:00 committed by Jacob Hughes
parent cb7264b22a
commit f665ccd3a2
5 changed files with 73 additions and 1 deletions

View file

@ -33,9 +33,19 @@ pub struct Struct2<T = usize> {
pub field: T,
}
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub struct Struct3<A = isize, #[unstable(feature = "unstable_default", issue = "none")] B = usize> {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub field1: A,
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub field2: B,
}
#[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 };
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub const STRUCT3: Struct3 = Struct3 { field1: 1, field2: 2 };

View file

@ -0,0 +1,12 @@
// ignore-tidy-linelength
// aux-build:unstable_generic_param.rs
extern crate unstable_generic_param;
use unstable_generic_param::*;
impl<T> Trait3<usize> for T where T: Trait2<usize> { //~ ERROR use of unstable library feature 'unstable_default'
fn foo() -> usize { T::foo() }
}
fn main() {}

View file

@ -0,0 +1,11 @@
error[E0658]: use of unstable library feature 'unstable_default'
--> $DIR/generics-default-stability-where.rs:8:45
|
LL | impl<T> Trait3<usize> for T where T: Trait2<usize> {
| ^^^^^
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -61,4 +61,19 @@ fn main() {
let _: usize = STRUCT2.field; // ok
let _ = STRUCT2.field + 1; // ok
let _ = STRUCT2.field + 1usize; // ok
let _ = STRUCT3;
let _: Struct3 = STRUCT3; // ok
let _: Struct3<isize, usize> = STRUCT3; //~ ERROR use of unstable library feature 'unstable_default'
let _: Struct3<isize> = STRUCT3; // ok
let _: Struct3<isize, isize> = Struct3 { field1: 0, field2: 0 }; //~ ERROR use of unstable library feature 'unstable_default'
let _: Struct3<usize, usize> = Struct3 { field1: 0, field2: 0 }; //~ ERROR use of unstable library feature 'unstable_default'
let _ = STRUCT3.field1; // ok
let _: isize = STRUCT3.field1; // ok
let _ = STRUCT3.field1 + 1; // ok
// Note the aforementioned leak.
let _: usize = STRUCT3.field2; // ok
let _: Struct3<usize> = Struct3 { field1: 0, field2: 0 }; // ok
let _ = STRUCT3.field2 + 1; // ok
let _ = STRUCT3.field2 + 1usize; // ok
}

View file

@ -46,6 +46,30 @@ LL | let _: Struct1<isize> = Struct1 { field: 0 };
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
error: aborting due to 6 previous errors
error[E0658]: use of unstable library feature 'unstable_default'
--> $DIR/generics-default-stability.rs:67:27
|
LL | let _: Struct3<isize, usize> = STRUCT3;
| ^^^^^
|
= 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:69:27
|
LL | let _: Struct3<isize, isize> = Struct3 { field1: 0, field2: 0 };
| ^^^^^
|
= 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:70:27
|
LL | let _: Struct3<usize, usize> = Struct3 { field1: 0, field2: 0 };
| ^^^^^
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0658`.