about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-01-24 07:22:22 +0000
committerbors <bors@rust-lang.org>2018-01-24 07:22:22 +0000
commit9758ff9c0bd812135304385a48135a93372c3ec2 (patch)
treeb1c5abd61ff8946814219e643a8d98859eee5b25 /src/libcore
parenta538fe7ce715c7bd27e2e05329c3d857b9ad92af (diff)
parentf25f4687093c1c7e69a06fa7fa6cc3cc6f9aa9d1 (diff)
downloadrust-9758ff9c0bd812135304385a48135a93372c3ec2.tar.gz
rust-9758ff9c0bd812135304385a48135a93372c3ec2.zip
Auto merge of #47299 - cramertj:unsafe-placer, r=alexcrichton
Make core::ops::Place an unsafe trait

Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/ops/place.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/ops/place.rs b/src/libcore/ops/place.rs
index 9fb171e7b92..b3dcf4e7ee9 100644
--- a/src/libcore/ops/place.rs
+++ b/src/libcore/ops/place.rs
@@ -27,10 +27,13 @@
 /// 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 trait Place<Data: ?Sized> {
+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;
 }