Skip to content

Commit a73e7d0

Browse files
Avi-D-coderJacob Hughes
authored and
Jacob Hughes
committed
Test unstable Alloc param on Box
1 parent 7616b30 commit a73e7d0

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![crate_type = "lib"]
22
#![feature(staged_api)]
3-
43
#![stable(feature = "stable_test_feature", since = "1.0.0")]
54

65
#[stable(feature = "stable_test_feature", since = "1.0.0")]
@@ -75,3 +74,38 @@ pub const STRUCT4: Struct4 = Struct4 { field: 1 };
7574

7675
#[stable(feature = "stable_test_feature", since = "1.0.0")]
7776
pub const STRUCT5: Struct5 = Struct5 { field: 1 };
77+
78+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
79+
pub trait Alloc {}
80+
81+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
82+
pub struct System {}
83+
84+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
85+
impl Alloc for System {}
86+
87+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
88+
pub struct Box1<T, #[unstable(feature = "box_alloc_param", issue = "none")] A: Alloc = System> {
89+
ptr: *mut T,
90+
alloc: A,
91+
}
92+
93+
impl<T> Box1<T, System> {
94+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
95+
pub fn new(mut t: T) -> Self {
96+
unsafe { Self { ptr: &mut t, alloc: System {} } }
97+
}
98+
}
99+
100+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
101+
pub struct Box2<T, A: Alloc = System> {
102+
ptr: *mut T,
103+
alloc: A,
104+
}
105+
106+
impl<T> Box2<T, System> {
107+
#[stable(feature = "stable_test_feature", since = "1.0.0")]
108+
pub fn new(mut t: T) -> Self {
109+
Self { ptr: &mut t, alloc: System {} }
110+
}
111+
}

src/test/ui/stability-attribute/generics-default-stability.rs

+6
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,10 @@ fn main() {
109109

110110
let _: Struct6<isize> = Struct6 { field: 1 }; // ok
111111
let _: Struct6<isize> = Struct6 { field: 0 }; // ok
112+
113+
let _: Box1<isize, System> = Box1::new(1); //~ ERROR use of unstable library feature 'box_alloc_param'
114+
let _: Box1<isize> = Box1::new(1); // ok
115+
116+
let _: Box2<isize, System> = Box2::new(1); // ok
117+
let _: Box2<isize> = Box2::new(1); // ok
112118
}

src/test/ui/stability-attribute/generics-default-stability.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ LL | let _: Struct5<isize> = Struct5 { field: 0 };
168168
|
169169
= help: add `#![feature(unstable_default)]` to the crate attributes to enable
170170

171+
error[E0658]: use of unstable library feature 'box_alloc_param'
172+
--> $DIR/generics-default-stability.rs:113:24
173+
|
174+
LL | let _: Box1<isize, System> = Box1::new(1);
175+
| ^^^^^^
176+
|
177+
= help: add `#![feature(box_alloc_param)]` to the crate attributes to enable
178+
171179
warning: use of deprecated item 'unstable_generic_param::Struct4::field': test
172180
--> $DIR/generics-default-stability.rs:84:39
173181
|
@@ -192,6 +200,6 @@ warning: use of deprecated item 'unstable_generic_param::Struct5::field': test
192200
LL | let _: Struct5<isize> = Struct5 { field: 0 };
193201
| ^^^^^^^^
194202

195-
error: aborting due to 12 previous errors; 16 warnings emitted
203+
error: aborting due to 13 previous errors; 16 warnings emitted
196204

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

0 commit comments

Comments
 (0)