about summary refs log tree commit diff
path: root/example
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2020-09-14 11:32:18 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2020-09-14 11:32:27 +0200
commitbb59d616aa62217b8f4c56311766957710d9e984 (patch)
tree390ee990fc82785d73e2ed9d475d49b2d0d9c04d /example
parent50e8f2218e94d15892a78f0b780ba103bf21647a (diff)
downloadrust-bb59d616aa62217b8f4c56311766957710d9e984.tar.gz
rust-bb59d616aa62217b8f4c56311766957710d9e984.zip
Use don't unroll loop in Rvalue::Repeat
Fixes #1081
Diffstat (limited to 'example')
-rw-r--r--example/mini_core.rs19
-rw-r--r--example/mini_core_hello_world.rs4
2 files changed, 23 insertions, 0 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs
index 94336154748..a972beedaa3 100644
--- a/example/mini_core.rs
+++ b/example/mini_core.rs
@@ -58,6 +58,7 @@ unsafe impl Copy for char {}
 unsafe impl<'a, T: ?Sized> Copy for &'a T {}
 unsafe impl<T: ?Sized> Copy for *const T {}
 unsafe impl<T: ?Sized> Copy for *mut T {}
+unsafe impl<T: Copy> Copy for Option<T> {}
 
 #[lang = "sync"]
 pub unsafe trait Sync {}
@@ -336,6 +337,24 @@ impl<T: ?Sized> PartialEq for *const T {
     }
 }
 
+impl <T: PartialEq> PartialEq for Option<T> {
+    fn eq(&self, other: &Self) -> bool {
+        match (self, other) {
+            (Some(lhs), Some(rhs)) => *lhs == *rhs,
+            (None, None) => true,
+            _ => false,
+        }
+    }
+
+    fn ne(&self, other: &Self) -> bool {
+        match (self, other) {
+            (Some(lhs), Some(rhs)) => *lhs != *rhs,
+            (None, None) => false,
+            _ => true,
+        }
+    }
+}
+
 #[lang = "neg"]
 pub trait Neg {
     type Output;
diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs
index d79f9f5f79c..f1c037696d8 100644
--- a/example/mini_core_hello_world.rs
+++ b/example/mini_core_hello_world.rs
@@ -285,6 +285,10 @@ fn main() {
     let slice_ptr = &[] as *const [u8];
     slice_ptr as *const u8;
 
+    let repeat = [Some(42); 2];
+    assert_eq!(repeat[0], Some(42));
+    assert_eq!(repeat[1], Some(42));
+
     #[cfg(not(jit))]
     test_tls();