From bb59d616aa62217b8f4c56311766957710d9e984 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 14 Sep 2020 11:32:18 +0200 Subject: Use don't unroll loop in Rvalue::Repeat Fixes #1081 --- example/mini_core.rs | 19 +++++++++++++++++++ example/mini_core_hello_world.rs | 4 ++++ 2 files changed, 23 insertions(+) (limited to 'example') 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 Copy for *const T {} unsafe impl Copy for *mut T {} +unsafe impl Copy for Option {} #[lang = "sync"] pub unsafe trait Sync {} @@ -336,6 +337,24 @@ impl PartialEq for *const T { } } +impl PartialEq for Option { + 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(); -- cgit 1.4.1-3-g733a5