diff options
| author | Avi Dessauer <avi.the.coder@gmail.com> | 2020-07-12 20:56:37 -0400 |
|---|---|---|
| committer | Jacob Hughes <j@jacobhughes.me> | 2020-09-22 21:55:47 -0400 |
| commit | a73e7d0a4df305e8b8237163e5ac7755cf488af8 (patch) | |
| tree | 19d992721a2c5a863a692ab8bb4f98330eb8fb43 | |
| parent | 7616b30bff843ff279fae9ae4eea44b87d46b310 (diff) | |
Test unstable Alloc param on Box
3 files changed, 50 insertions, 2 deletions
diff --git a/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs b/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs index 82eed9a38f9..b26908c25e3 100644 --- a/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs +++ b/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs @@ -1,6 +1,5 @@ #![crate_type = "lib"] #![feature(staged_api)] - #![stable(feature = "stable_test_feature", since = "1.0.0")] #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -75,3 +74,38 @@ pub const STRUCT4: Struct4 = Struct4 { field: 1 }; #[stable(feature = "stable_test_feature", since = "1.0.0")] pub const STRUCT5: Struct5 = Struct5 { field: 1 }; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Alloc {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct System {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +impl Alloc for System {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Box1<T, #[unstable(feature = "box_alloc_param", issue = "none")] A: Alloc = System> { + ptr: *mut T, + alloc: A, +} + +impl<T> Box1<T, System> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new(mut t: T) -> Self { + unsafe { Self { ptr: &mut t, alloc: System {} } } + } +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Box2<T, A: Alloc = System> { + ptr: *mut T, + alloc: A, +} + +impl<T> Box2<T, System> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new(mut t: T) -> Self { + Self { ptr: &mut t, alloc: System {} } + } +} diff --git a/src/test/ui/stability-attribute/generics-default-stability.rs b/src/test/ui/stability-attribute/generics-default-stability.rs index 26f7692209f..d412aceb3a2 100644 --- a/src/test/ui/stability-attribute/generics-default-stability.rs +++ b/src/test/ui/stability-attribute/generics-default-stability.rs @@ -109,4 +109,10 @@ fn main() { let _: Struct6<isize> = Struct6 { field: 1 }; // ok let _: Struct6<isize> = Struct6 { field: 0 }; // ok + + let _: Box1<isize, System> = Box1::new(1); //~ ERROR use of unstable library feature 'box_alloc_param' + let _: Box1<isize> = Box1::new(1); // ok + + let _: Box2<isize, System> = Box2::new(1); // ok + let _: Box2<isize> = Box2::new(1); // ok } diff --git a/src/test/ui/stability-attribute/generics-default-stability.stderr b/src/test/ui/stability-attribute/generics-default-stability.stderr index d9e195c21d6..37a809f8bca 100644 --- a/src/test/ui/stability-attribute/generics-default-stability.stderr +++ b/src/test/ui/stability-attribute/generics-default-stability.stderr @@ -168,6 +168,14 @@ LL | let _: Struct5<isize> = Struct5 { field: 0 }; | = help: add `#![feature(unstable_default)]` to the crate attributes to enable +error[E0658]: use of unstable library feature 'box_alloc_param' + --> $DIR/generics-default-stability.rs:113:24 + | +LL | let _: Box1<isize, System> = Box1::new(1); + | ^^^^^^ + | + = help: add `#![feature(box_alloc_param)]` to the crate attributes to enable + warning: use of deprecated item 'unstable_generic_param::Struct4::field': test --> $DIR/generics-default-stability.rs:84:39 | @@ -192,6 +200,6 @@ warning: use of deprecated item 'unstable_generic_param::Struct5::field': test LL | let _: Struct5<isize> = Struct5 { field: 0 }; | ^^^^^^^^ -error: aborting due to 12 previous errors; 16 warnings emitted +error: aborting due to 13 previous errors; 16 warnings emitted For more information about this error, try `rustc --explain E0658`. |
