Skip to content

Commit 9b5859a

Browse files
aidanhsSimonSapin
authored andcommitted
Remove all unstable placement features
Closes #22181, #27779
1 parent 5ee891c commit 9b5859a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+39
-1392
lines changed

src/grammar/parser-lalr.y

-3
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,6 @@ nonblock_expr
14001400
| BREAK lifetime { $$ = mk_node("ExprBreak", 1, $2); }
14011401
| YIELD { $$ = mk_node("ExprYield", 0); }
14021402
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
1403-
| nonblock_expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
14041403
| nonblock_expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
14051404
| nonblock_expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
14061405
| nonblock_expr SHREQ expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
@@ -1463,7 +1462,6 @@ expr
14631462
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
14641463
| YIELD { $$ = mk_node("ExprYield", 0); }
14651464
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
1466-
| expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
14671465
| expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
14681466
| expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
14691467
| expr SHREQ expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
@@ -1527,7 +1525,6 @@ expr_nostruct
15271525
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
15281526
| YIELD { $$ = mk_node("ExprYield", 0); }
15291527
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
1530-
| expr_nostruct LARROW expr_nostruct { $$ = mk_node("ExprInPlace", 2, $1, $3); }
15311528
| expr_nostruct '=' expr_nostruct { $$ = mk_node("ExprAssign", 2, $1, $3); }
15321529
| expr_nostruct SHLEQ expr_nostruct { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
15331530
| expr_nostruct SHREQ expr_nostruct { $$ = mk_node("ExprAssignShr", 2, $1, $3); }

src/liballoc/binary_heap.rs

+1-65
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
#![allow(missing_docs)]
156156
#![stable(feature = "rust1", since = "1.0.0")]
157157

158-
use core::ops::{Deref, DerefMut, Place, Placer, InPlace};
158+
use core::ops::{Deref, DerefMut};
159159
use core::iter::{FromIterator, FusedIterator};
160160
use core::mem::{swap, size_of};
161161
use core::ptr;
@@ -1195,67 +1195,3 @@ impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BinaryHeap<T> {
11951195
self.extend(iter.into_iter().cloned());
11961196
}
11971197
}
1198-
1199-
#[unstable(feature = "collection_placement",
1200-
reason = "placement protocol is subject to change",
1201-
issue = "30172")]
1202-
pub struct BinaryHeapPlace<'a, T: 'a>
1203-
where T: Clone + Ord {
1204-
heap: *mut BinaryHeap<T>,
1205-
place: vec::PlaceBack<'a, T>,
1206-
}
1207-
1208-
#[unstable(feature = "collection_placement",
1209-
reason = "placement protocol is subject to change",
1210-
issue = "30172")]
1211-
impl<'a, T: Clone + Ord + fmt::Debug> fmt::Debug for BinaryHeapPlace<'a, T> {
1212-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1213-
f.debug_tuple("BinaryHeapPlace")
1214-
.field(&self.place)
1215-
.finish()
1216-
}
1217-
}
1218-
1219-
#[unstable(feature = "collection_placement",
1220-
reason = "placement protocol is subject to change",
1221-
issue = "30172")]
1222-
impl<'a, T: 'a> Placer<T> for &'a mut BinaryHeap<T>
1223-
where T: Clone + Ord {
1224-
type Place = BinaryHeapPlace<'a, T>;
1225-
1226-
fn make_place(self) -> Self::Place {
1227-
let ptr = self as *mut BinaryHeap<T>;
1228-
let place = Placer::make_place(self.data.place_back());
1229-
BinaryHeapPlace {
1230-
heap: ptr,
1231-
place,
1232-
}
1233-
}
1234-
}
1235-
1236-
#[unstable(feature = "collection_placement",
1237-
reason = "placement protocol is subject to change",
1238-
issue = "30172")]
1239-
unsafe impl<'a, T> Place<T> for BinaryHeapPlace<'a, T>
1240-
where T: Clone + Ord {
1241-
fn pointer(&mut self) -> *mut T {
1242-
self.place.pointer()
1243-
}
1244-
}
1245-
1246-
#[unstable(feature = "collection_placement",
1247-
reason = "placement protocol is subject to change",
1248-
issue = "30172")]
1249-
impl<'a, T> InPlace<T> for BinaryHeapPlace<'a, T>
1250-
where T: Clone + Ord {
1251-
type Owner = &'a T;
1252-
1253-
unsafe fn finalize(self) -> &'a T {
1254-
self.place.finalize();
1255-
1256-
let heap: &mut BinaryHeap<T> = &mut *self.heap;
1257-
let len = heap.len();
1258-
let i = heap.sift_up(0, len - 1);
1259-
heap.data.get_unchecked(i)
1260-
}
1261-
}

