From a73e7d0a4df305e8b8237163e5ac7755cf488af8 Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Sun, 12 Jul 2020 20:56:37 -0400 Subject: [PATCH] Test unstable Alloc param on Box --- .../auxiliary/unstable_generic_param.rs | 36 ++++++++++++++++++- .../generics-default-stability.rs | 6 ++++ .../generics-default-stability.stderr | 10 +++++- 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 { + ptr: *mut T, + alloc: A, +} + +impl Box1 { + #[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 { + ptr: *mut T, + alloc: A, +} + +impl Box2 { + #[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 = Struct6 { field: 1 }; // ok let _: Struct6 = Struct6 { field: 0 }; // ok + + let _: Box1 = Box1::new(1); //~ ERROR use of unstable library feature 'box_alloc_param' + let _: Box1 = Box1::new(1); // ok + + let _: Box2 = Box2::new(1); // ok + let _: Box2 = 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 = 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 = 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 = 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`.