diff options
| author | bors <bors@rust-lang.org> | 2021-05-01 09:59:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-01 09:59:54 +0000 |
| commit | fed59d669c5ca3c0e9c39dcb1f6510b5876ede64 (patch) | |
| tree | 71be961123cb9718153613d9a53c138f2a409075 /compiler/rustc_codegen_cranelift/example | |
| parent | 1c2c6b670023efda0fea8e1837f9542d3ed12f5d (diff) | |
| parent | 6af045f00a3bf7d34a2dcd84d1f89e2b5fef0f36 (diff) | |
| download | rust-fed59d669c5ca3c0e9c39dcb1f6510b5876ede64.tar.gz rust-fed59d669c5ca3c0e9c39dcb1f6510b5876ede64.zip | |
Auto merge of #84786 - JohnTitor:rollup-j5omx6f, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #84601 (rustdoc: Only store locations in Cache::extern_locations and calculate the other info on-demand) - #84704 (platform-support.md: Update for consistency with Target Tier Policy) - #84724 (Replace llvm::sys::fs::F_None with llvm::sys::fs::OF_None) - #84740 (Reset the docs' copy path button after 1 second) - #84749 (Sync `rustc_codegen_cranelift`) - #84756 (Add a ToC to the Target Tier Policy documentation) - #84765 (Update cargo) - #84774 (Fix misspelling) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_cranelift/example')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs | 43 | ||||
| -rw-r--r-- | compiler/rustc_codegen_cranelift/example/std_example.rs | 3 |
2 files changed, 27 insertions, 19 deletions
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 ea37ca98b59..6570f2bf9f2 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -11,6 +11,22 @@ unsafe extern "C" fn my_puts(s: *const i8) { puts(s); } +macro_rules! assert { + ($e:expr) => { + if !$e { + panic(stringify!(! $e)); + } + }; +} + +macro_rules! assert_eq { + ($l:expr, $r: expr) => { + if $l != $r { + panic(stringify!($l != $r)); + } + } +} + #[lang = "termination"] trait Termination { fn report(self) -> i32; @@ -20,8 +36,9 @@ impl Termination for () { fn report(self) -> i32 { unsafe { NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44 - *NUM_REF as i32 + assert_eq!(*NUM_REF as i32, 44); } + 0 } } @@ -82,29 +99,12 @@ fn start<T: Termination + 'static>( unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const i8)); } } - main().report(); - 0 + main().report() as isize } static mut NUM: u8 = 6 * 7; static NUM_REF: &'static u8 = unsafe { &NUM }; -macro_rules! assert { - ($e:expr) => { - if !$e { - panic(stringify!(! $e)); - } - }; -} - -macro_rules! assert_eq { - ($l:expr, $r: expr) => { - if $l != $r { - panic(stringify!($l != $r)); - } - } -} - struct Unique<T: ?Sized> { pointer: *const T, _marker: PhantomData<T>, @@ -296,6 +296,11 @@ fn main() { unsafe { global_asm_test(); } + + // Both statics have a reference that points to the same anonymous allocation. + static REF1: &u8 = &42; + static REF2: &u8 = REF1; + assert_eq!(*REF1, *REF2); } #[cfg(all(not(jit), target_os = "linux"))] diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs index 015bbdfed46..77ba72df8ef 100644 --- a/compiler/rustc_codegen_cranelift/example/std_example.rs +++ b/compiler/rustc_codegen_cranelift/example/std_example.rs @@ -48,6 +48,8 @@ fn main() { assert_eq!(2.3f32.copysign(-1.0), -2.3f32); println!("{}", 2.3f32.powf(2.0)); + assert_eq!(i64::MAX.checked_mul(2), None); + assert_eq!(-128i8, (-128i8).saturating_sub(1)); assert_eq!(127i8, 127i8.saturating_sub(-128)); assert_eq!(-128i8, (-128i8).saturating_add(-128)); @@ -84,6 +86,7 @@ fn main() { assert_eq!(houndred_i128 as f64, 100.0); assert_eq!(houndred_f32 as i128, 100); assert_eq!(houndred_f64 as i128, 100); + assert_eq!(1u128.rotate_left(2), 4); // Test signed 128bit comparing let max = usize::MAX as i128; |
