Permalink
Browse files

Remove all unstable placement features

  • Loading branch information...
aidanhs authored and Robbepop committed Feb 18, 2018
1 parent f0cf316 commit fee7908e2fbdc1ba04b5e7f9e4b532f4586bb7eb
Showing with 39 additions and 1,392 deletions.
  1. +0 −3 src/grammar/parser-lalr.y
  2. +1 −65 src/liballoc/binary_heap.rs
  3. +1 −150 src/liballoc/boxed.rs
  4. +4 −8 src/liballoc/lib.rs
  5. +2 −176 src/liballoc/linked_list.rs
  6. +0 −20 src/liballoc/tests/binary_heap.rs
  7. +0 −2 src/liballoc/tests/lib.rs
  8. +1 −19 src/liballoc/tests/vec.rs
  9. +0 −22 src/liballoc/tests/vec_deque.rs
  10. +1 −75 src/liballoc/vec.rs
  11. +1 −143 src/liballoc/vec_deque.rs
  12. +0 −4 src/libcore/ops/mod.rs
  13. +0 −143 src/libcore/ops/place.rs
  14. +0 −133 src/librustc/hir/lowering.rs
  15. +0 −1 src/librustc/ich/impls_syntax.rs
  16. +0 −1 src/librustc_lint/unused.rs
  17. +4 −3 src/librustc_mir/build/matches/test.rs
  18. +0 −2 src/librustc_mir/lib.rs
  19. +0 −10 src/librustc_typeck/diagnostics.rs
  20. +1 −150 src/libstd/collections/hash/map.rs
  21. +0 −26 src/libstd/collections/hash/table.rs
  22. +0 −1 src/libstd/lib.rs
  23. +0 −3 src/libsyntax/ast.rs
  24. +0 −7 src/libsyntax/feature_gate.rs
  25. +0 −3 src/libsyntax/fold.rs
  26. +0 −13 src/libsyntax/parse/parser.rs
  27. +0 −13 src/libsyntax/print/pprust.rs
  28. +4 −10 src/libsyntax/util/parser.rs
  29. +0 −4 src/libsyntax/visit.rs
  30. +0 −2 src/libsyntax_pos/hygiene.rs
  31. +0 −17 src/test/compile-fail/issue-14084.rs
  32. +0 −24 src/test/compile-fail/placement-expr-unsafe.rs
  33. +0 −21 src/test/compile-fail/placement-expr-unstable.rs
  34. +1 −2 src/test/parse-fail/assoc-oddities-1.rs
  35. +0 −1 src/test/pretty/stmt_expr_attributes.rs
  36. +0 −10 src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs
  37. +16 −23 src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs
  38. +2 −8 src/test/run-pass/new-box-syntax.rs
  39. +0 −37 src/test/run-pass/placement-in-syntax.rs
  40. +0 −26 src/test/ui/feature-gate-placement-expr.rs
  41. +0 −11 src/test/ui/feature-gate-placement-expr.stderr
@@ -1400,7 +1400,6 @@ nonblock_expr
| BREAK lifetime { $$ = mk_node("ExprBreak", 1, $2); }
| YIELD { $$ = mk_node("ExprYield", 0); }
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
| nonblock_expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
| nonblock_expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
| nonblock_expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
| nonblock_expr SHREQ expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
@@ -1463,7 +1462,6 @@ expr
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
| YIELD { $$ = mk_node("ExprYield", 0); }
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
| expr LARROW expr { $$ = mk_node("ExprInPlace", 2, $1, $3); }
| expr '=' expr { $$ = mk_node("ExprAssign", 2, $1, $3); }
| expr SHLEQ expr { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
| expr SHREQ expr { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
@@ -1527,7 +1525,6 @@ expr_nostruct
| BREAK ident { $$ = mk_node("ExprBreak", 1, $2); }
| YIELD { $$ = mk_node("ExprYield", 0); }
| YIELD expr { $$ = mk_node("ExprYield", 1, $2); }
| expr_nostruct LARROW expr_nostruct { $$ = mk_node("ExprInPlace", 2, $1, $3); }
| expr_nostruct '=' expr_nostruct { $$ = mk_node("ExprAssign", 2, $1, $3); }
| expr_nostruct SHLEQ expr_nostruct { $$ = mk_node("ExprAssignShl", 2, $1, $3); }
| expr_nostruct SHREQ expr_nostruct { $$ = mk_node("ExprAssignShr", 2, $1, $3); }
@@ -155,7 +155,7 @@
#![allow(missing_docs)]
#![stable(feature = "rust1", since = "1.0.0")]

use core::ops::{Deref, DerefMut, Place, Placer, InPlace};
use core::ops::{Deref, DerefMut};
use core::iter::{FromIterator, FusedIterator};
use core::mem::{swap, size_of};
use core::ptr;
@@ -1195,67 +1195,3 @@ impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BinaryHeap<T> {
self.extend(iter.into_iter().cloned());
}
}

#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
pub struct BinaryHeapPlace<'a, T: 'a>
where T: Clone + Ord {
heap: *mut BinaryHeap<T>,
place: vec::PlaceBack<'a, T>,
}

#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
impl<'a, T: Clone + Ord + fmt::Debug> fmt::Debug for BinaryHeapPlace<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("BinaryHeapPlace")
.field(&self.place)
.finish()
}
}

