about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/example
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2020-11-03 11:00:04 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2020-11-03 11:00:04 +0100
commit216c4ae46352330bc7962f132fe226a7e73ab8fa (patch)
treec1d7af49fa1f27f325f090cff3f2d8861972fec9 /compiler/rustc_codegen_cranelift/example
parenta6403b0f04b58a35cb9f3e544b2847ee09bcf3a4 (diff)
parent03f01bbe901d60b71cf2c5ec766aef5e532ab79d (diff)
downloadrust-216c4ae46352330bc7962f132fe226a7e73ab8fa.tar.gz
rust-216c4ae46352330bc7962f132fe226a7e73ab8fa.zip
Merge commit '03f01bbe901d60b71cf2c5ec766aef5e532ab79d' into update_cg_clif-2020-11-01
Diffstat (limited to 'compiler/rustc_codegen_cranelift/example')
-rw-r--r--compiler/rustc_codegen_cranelift/example/mini_core.rs10
-rw-r--r--compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs22
-rw-r--r--compiler/rustc_codegen_cranelift/example/std_example.rs14
3 files changed, 39 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs
index a972beedaa3..ce07fe83df1 100644
--- a/compiler/rustc_codegen_cranelift/example/mini_core.rs
+++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs
@@ -48,6 +48,7 @@ unsafe impl Copy for u8 {}
 unsafe impl Copy for u16 {}
 unsafe impl Copy for u32 {}
 unsafe impl Copy for u64 {}
+unsafe impl Copy for u128 {}
 unsafe impl Copy for usize {}
 unsafe impl Copy for i8 {}
 unsafe impl Copy for i16 {}
@@ -283,6 +284,15 @@ impl PartialEq for u64 {
     }
 }
 
+impl PartialEq for u128 {
+    fn eq(&self, other: &u128) -> bool {
+        (*self) == (*other)
+    }
+    fn ne(&self, other: &u128) -> bool {
+        (*self) != (*other)
+    }
+}
+
 impl PartialEq for usize {
     fn eq(&self, other: &usize) -> bool {
         (*self) == (*other)
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs
index 376056e1938..4a8375afac3 100644
--- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs
+++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs
@@ -287,6 +287,8 @@ fn main() {
     assert_eq!(repeat[0], Some(42));
     assert_eq!(repeat[1], Some(42));
 
+    from_decimal_string();
+
     #[cfg(not(jit))]
     test_tls();
 
@@ -446,3 +448,23 @@ fn check_niche_behavior () {
         intrinsics::abort();
     }
 }
+
+fn from_decimal_string() {
+    loop {
+        let multiplier = 1;
+
+        take_multiplier_ref(&multiplier);
+
+        if multiplier == 1 {
+            break;
+        }
+
+        unreachable();
+    }
+}
+
+fn take_multiplier_ref(_multiplier: &u128) {}
+
+fn unreachable() -> ! {
+    panic("unreachable")
+}
diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs
index 079b4299049..cb512a4aa33 100644
--- a/compiler/rustc_codegen_cranelift/example/std_example.rs
+++ b/compiler/rustc_codegen_cranelift/example/std_example.rs
@@ -315,13 +315,13 @@ fn test_checked_mul() {
     assert_eq!(1i8.checked_mul(-128i8), Some(-128i8));
     assert_eq!((-128i8).checked_mul(-128i8), None);
 
-    assert_eq!(1u64.checked_mul(u64::max_value()), Some(u64::max_value()));
-    assert_eq!(u64::max_value().checked_mul(u64::max_value()), None);
-    assert_eq!(1i64.checked_mul(i64::max_value()), Some(i64::max_value()));
-    assert_eq!(i64::max_value().checked_mul(i64::max_value()), None);
-    assert_eq!((-1i64).checked_mul(i64::min_value() + 1), Some(i64::max_value()));
-    assert_eq!(1i64.checked_mul(i64::min_value()), Some(i64::min_value()));
-    assert_eq!(i64::min_value().checked_mul(i64::min_value()), None);
+    assert_eq!(1u64.checked_mul(u64::MAX), Some(u64::MAX));
+    assert_eq!(u64::MAX.checked_mul(u64::MAX), None);
+    assert_eq!(1i64.checked_mul(i64::MAX), Some(i64::MAX));
+    assert_eq!(i64::MAX.checked_mul(i64::MAX), None);
+    assert_eq!((-1i64).checked_mul(i64::MIN + 1), Some(i64::MAX));
+    assert_eq!(1i64.checked_mul(i64::MIN), Some(i64::MIN));
+    assert_eq!(i64::MIN.checked_mul(i64::MIN), None);
 }
 
 #[derive(PartialEq)]