Skip to content

Commit 4c16052

Browse files
author
Dave Huseby
committed
---
yaml --- r: 235766 b: refs/heads/stable c: 01cb16d h: refs/heads/master v: v3
1 parent 8f0ec4c commit 4c16052

Some content is hidden

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

84 files changed

+682
-1952
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 5e6b534362de257603f8fc318eba78deb83206e3
32+
refs/heads/stable: 01cb16d1bf510ccd33db79a7c91843a662952822
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/liballoc/boxed.rs

Lines changed: 6 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,13 @@
5555

5656
use core::prelude::*;
5757

58-
use heap;
59-
6058
use core::any::Any;
6159
use core::cmp::Ordering;
6260
use core::fmt;
6361
use core::hash::{self, Hash};
64-
use core::marker::{self, Unsize};
62+
use core::marker::Unsize;
6563
use core::mem;
6664
use core::ops::{CoerceUnsized, Deref, DerefMut};
67-
use core::ops::{Placer, Boxed, Place, InPlace, BoxPlace};
6865
use core::ptr::Unique;
6966
use core::raw::{TraitObject};
7067

@@ -75,7 +72,7 @@ use core::raw::{TraitObject};
7572
///
7673
/// ```
7774
/// # #![feature(box_heap)]
78-
/// #![feature(box_syntax, placement_in_syntax)]
75+
/// #![feature(box_syntax)]
7976
/// use std::boxed::HEAP;
8077
///
8178
/// fn main() {
@@ -86,110 +83,15 @@ use core::raw::{TraitObject};
8683
#[lang = "exchange_heap"]
8784
#[unstable(feature = "box_heap",
8885
reason = "may be renamed; uncertain about custom allocator design")]
89-
pub const HEAP: ExchangeHeapSingleton =
90-
ExchangeHeapSingleton { _force_singleton: () };
91-
92-
/// This the singleton type used solely for `boxed::HEAP`.
93-
#[derive(Copy, Clone)]
94-
pub struct ExchangeHeapSingleton { _force_singleton: () }
86+
pub const HEAP: () = ();
9587

9688
/// A pointer type for heap allocation.
9789
///
9890
/// See the [module-level documentation](../../std/boxed/index.html) for more.
9991
#[lang = "owned_box"]
10092
#[stable(feature = "rust1", since = "1.0.0")]
10193
#[fundamental]
102-
pub struct Box<T: ?Sized>(Unique<T>);
103-
104-
/// `IntermediateBox` represents uninitialized backing storage for `Box`.
105-
///
106-
/// FIXME (pnkfelix): Ideally we would just reuse `Box<T>` instead of
107-
/// introducing a separate `IntermediateBox<T>`; but then you hit
108-
/// issues when you e.g. attempt to destructure an instance of `Box`,
109-
/// since it is a lang item and so it gets special handling by the
110-
/// compiler. Easier just to make this parallel type for now.
111-
///
112-
/// FIXME (pnkfelix): Currently the `box` protocol only supports
113-
/// creating instances of sized types. This IntermediateBox is
114-
/// designed to be forward-compatible with a future protocol that
115-
/// supports creating instances of unsized types; that is why the type
116-
/// parameter has the `?Sized` generalization marker, and is also why
117-
/// this carries an explicit size. However, it probably does not need
118-
/// to carry the explicit alignment; that is just a work-around for
119-
/// the fact that the `align_of` intrinsic currently requires the
120-
/// input type to be Sized (which I do not think is strictly
121-
/// necessary).
122-
#[unstable(feature = "placement_in", reason = "placement box design is still being worked out.")]
123-
pub struct IntermediateBox<T: ?Sized>{
124-
ptr: *mut u8,
125-
size: usize,
126-
align: usize,
127-
marker: marker::PhantomData<*mut T>,
128-
}
129-
130-
impl<T> Place<T> for IntermediateBox<T> {
131-
fn pointer(&mut self) -> *mut T {
132-
unsafe { ::core::mem::transmute(self.ptr) }
133-
}
134-
}
135-
136-
unsafe fn finalize<T>(b: IntermediateBox<T>) -> Box<T> {
137-
let p = b.ptr as *mut T;
138-
mem::forget(b);
139-
mem::transmute(p)
140-
}
141-
142-
fn make_place<T>() -> IntermediateBox<T> {
143-
let size = mem::size_of::<T>();
144-
let align = mem::align_of::<T>();
145-
146-
let p = if size == 0 {
147-
heap::EMPTY as *mut u8
148-
} else {
149-
let p = unsafe {
150-
heap::allocate(size, align)
151-
};
152-
if p.is_null() {
153-
panic!("Box make_place allocation failure.");
154-
}
155-
p
156-
};
157-
158-
IntermediateBox { ptr: p, size: size, align: align, marker: marker::PhantomData }
159-
}
160-
161-
impl<T> BoxPlace<T> for IntermediateBox<T> {
162-
fn make_place() -> IntermediateBox<T> { make_place() }
163-
}
164-
165-
impl<T> InPlace<T> for IntermediateBox<T> {
166-
type Owner = Box<T>;
167-
unsafe fn finalize(self) -> Box<T> { finalize(self) }
168-
}
169-
170-
impl<T> Boxed for Box<T> {
171-
type Data = T;
172-
type Place = IntermediateBox<T>;
173-
unsafe fn finalize(b: IntermediateBox<T>) -> Box<T> { finalize(b) }
174-
}
175-
176-
impl<T> Placer<T> for ExchangeHeapSingleton {
177-
type Place = IntermediateBox<T>;
178-
179-
fn make_place(self) -> IntermediateBox<T> {
180-
make_place()
181-
}
182-
}
183-
184-
impl<T: ?Sized> Drop for IntermediateBox<T> {
185-
fn drop(&mut self) {
186-
if self.size > 0 {
187-
unsafe {
188-
heap::deallocate(self.ptr, self.size, self.align)
189-
}
190-
}
191-
}
192-
}
94+
pub struct Box<T>(Unique<T>);
19395