#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
impl<'a, T: 'a> Placer<T> for &'a mut BinaryHeap<T>
where T: Clone + Ord {
type Place = BinaryHeapPlace<'a, T>;

fn make_place(self) -> Self::Place {
let ptr = self as *mut BinaryHeap<T>;
let place = Placer::make_place(self.data.place_back());
BinaryHeapPlace {
heap: ptr,
place,
}
}
}

#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
unsafe impl<'a, T> Place<T> for BinaryHeapPlace<'a, T>
where T: Clone + Ord {
fn pointer(&mut self) -> *mut T {
self.place.pointer()
}
}

#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
impl<'a, T> InPlace<T> for BinaryHeapPlace<'a, T>
where T: Clone + Ord {
type Owner = &'a T;

unsafe fn finalize(self) -> &'a T {
self.place.finalize();

let heap: &mut BinaryHeap<T> = &mut *self.heap;
let len = heap.len();
let i = heap.sift_up(0, len - 1);
heap.data.get_unchecked(i)
}
}
@@ -55,55 +55,21 @@

#![stable(feature = "rust1", since = "1.0.0")]

use heap::Heap;
use raw_vec::RawVec;

use core::any::Any;
use core::borrow;
use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::heap::{Alloc, Layout};
use core::iter::FusedIterator;
use core::marker::{self, Unpin, Unsize};
use core::marker::{Unpin, Unsize};
use core::mem::{self, Pin};
use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState};
use core::ops::{BoxPlace, Boxed, InPlace, Place, Placer};
use core::ptr::{self, NonNull, Unique};
use core::convert::From;
use str::from_boxed_utf8_unchecked;

/// A value that represents the heap. This is the default place that the `box`
/// keyword allocates into when no place is supplied.
///
/// The following two examples are equivalent:
///
/// ```
/// #![feature(box_heap)]
///
/// #![feature(box_syntax, placement_in_syntax)]
/// use std::boxed::HEAP;
///
/// fn main() {
/// let foo: Box<i32> = in HEAP { 5 };
/// let foo = box 5;
/// }
/// ```
#[unstable(feature = "box_heap",
reason = "may be renamed; uncertain about custom allocator design",
issue = "27779")]
pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () };

/// This the singleton type used solely for `boxed::HEAP`.
#[unstable(feature = "box_heap",
reason = "may be renamed; uncertain about custom allocator design",
issue = "27779")]
#[allow(missing_debug_implementations)]
#[derive(Copy, Clone)]
pub struct ExchangeHeapSingleton {
_force_singleton: (),
}

/// A pointer type for heap allocation.
///
/// See the [module-level documentation](../../std/boxed/index.html) for more.
@@ -112,121 +78,6 @@ pub struct ExchangeHeapSingleton {
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Box<T: ?Sized>(Unique<T>);

/// `IntermediateBox` represents uninitialized backing storage for `Box`.
///
/// FIXME (pnkfelix): Ideally we would just reuse `Box<T>` instead of
/// introducing a separate `IntermediateBox<T>`; but then you hit
/// issues when you e.g. attempt to destructure an instance of `Box`,
/// since it is a lang item and so it gets special handling by the
/// compiler. Easier just to make this parallel type for now.
///
/// FIXME (pnkfelix): Currently the `box` protocol only supports
/// creating instances of sized types. This IntermediateBox is
/// designed to be forward-compatible with a future protocol that
/// supports creating instances of unsized types; that is why the type
/// parameter has the `?Sized` generalization marker, and is also why
/// this carries an explicit size. However, it probably does not need
/// to carry the explicit alignment; that is just a work-around for
/// the fact that the `align_of` intrinsic currently requires the
/// input type to be Sized (which I do not think is strictly
/// necessary).
#[unstable(feature = "placement_in",
reason = "placement box design is still being worked out.",
issue = "27779")]
#[allow(missing_debug_implementations)]
pub struct IntermediateBox<T: ?Sized> {
ptr: *mut u8,
layout: Layout,
marker: marker::PhantomData<*mut T>,
}

