summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-04-04 01:06:35 +0000
committerbors <bors@rust-lang.org>2018-04-04 01:06:35 +0000
commit199b7e211d6d9173fded261e0a4de984efc0c2eb (patch)
treef019fd913e56676cfb5d71b6676db89bee30fcf6 /src/libcore
parentc75d5e242fa5c745a89e5d9541e3cc737d269061 (diff)
parent9b5859aea199d5f34a4d4b5ae7112c5c41f3b242 (diff)
downloadrust-199b7e211d6d9173fded261e0a4de984efc0c2eb.tar.gz
rust-199b7e211d6d9173fded261e0a4de984efc0c2eb.zip
Auto merge of #48333 - aidanhs:aphs-no-place-for-placement, r=nikomatsakis
Remove all unstable placement features

Closes #22181, #27779. Effectively makes the assortment of placement RFCs (rust-lang/rfcs#470, rust-lang/rfcs#809, rust-lang/rfcs#1228) 'unaccepted'. It leaves `box_syntax` and keeps the `<-` token as recognised by libsyntax.

------------------------

I don't know the correct process for unaccepting an unstable feature that was accepted as an RFC so...here's a PR.

Let me preface this by saying I'm not particularly happy about doing this (I know it'll be unpopular), but I think it's the most honest expression of how things stand today. I've been motivated by a [post on reddit](https://www.reddit.com/r/rust/comments/7wrqk2/when_will_box_and_placementin_syntax_be_stable/) which asks when these features will be stable - the features have received little RFC-style design work since the end of 2015 (~2 years ago) and leaving them in limbo confuses people who want to know where they're up to. Without additional design work that needs to happen (see the collection of unresolved questions later in this post) they can't really get stabilised, and I think that design work would be most suited to an RFC rather than (currently mostly unused) experimental features in Rust nightly.

I have my own motivations - it's very simple to 'defeat' placement in debug mode today and I don't want a placement in Rust that a) has no guarantees to work and b) has no plan for in-place serde deserialisation.

There's a quote in [1]: "Ordinarily these uncertainties might lead to the RFC being postponed. [The RFC seems like a promising direction hence we will accept since it] will thus give us immediate experience with the design and help in determining the best final solution.". I propose that there have been enough additional uncertainties raised since then that the original direction is less promising and we should be think about the problem anew.

(a historical note: the first mention of placement (under that name - uninit pointers were earlier) in an RFC AFAIK is [0] in late 2014 (pre-1.0). RFCs since then have built on this base - [1] is a comment in Feb 2015 accepting a more conservative design of the Place* traits - this is back when serde still required aster and seemed to break every other nightly! A lot has changed since then, perhaps placement should too)

------------------------

Concrete unresolved questions include:

 - making placement work in debug mode [7]
 - making placement work for serde/with fallible creation [5], [irlo2], [8]
 - trait design:
   - opting into not consuming the placer in `Placer::make_place` - [2]
   - trait proliferation - [4] (+ others in that thread)
   - fallible allocation - [3], [4] (+ others in that thread)
 - support for DSTs/unsized structs (if at all) - [1], [6]

More speculative unresolved questions include:

 - better trait design with in the context of future language features [irlo1] (Q11), [irlo3]
 - interaction between custom allocators and placement [irlo3]

[0] https://github.com/rust-lang/rfcs/pull/470
[1] https://github.com/rust-lang/rfcs/pull/809#issuecomment-73910414
[2] https://github.com/rust-lang/rfcs/issues/1286
[3] https://github.com/rust-lang/rfcs/issues/1315
[4] https://github.com/rust-lang/rust/issues/27779#issuecomment-146711893
[5] https://github.com/rust-lang/rust/issues/27779#issuecomment-285562402
[6] https://github.com/rust-lang/rust/issues/27779#issuecomment-354464938
[7] https://github.com/rust-lang/rust/issues/27779#issuecomment-358025344
[8] https://github.com/rust-lang/rfcs/pull/1228#issuecomment-190825370
[irlo1] https://internals.rust-lang.org/t/placement-nwbi-faq-new-box-in-left-arrow/2789
[irlo2] https://internals.rust-lang.org/t/placement-nwbi-faq-new-box-in-left-arrow/2789/19
[irlo3] https://internals.rust-lang.org/t/lang-team-minutes-feature-status-report-placement-in-and-box/4646
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/ops/mod.rs4
-rw-r--r--src/libcore/ops/place.rs143
2 files changed, 0 insertions, 147 deletions
diff --git a/src/libcore/ops/mod.rs b/src/libcore/ops/mod.rs
index 0b480b618fc..ce4f45762de 100644
--- a/src/libcore/ops/mod.rs
+++ b/src/libcore/ops/mod.rs
@@ -161,7 +161,6 @@ mod drop;
 mod function;
 mod generator;
 mod index;
-mod place;
 mod range;
 mod try;
 mod unsize;
@@ -200,8 +199,5 @@ pub use self::try::Try;
 #[unstable(feature = "generator_trait", issue = "43122")]
 pub use self::generator::{Generator, GeneratorState};
 
-#[unstable(feature = "placement_new_protocol", issue = "27779")]
-pub use self::place::{Place, Placer, InPlace, Boxed, BoxPlace};
-
 #[unstable(feature = "coerce_unsized", issue = "27732")]
 pub use self::unsize::CoerceUnsized;