19496
impl<T> Box<T> {
19597
/// Allocates memory on the heap and then moves `x` into it.
@@ -297,7 +199,8 @@ impl<T: Clone> Clone for Box<T> {
297199
/// let y = x.clone();
298200
/// ```
299201
#[inline]
300-
fn clone(&self) -> Box<T> { box (HEAP) {(**self).clone()} }
202+
fn clone(&self) -> Box<T> { box {(**self).clone()} }
203+
301204
/// Copies `source`'s contents into `self` without creating a new allocation.
302205
///
303206
/// # Examples

branches/stable/src/liballoc/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
test(no_crate_inject))]
7171
#![no_std]
7272

73-
// SNAP d4432b3
74-
#![allow(unused_features)] // until feature(placement_in_syntax) is in snap
7573
#![feature(allocator)]
7674
#![feature(box_syntax)]
7775
#![feature(coerce_unsized)]
@@ -84,8 +82,6 @@
8482
#![feature(no_std)]
8583
#![feature(nonzero)]
8684
#![feature(optin_builtin_traits)]
87-
#![feature(placement_in_syntax)]
88-
#![feature(placement_new_protocol)]
8985
#![feature(raw)]
9086
#![feature(staged_api)]
9187
#![feature(unboxed_closures)]

branches/stable/src/libcore/intrinsics.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,6 @@ extern "rust-intrinsic" {
184184
/// elements.
185185
pub fn size_of<T>() -> usize;
186186

187-
#[cfg(not(stage0))]
188-
/// Moves a value to an uninitialized memory location.
189-
///
190-
/// Drop glue is not run on the destination.
191-
pub fn move_val_init<T>(dst: *mut T, src: T);
192-
193-
// SNAP d4432b3
194-
#[cfg(stage0)]
195187
/// Moves a value to an uninitialized memory location.
196188
///
197189
/// Drop glue is not run on the destination.

branches/stable/src/libcore/ops.rs

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,120 +1266,3 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {}
12661266

12671267
// *const T -> *const U
12681268
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
1269-
1270-
/// Both `in (PLACE) EXPR` and `box EXPR` desugar into expressions
1271-
/// that allocate an intermediate "place" that holds uninitialized
1272-
/// state. The desugaring evaluates EXPR, and writes the result at
1273-
/// the address returned by the `pointer` method of this trait.
1274-
///
1275-
/// A `Place` can be thought of as a special representation for a
1276-
/// hypothetical `&uninit` reference (which Rust cannot currently
1277-
/// express directly). That is, it represents a pointer to
1278-
/// uninitialized storage.
1279-
///
1280-
/// The client is responsible for two steps: First, initializing the
1281-
/// payload (it can access its address via `pointer`). Second,
1282-
/// converting the agent to an instance of the owning pointer, via the
1283-
/// appropriate `finalize` method (see the `InPlace`.
1284-
///
1285-
/// If evaluating EXPR fails, then the destructor for the
1286-
/// implementation of Place to clean up any intermediate state
1287-
/// (e.g. deallocate box storage, pop a stack, etc).
1288-
#[unstable(feature = "placement_new_protocol")]
1289-
pub trait Place<Data: ?Sized> {
1290-
/// Returns the address where the input value will be written.
1291-
/// Note that the data at this address is generally uninitialized,
1292-
/// and thus one should use `ptr::write` for initializing it.
1293-
fn pointer(&mut self) -> *mut Data;
1294-
}
1295-
1296-
/// Interface to implementations of `in (PLACE) EXPR`.
1297-
///
1298-
/// `in (PLACE) EXPR` effectively desugars into:
1299-
///
1300-
/// ```rust,ignore
1301-
/// let p = PLACE;
1302-
/// let mut place = Placer::make_place(p);
1303-
/// let raw_place = Place::pointer(&mut place);
1304-
/// let value = EXPR;
1305-
/// unsafe {
1306-
/// std::ptr::write(raw_place, value);
1307-
/// InPlace::finalize(place)
1308-
/// }
1309-
/// ```
1310-
///
1311-
/// The type of `in (PLACE) EXPR` is derived from the type of `PLACE`;
1312-
/// if the type of `PLACE` is `P`, then the final type of the whole
1313-
/// expression is `P::Place::Owner` (see the `InPlace` and `Boxed`
1314-
/// traits).
1315-
///
1316-
/// Values for types implementing this trait usually are transient
1317-
/// intermediate values (e.g. the return value of `Vec::emplace_back`)
1318-
/// or `Copy`, since the `make_place` method takes `self` by value.
1319-
#[unstable(feature = "placement_new_protocol")]
1320-
pub trait Placer<Data: ?Sized> {
1321-
/// `Place` is the intermedate agent guarding the
1322-
/// uninitialized state for `Data`.
1323-
type Place: InPlace<Data>;
1324-
1325-
/// Creates a fresh place from `self`.
1326-
fn make_place(self) -> Self::Place;
1327-
}
1328-
1329-
/// Specialization of `Place` trait supporting `in (PLACE) EXPR`.
1330-
#[unstable(feature = "placement_new_protocol")]
1331-
pub trait InPlace<Data: ?Sized>: Place<Data> {
1332-
/// `Owner` is the type of the end value of `in (PLACE) EXPR`
1333-
///
1334-
/// Note that when `in (PLACE) EXPR` is solely used for
1335-
/// side-effecting an existing data-structure,
1336-
/// e.g. `Vec::emplace_back`, then `Owner` need not carry any
1337-
/// information at all (e.g. it can be the unit type `()` in that
1338-
/// case).
1339-
type Owner;
1340-
1341-
/// Converts self into the final value, shifting
1342-
/// deallocation/cleanup responsibilities (if any remain), over to
1343-
/// the returned instance of `Owner` and forgetting self.
1344-
unsafe fn finalize(self) -> Self::Owner;
1345-
}
1346-
1347-
/// Core trait for the `box EXPR` form.
1348-
///
1349-
/// `box EXPR` effectively desugars into:
1350-
///
1351-
/// ```rust,ignore
1352-
/// let mut place = BoxPlace::make_place();
1353-
/// let raw_place = Place::pointer(&mut place);
1354-
/// let value = EXPR;
1355-
/// unsafe {
1356-
/// ::std::ptr::write(raw_place, value);
1357-
/// Boxed::finalize(place)
1358-
/// }
1359-
/// ```
1360-
///
1361-
/// The type of `box EXPR` is supplied from its surrounding
1362-
/// context; in the above expansion, the result type `T` is used
1363-
/// to determine which implementation of `Boxed` to use, and that
1364-
/// `<T as Boxed>` in turn dictates determines which
1365-
/// implementation of `BoxPlace` to use, namely:
1366-
/// `<<T as Boxed>::Place as BoxPlace>`.
1367-
#[unstable(feature = "placement_new_protocol")]
1368-
pub trait Boxed {
1369-
/// The kind of data that is stored in this kind of box.
1370-
type Data; /* (`Data` unused b/c cannot yet express below bound.) */
1371-
/// The place that will negotiate the storage of the data.
1372-
type Place: BoxPlace<Self::Data>;
1373-
1374-
/// Converts filled place into final owning value, shifting
1375-
/// deallocation/cleanup responsibilities (if any remain), over to
1376-
/// returned instance of `Self` and forgetting `filled`.
1377-
unsafe fn finalize(filled: Self::Place) -> Self;
1378-
}
1379-
1380-
/// Specialization of `Place` trait supporting `box EXPR`.
1381-
#[unstable(feature = "placement_new_protocol")]
1382-
pub trait BoxPlace<Data: ?Sized> : Place<Data> {
1383-
/// Creates a globally fresh place.
1384-
fn make_place() -> Self;
1385-
}

branches/stable/src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,13 +564,8 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
564564
assert_eq!(next(st), '[');
565565
let did = parse_def_(st, ClosureSource, conv);
566566
let substs = parse_substs_(st, conv);
567-
let mut tys = vec![];
568-
while peek(st) != '.' {
569-
tys.push(parse_ty_(st, conv));
570-
}
571-
assert_eq!(next(st), '.');
572567
assert_eq!(next(st), ']');
573-
return st.tcx.mk_closure(did, st.tcx.mk_substs(substs), tys);
568+
return st.tcx.mk_closure(did, st.tcx.mk_substs(substs));
574569
}
575570
'P' => {
576571
assert_eq!(next(st), '[');

branches/stable/src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,9 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
143143
enc_substs(w, cx, substs);
144144
mywrite!(w, "]");
145145
}
146-
ty::TyClosure(def, ref substs) => {
146+
ty::TyClosure(def, substs) => {
147147
mywrite!(w, "k[{}|", (cx.ds)(def));
148-
enc_substs(w, cx, &substs.func_substs);
149-
for ty in &substs.upvar_tys {
150-
enc_ty(w, cx, ty);
151-
}
152-
mywrite!(w, ".");
148+
enc_substs(w, cx, substs);
153149
mywrite!(w, "]");
154150
}
155151
ty::TyProjection(ref data) => {

0 commit comments

Comments
 (0)