#[unstable(feature = "placement_in",
reason = "placement box design is still being worked out.",
issue = "27779")]
unsafe impl<T> Place<T> for IntermediateBox<T> {
fn pointer(&mut self) -> *mut T {
self.ptr as *mut T
}
}

unsafe fn finalize<T>(b: IntermediateBox<T>) -> Box<T> {
let p = b.ptr as *mut T;
mem::forget(b);
Box::from_raw(p)
}

fn make_place<T>() -> IntermediateBox<T> {
let layout = Layout::new::<T>();

let p = if layout.size() == 0 {
mem::align_of::<T>() as *mut u8
} else {
unsafe {
Heap.alloc(layout.clone()).unwrap_or_else(|err| {
Heap.oom(err)
})
}
};

IntermediateBox {
ptr: p,
layout,
marker: marker::PhantomData,
}
}

#[unstable(feature = "placement_in",
reason = "placement box design is still being worked out.",
issue = "27779")]
impl<T> BoxPlace<T> for IntermediateBox<T> {
fn make_place() -> IntermediateBox<T> {
make_place()
}
}

#[unstable(feature = "placement_in",
reason = "placement box design is still being worked out.",
issue = "27779")]
impl<T> InPlace<T> for IntermediateBox<T> {
type Owner = Box<T>;
unsafe fn finalize(self) -> Box<T> {
finalize(self)
}
}

#[unstable(feature = "placement_new_protocol", issue = "27779")]
impl<T> Boxed for Box<T> {
type Data = T;
type Place = IntermediateBox<T>;
unsafe fn finalize(b: IntermediateBox<T>) -> Box<T> {
finalize(b)
}
}

#[unstable(feature = "placement_in",
reason = "placement box design is still being worked out.",
issue = "27779")]
impl<T> Placer<T> for ExchangeHeapSingleton {
type Place = IntermediateBox<T>;

fn make_place(self) -> IntermediateBox<T> {
make_place()
}
}

#[unstable(feature = "placement_in",
reason = "placement box design is still being worked out.",
issue = "27779")]
impl<T: ?Sized> Drop for IntermediateBox<T> {
fn drop(&mut self) {
if self.layout.size() > 0 {
unsafe {
Heap.dealloc(self.ptr, self.layout.clone())
}
}
}
}

impl<T> Box<T> {
/// Allocates memory on the heap and then places `x` into it.
///
@@ -76,7 +76,6 @@
#![deny(missing_debug_implementations)]

#![cfg_attr(test, allow(deprecated))] // rand
#![cfg_attr(test, feature(placement_in))]
#![cfg_attr(not(test), feature(core_float))]
#![cfg_attr(not(test), feature(exact_size_is_empty))]
#![cfg_attr(not(test), feature(generator_trait))]
@@ -108,8 +107,6 @@
#![feature(optin_builtin_traits)]
#![feature(pattern)]
#![feature(pin)]
#![feature(placement_in_syntax)]
#![feature(placement_new_protocol)]
#![feature(ptr_internals)]
#![feature(rustc_attrs)]
#![feature(slice_get_slice)]
@@ -128,8 +125,8 @@
#![feature(pointer_methods)]
#![feature(inclusive_range_fields)]

#![cfg_attr(not(test), feature(fn_traits, placement_new_protocol, swap_with_slice, i128))]
#![cfg_attr(test, feature(test, box_heap))]
#![cfg_attr(not(test), feature(fn_traits, swap_with_slice, i128))]
#![cfg_attr(test, feature(test))]

// Allow testing this library

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

// Need to conditionally define the mod from `boxed.rs` to avoid
// duplicating the lang-items when building in test cfg; but also need
// to allow code to have `use boxed::HEAP;`
// and `use boxed::Box;` declarations.
// to allow code to have `use boxed::Box;` declarations.
#[cfg(not(test))]
pub mod boxed;
#[cfg(test)]
mod boxed {
pub use std::boxed::{Box, IntermediateBox, HEAP};
pub use std::boxed::Box;
}
#[cfg(test)]
mod boxed_test;
Oops, something went wrong.

0 comments on commit fee7908

Please sign in to comment.