diff --git a/src/libcore/ops/place.rs b/src/libcore/ops/place.rs
deleted file mode 100644
index b3dcf4e7ee9..00000000000
--- a/src/libcore/ops/place.rs
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/// Both `PLACE <- EXPR` and `box EXPR` desugar into expressions
-/// that allocate an intermediate "place" that holds uninitialized
-/// state.  The desugaring evaluates EXPR, and writes the result at
-/// the address returned by the `pointer` method of this trait.
-///
-/// A `Place` can be thought of as a special representation for a
-/// hypothetical `&uninit` reference (which Rust cannot currently
-/// express directly). That is, it represents a pointer to
-/// uninitialized storage.
-///
-/// The client is responsible for two steps: First, initializing the
-/// payload (it can access its address via `pointer`). Second,
-/// converting the agent to an instance of the owning pointer, via the
-/// appropriate `finalize` method (see the `InPlace`.
-///
-/// If evaluating EXPR fails, then it is up to the destructor for the
-/// implementation of Place to clean up any intermediate state
-/// (e.g. deallocate box storage, pop a stack, etc).
-#[unstable(feature = "placement_new_protocol", issue = "27779")]
-pub unsafe trait Place<Data: ?Sized> {
-    /// Returns the address where the input value will be written.
-    /// Note that the data at this address is generally uninitialized,
-    /// and thus one should use `ptr::write` for initializing it.
-    ///
-    /// This function must return a pointer through which a value
-    /// of type `Data` can be written.
-    fn pointer(&mut self) -> *mut Data;
-}
-
-/// Interface to implementations of  `PLACE <- EXPR`.
-///
-/// `PLACE <- EXPR` effectively desugars into:
-///
-/// ```
-/// # #![feature(placement_new_protocol, box_heap)]
-/// # use std::ops::{Placer, Place, InPlace};
-/// # #[allow(non_snake_case)]
-/// # fn main() {
-/// # let PLACE = std::boxed::HEAP;
-/// # let EXPR = 1;
-/// let p = PLACE;
-/// let mut place = Placer::make_place(p);
-/// let raw_place = Place::pointer(&mut place);
-/// let value = EXPR;
-/// unsafe {
-///     std::ptr::write(raw_place, value);
-///     InPlace::finalize(place)
-/// }
-/// # ; }
-/// ```
-///
-/// The type of `PLACE <- EXPR` is derived from the type of `PLACE`;
-/// if the type of `PLACE` is `P`, then the final type of the whole
-/// expression is `P::Place::Owner` (see the `InPlace` and `Boxed`
-/// traits).
-///
-/// Values for types implementing this trait usually are transient
-/// intermediate values (e.g. the return value of `Vec::emplace_back`)
-/// or `Copy`, since the `make_place` method takes `self` by value.
-#[unstable(feature = "placement_new_protocol", issue = "27779")]
-pub trait Placer<Data: ?Sized> {
-    /// `Place` is the intermediate agent guarding the
-    /// uninitialized state for `Data`.
-    type Place: InPlace<Data>;
-
-    /// Creates a fresh place from `self`.
-    fn make_place(self) -> Self::Place;
-}
-
-/// Specialization of `Place` trait supporting `PLACE <- EXPR`.
-#[unstable(feature = "placement_new_protocol", issue = "27779")]
-pub trait InPlace<Data: ?Sized>: Place<Data> {
-    /// `Owner` is the type of the end value of `PLACE <- EXPR`
-    ///
-    /// Note that when `PLACE <- EXPR` is solely used for
-    /// side-effecting an existing data-structure,
-    /// e.g. `Vec::emplace_back`, then `Owner` need not carry any
-    /// information at all (e.g. it can be the unit type `()` in that
-    /// case).
-    type Owner;
-
-    /// Converts self into the final value, shifting
-    /// deallocation/cleanup responsibilities (if any remain), over to
-    /// the returned instance of `Owner` and forgetting self.
-    unsafe fn finalize(self) -> Self::Owner;
-}
-
-/// Core trait for the `box EXPR` form.
-///
-/// `box EXPR` effectively desugars into:
-///
-/// ```
-/// # #![feature(placement_new_protocol)]
-/// # use std::ops::{BoxPlace, Place, Boxed};
-/// # #[allow(non_snake_case)]
-/// # fn main() {
-/// # let EXPR = 1;
-/// let mut place = BoxPlace::make_place();
-/// let raw_place = Place::pointer(&mut place);
-/// let value = EXPR;
-/// # let _: Box<_> =
-/// unsafe {
-///     ::std::ptr::write(raw_place, value);
-///     Boxed::finalize(place)
-/// }
-/// # ; }
-/// ```
-///
-/// The type of `box EXPR` is supplied from its surrounding
-/// context; in the above expansion, the result type `T` is used
-/// to determine which implementation of `Boxed` to use, and that
-/// `<T as Boxed>` in turn dictates determines which
-/// implementation of `BoxPlace` to use, namely:
-/// `<<T as Boxed>::Place as BoxPlace>`.
-#[unstable(feature = "placement_new_protocol", issue = "27779")]
-pub trait Boxed {
-    /// The kind of data that is stored in this kind of box.
-    type Data;  /* (`Data` unused b/c cannot yet express below bound.) */
-    /// The place that will negotiate the storage of the data.
-    type Place: BoxPlace<Self::Data>;
-
-    /// Converts filled place into final owning value, shifting
-    /// deallocation/cleanup responsibilities (if any remain), over to
-    /// returned instance of `Self` and forgetting `filled`.
-    unsafe fn finalize(filled: Self::Place) -> Self;
-}
-
-/// Specialization of `Place` trait supporting `box EXPR`.
-#[unstable(feature = "placement_new_protocol", issue = "27779")]
-pub trait BoxPlace<Data: ?Sized> : Place<Data> {
-    /// Creates a globally fresh place.
-    fn make_place() -> Self;
-}