diff options
| author | bors <bors@rust-lang.org> | 2018-01-24 07:22:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-24 07:22:22 +0000 |
| commit | 9758ff9c0bd812135304385a48135a93372c3ec2 (patch) | |
| tree | b1c5abd61ff8946814219e643a8d98859eee5b25 /src/liballoc | |
| parent | a538fe7ce715c7bd27e2e05329c3d857b9ad92af (diff) | |
| parent | f25f4687093c1c7e69a06fa7fa6cc3cc6f9aa9d1 (diff) | |
| download | rust-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/liballoc')
| -rw-r--r-- | src/liballoc/binary_heap.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/linked_list.rs | 4 | ||||
| -rw-r--r-- | src/liballoc/vec.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/vec_deque.rs | 4 |
5 files changed, 7 insertions, 7 deletions
diff --git a/src/liballoc/binary_heap.rs b/src/liballoc/binary_heap.rs index 94bbaf92ce9..3041f85cd4c 100644 --- a/src/liballoc/binary_heap.rs +++ b/src/liballoc/binary_heap.rs @@ -1211,7 +1211,7 @@ where T: Clone + Ord { #[unstable(feature = "collection_placement", reason = "placement protocol is subject to change", issue = "30172")] -impl<'a, T> Place<T> for BinaryHeapPlace<'a, T> +unsafe impl<'a, T> Place<T> for BinaryHeapPlace<'a, T> where T: Clone + Ord { fn pointer(&mut self) -> *mut T { self.place.pointer() diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index bfe23ddeca3..cdaad973a71 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -142,7 +142,7 @@ pub struct IntermediateBox<T: ?Sized> { #[unstable(feature = "placement_in", reason = "placement box design is still being worked out.", issue = "27779")] -impl<T> Place<T> for IntermediateBox<T> { +unsafe impl<T> Place<T> for IntermediateBox<T> { fn pointer(&mut self) -> *mut T { self.ptr as *mut T } diff --git a/src/liballoc/linked_list.rs b/src/liballoc/linked_list.rs index 3cc810a055f..65be087b35e 100644 --- a/src/liballoc/linked_list.rs +++ b/src/liballoc/linked_list.rs @@ -1286,7 +1286,7 @@ impl<'a, T> Placer<T> for FrontPlace<'a, T> { #[unstable(feature = "collection_placement", reason = "placement protocol is subject to change", issue = "30172")] -impl<'a, T> Place<T> for FrontPlace<'a, T> { +unsafe impl<'a, T> Place<T> for FrontPlace<'a, T> { fn pointer(&mut self) -> *mut T { unsafe { &mut (*self.node.pointer()).element } } @@ -1341,7 +1341,7 @@ impl<'a, T> Placer<T> for BackPlace<'a, T> { #[unstable(feature = "collection_placement", reason = "placement protocol is subject to change", issue = "30172")] -impl<'a, T> Place<T> for BackPlace<'a, T> { +unsafe impl<'a, T> Place<T> for BackPlace<'a, T> { fn pointer(&mut self) -> *mut T { unsafe { &mut (*self.node.pointer()).element } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b14b9d74765..b26979c7f6d 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2544,7 +2544,7 @@ impl<'a, T> Placer<T> for PlaceBack<'a, T> { #[unstable(feature = "collection_placement", reason = "placement protocol is subject to change", issue = "30172")] -impl<'a, T> Place<T> for PlaceBack<'a, T> { +unsafe impl<'a, T> Place<T> for PlaceBack<'a, T> { fn pointer(&mut self) -> *mut T { unsafe { self.vec.as_mut_ptr().offset(self.vec.len as isize) } } diff --git a/src/liballoc/vec_deque.rs b/src/liballoc/vec_deque.rs index 9259138bab0..8b686365e69 100644 --- a/src/liballoc/vec_deque.rs +++ b/src/liballoc/vec_deque.rs @@ -2565,7 +2565,7 @@ impl<'a, T> Placer<T> for PlaceBack<'a, T> { #[unstable(feature = "collection_placement", reason = "placement protocol is subject to change", issue = "30172")] -impl<'a, T> Place<T> for PlaceBack<'a, T> { +unsafe impl<'a, T> Place<T> for PlaceBack<'a, T> { fn pointer(&mut self) -> *mut T { unsafe { self.vec_deque.ptr().offset(self.vec_deque.head as isize) } } @@ -2611,7 +2611,7 @@ impl<'a, T> Placer<T> for PlaceFront<'a, T> { #[unstable(feature = "collection_placement", reason = "placement protocol is subject to change", issue = "30172")] -impl<'a, T> Place<T> for PlaceFront<'a, T> { +unsafe impl<'a, T> Place<T> for PlaceFront<'a, T> { fn pointer(&mut self) -> *mut T { let tail = self.vec_deque.wrap_sub(self.vec_deque.tail, 1); unsafe { self.vec_deque.ptr().offset(tail as isize) } |