src/liballoc/boxed.rs

+1-150
Original file line numberDiff line numberDiff line change
@@ -55,55 +55,21 @@
5555
5656
#![stable(feature = "rust1", since = "1.0.0")]
5757

58-
use heap::Heap;
5958
use raw_vec::RawVec;
6059

6160
use core::any::Any;
6261
use core::borrow;
6362
use core::cmp::Ordering;
6463
use core::fmt;
6564
use core::hash::{Hash, Hasher};
66-
use core::heap::{Alloc, Layout};
6765
use core::iter::FusedIterator;
68-
use core::marker::{self, Unpin, Unsize};
66+
use core::marker::{Unpin, Unsize};
6967
use core::mem::{self, Pin};
7068
use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState};
71-
use core::ops::{BoxPlace, Boxed, InPlace, Place, Placer};
7269
use core::ptr::{self, NonNull, Unique};
7370
use core::convert::From;
7471
use str::from_boxed_utf8_unchecked;
7572

76-
/// A value that represents the heap. This is the default place that the `box`
77-
/// keyword allocates into when no place is supplied.
78-
///
79-
/// The following two examples are equivalent:
80-
///
81-
/// ```
82-
/// #![feature(box_heap)]
83-
///
84-
/// #![feature(box_syntax, placement_in_syntax)]
85-
/// use std::boxed::HEAP;
86-
///
87-
/// fn main() {
88-
/// let foo: Box<i32> = in HEAP { 5 };
89-
/// let foo = box 5;
90-
/// }
91-
/// ```
92-
#[unstable(feature = "box_heap",
93-
reason = "may be renamed; uncertain about custom allocator design",
94-
issue = "27779")]
95-
pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () };
96-
97-
/// This the singleton type used solely for `boxed::HEAP`.
98-
#[unstable(feature = "box_heap",
99-
reason = "may be renamed; uncertain about custom allocator design",
100-
issue = "27779")]
101-
#[allow(missing_debug_implementations)]
102-
#[derive(Copy, Clone)]
103-
pub struct ExchangeHeapSingleton {
104-
_force_singleton: (),
105-
}
106-
10773
/// A pointer type for heap allocation.
10874
///
10975
/// See the [module-level documentation](../../std/boxed/index.html) for more.
@@ -112,121 +78,6 @@ pub struct ExchangeHeapSingleton {
11278
#[stable(feature = "rust1", since = "1.0.0")]
11379
pub struct Box<T: ?Sized>(Unique<T>);
11480

115-
/// `IntermediateBox` represents uninitialized backing storage for `Box`.
116-
///
117-
/// FIXME (pnkfelix): Ideally we would just reuse `Box<T>` instead of
118-
/// introducing a separate `IntermediateBox<T>`; but then you hit
119-
/// issues when you e.g. attempt to destructure an instance of `Box`,
120-
/// since it is a lang item and so it gets special handling by the
121-
/// compiler. Easier just to make this parallel type for now.
122-
///
123-
/// FIXME (pnkfelix): Currently the `box` protocol only supports
124-
/// creating instances of sized types. This IntermediateBox is
125-
/// designed to be forward-compatible with a future protocol that
126-
/// supports creating instances of unsized types; that is why the type
127-
/// parameter has the `?Sized` generalization marker, and is also why
128-
/// this carries an explicit size. However, it probably does not need
129-
/// to carry the explicit alignment; that is just a work-around for
130-
/// the fact that the `align_of` intrinsic currently requires the
131-
/// input type to be Sized (which I do not think is strictly
132-
/// necessary).
133-
#[unstable(feature = "placement_in",
134-
reason = "placement box design is still being worked out.",
135-
issue = "27779")]
136-
#[allow(missing_debug_implementations)]
137-
pub struct IntermediateBox<T: ?Sized> {
138-
ptr: *mut u8,
139-
layout: Layout,
140-
marker: marker::PhantomData<*mut T>,
141-
}
142-
143-
#[unstable(feature = "placement_in",
144-
reason = "placement box design is still being worked out.",
145-
issue = "27779")]
146-
unsafe impl<T> Place<T> for IntermediateBox<T> {
147-
fn pointer(&mut self) -> *mut T {
148-
self.ptr as *mut T
149-
}
150-
}
151-
152-
unsafe fn finalize<T>(b: IntermediateBox<T>) -> Box<T> {
153-
let p = b.ptr as *mut T;
154-
mem::forget(b);
155-
Box::from_raw(p)
156-
}
157-
158-
fn make_place<T>() -> IntermediateBox<T> {
159-
let layout = Layout::new::<T>();
160-
161-
let p = if layout.size() == 0 {
162-
mem::align_of::<T>() as *mut u8
163-
} else {
164-
unsafe {
165-
Heap.alloc(layout.clone()).unwrap_or_else(|err| {
166-
Heap.oom(err)
167-
})
168-
}
169-
};
170-
171-
IntermediateBox {
172-
ptr: p,
173-
layout,
174-
marker: marker::PhantomData,
175-
}
176-
}
177-
178-
#[unstable(feature = "placement_in",
179-
reason = "placement box design is still being worked out.",
180-
issue = "27779")]
181-
impl<T> BoxPlace<T> for IntermediateBox<T> {
182-
fn make_place() -> IntermediateBox<T> {
183-
make_place()
184-
}
185-
}
186-
187-
#[unstable(feature = "placement_in",
188-
reason = "placement box design is still being worked out.",
189-
issue = "27779")]
190-
impl<T> InPlace<T> for IntermediateBox<T> {
191-
type Owner = Box<T>;
192-
unsafe fn finalize(self) -> Box<T> {
193-
finalize(self)
194-
}
195-
}
196-
197-
#[unstable(feature = "placement_new_protocol", issue = "27779")]
198-
impl<T> Boxed for Box<T> {
199-
type Data = T;
200-
type Place = IntermediateBox<T>;
201-
unsafe fn finalize(b: IntermediateBox<T>) -> Box<T> {
202-
finalize(b)
203-
}
204-
}
205-
206-
#[unstable(feature = "placement_in",
207-
reason = "placement box design is still being worked out.",
208-
issue = "27779")]
209-
impl<T> Placer<T> for ExchangeHeapSingleton {
210-
type Place = IntermediateBox<T>;
211-
212-
fn make_place(self) -> IntermediateBox<T> {
213-
make_place()
214-
}
215-
}
216-
217-
#[unstable(feature = "placement_in",
218-
reason = "placement box design is still being worked out.",
219-
issue = "27779")]
220-
impl<T: ?Sized> Drop for IntermediateBox<T> {
221-
fn drop(&mut self) {
222-
if self.layout.size() > 0 {
223-
unsafe {
224-
Heap.dealloc(self.ptr, self.layout.clone())
225-
}
226-
}
227-
}
228-
}
229-
23081
impl<T> Box<T> {
23182
/// Allocates memory on the heap and then places `x` into it.
23283
///

src/liballoc/lib.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
#![deny(missing_debug_implementations)]
7777

7878
#![cfg_attr(test, allow(deprecated))] // rand
79-
#![cfg_attr(test, feature(placement_in))]
8079
#![cfg_attr(not(test), feature(core_float))]
8180
#![cfg_attr(not(test), feature(exact_size_is_empty))]
8281
#![cfg_attr(not(test), feature(generator_trait))]
@@ -108,8 +107,6 @@
108107
#![feature(optin_builtin_traits)]
109108
#![feature(pattern)]
110109
#![feature(pin)]
111-
#![feature(placement_in_syntax)]
112-
#![feature(placement_new_protocol)]
113110
#![feature(ptr_internals)]
114111
#![feature(rustc_attrs)]
115112
#![feature(slice_get_slice)]
@@ -128,8 +125,8 @@
128125
#![feature(pointer_methods)]
129126
#![feature(inclusive_range_fields)]
130127

131-
#![cfg_attr(not(test), feature(fn_traits, placement_new_protocol, swap_with_slice, i128))]
132-
#![cfg_attr(test, feature(test, box_heap))]
128+
#![cfg_attr(not(test), feature(fn_traits, swap_with_slice, i128))]
129+
#![cfg_attr(test, feature(test))]
133130

134131
// Allow testing this library
135132

@@ -159,13 +156,12 @@ pub mod heap;
159156

160157
// Need to conditionally define the mod from `boxed.rs` to avoid
161158
// duplicating the lang-items when building in test cfg; but also need
162-
// to allow code to have `use boxed::HEAP;`
163-
// and `use boxed::Box;` declarations.
159+
// to allow code to have `use boxed::Box;` declarations.
164160
#[cfg(not(test))]
165161
pub mod boxed;
166162
#[cfg(test)]
167163
mod boxed {
168-
pub use std::boxed::{Box, IntermediateBox, HEAP};
164+
pub use std::boxed::Box;
169165
}
170166
#[cfg(test)]
171167
mod boxed_test;

0 commit comments

Comments
 (0)