about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-09-15 06:14:26 -0700
committerGitHub <noreply@github.com>2016-09-15 06:14:26 -0700
commitdc75933abaf3f6d619ada2bbc12b01bc85ddb4ae (patch)
tree034d03910e6757b5455e0792aacf4ed021c72383 /src/libcore
parente2c64d16906dbb29763d6cbf022164a09247ef9f (diff)
parentec08128882b165a93b3fd1f99c9606ad5e09b3dc (diff)
downloadrust-dc75933abaf3f6d619ada2bbc12b01bc85ddb4ae.tar.gz
rust-dc75933abaf3f6d619ada2bbc12b01bc85ddb4ae.zip
Auto merge of #36491 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests

- Successful merges: #36384, #36405, #36425, #36429, #36438, #36454, #36459, #36461, #36463
- Failed merges: #36444
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/clone.rs19
-rw-r--r--src/libcore/cmp.rs13
-rw-r--r--src/libcore/slice.rs8
3 files changed, 32 insertions, 8 deletions
diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs
index 69355c6c6cc..0b800cacfc1 100644
--- a/src/libcore/clone.rs
+++ b/src/libcore/clone.rs
@@ -113,10 +113,23 @@ pub trait Clone : Sized {
     }
 }
 
-// FIXME(aburka): this method is used solely by #[derive] to
-// assert that every component of a type implements Clone.
+// FIXME(aburka): these structs are used solely by #[derive] to
+// assert that every component of a type implements Clone or Copy.
 //
-// This should never be called by user code.
+// These structs should never appear in user code.
+#[doc(hidden)]
+#[allow(missing_debug_implementations)]
+#[unstable(feature = "derive_clone_copy",
+           reason = "deriving hack, should not be public",
+           issue = "0")]
+pub struct AssertParamIsClone<T: Clone + ?Sized> { _field: ::marker::PhantomData<T> }
+#[doc(hidden)]
+#[allow(missing_debug_implementations)]
+#[unstable(feature = "derive_clone_copy",
+           reason = "deriving hack, should not be public",
+           issue = "0")]
+pub struct AssertParamIsCopy<T: Copy + ?Sized> { _field: ::marker::PhantomData<T> }
+#[cfg(stage0)]
 #[doc(hidden)]
 #[inline(always)]
 #[unstable(feature = "derive_clone_copy",
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index 670978a2d49..f990a27e52b 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -129,7 +129,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
 /// This trait can be used with `#[derive]`. When `derive`d, because `Eq` has
 /// no extra methods, it is only informing the compiler that this is an
 /// equivalence relation rather than a partial equivalence relation. Note that
-/// the `derive` strategy requires all fields are `PartialEq`, which isn't
+/// the `derive` strategy requires all fields are `Eq`, which isn't
 /// always desired.
 ///
 /// ## How can I implement `Eq`?
@@ -165,6 +165,17 @@ pub trait Eq: PartialEq<Self> {
     fn assert_receiver_is_total_eq(&self) {}
 }
 
+// FIXME: this struct is used solely by #[derive] to
+// assert that every component of a type implements Eq.
+//
+// This struct should never appear in user code.
+#[doc(hidden)]
+#[allow(missing_debug_implementations)]
+#[unstable(feature = "derive_eq",
+           reason = "deriving hack, should not be public",
+           issue = "0")]
+pub struct AssertParamIsEq<T: Eq + ?Sized> { _field: ::marker::PhantomData<T> }
+
 /// An `Ordering` is the result of a comparison between two values.
 ///
 /// # Examples
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index 7b147faccd2..d1df56905df 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -520,8 +520,8 @@ impl<T> ops::Index<usize> for [T] {
     type Output = T;
 
     fn index(&self, index: usize) -> &T {
-        assert!(index < self.len());
-        unsafe { self.get_unchecked(index) }
+        // NB built-in indexing
+        &(*self)[index]
     }
 }
 
@@ -530,8 +530,8 @@ impl<T> ops::Index<usize> for [T] {
 impl<T> ops::IndexMut<usize> for [T] {
     #[inline]
     fn index_mut(&mut self, index: usize) -> &mut T {
-        assert!(index < self.len());
-        unsafe { self.get_unchecked_mut(index) }
+        // NB built-in indexing
+        &mut (*self)[index]
     }
 }