From 691a4c231c0744edf9a3ea5e08f4312333a772c7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 26 Apr 2019 16:42:50 +0200 Subject: [PATCH] DEBUG commit for https://github.com/rust-lang/rust/pull/60173 --- tests/compiletest.rs | 3 + tests/run-pass/args.rs | 5 - tests/run-pass/args.stdout | 1 - tests/run-pass/arrays.rs | 45 ---- tests/run-pass/associated-const.rs | 11 - tests/run-pass/assume_bug.rs | 3 - tests/run-pass/async-fn.rs | 45 ---- tests/run-pass/atomic-access-bool.rs | 19 -- tests/run-pass/atomic-compare_exchange.rs | 29 --- tests/run-pass/bad_substs.rs | 4 - tests/run-pass/binops.rs | 81 ------- tests/run-pass/bools.rs | 29 --- tests/run-pass/box-pair-to-vec.rs | 28 --- tests/run-pass/box-pair-to-vec.stdout | 3 - tests/run-pass/box_box_trait.rs | 31 --- tests/run-pass/btreemap.rs | 29 --- tests/run-pass/c_enums.rs | 32 --- tests/run-pass/call_drop_on_array_elements.rs | 22 -- .../call_drop_on_fat_ptr_array_elements.rs | 20 -- .../call_drop_on_zst_array_elements.rs | 21 -- .../run-pass/call_drop_through_owned_slice.rs | 16 -- .../call_drop_through_trait_object.rs | 20 -- .../call_drop_through_trait_object_rc.rs | 22 -- tests/run-pass/calloc.rs | 26 --- tests/run-pass/calls.rs | 45 ---- tests/run-pass/cast-rfc0401-vtable-kinds.rs | 45 ---- tests/run-pass/cast_fn_ptr.rs | 9 - tests/run-pass/cast_fn_ptr_unsafe.rs | 8 - tests/run-pass/catch.rs | 7 - tests/run-pass/catch.stdout | 1 - tests/run-pass/char.rs | 7 - tests/run-pass/closure-drop.rs | 25 --- tests/run-pass/closure-field-ty.rs | 10 - tests/run-pass/closures.rs | 53 ----- tests/run-pass/const-vec-of-fns.rs | 17 -- tests/run-pass/constants.rs | 9 - tests/run-pass/deriving-associated-types.rs | 198 ------------------ tests/run-pass/drop_empty_slice.rs | 7 - tests/run-pass/dst-field-align.rs | 67 ------ tests/run-pass/dst-irrefutable-bind.rs | 14 -- tests/run-pass/dst-raw.rs | 103 --------- tests/run-pass/dst-struct-sole.rs | 75 ------- tests/run-pass/dst-struct.rs | 123 ----------- .../enum-nullable-const-null-with-fields.rs | 12 -- tests/run-pass/enums.rs | 34 --- tests/run-pass/env.rs | 9 - tests/run-pass/exit.rs | 3 - tests/run-pass/extern_types.rs | 10 - tests/run-pass/float_fast_math.rs | 20 -- tests/run-pass/floats.rs | 15 -- .../fn_item_as_closure_trait_object.rs | 6 - ..._item_with_args_as_closure_trait_object.rs | 8 - ...h_multiple_args_as_closure_trait_object.rs | 18 -- .../fn_ptr_as_closure_trait_object.rs | 15 -- tests/run-pass/foreign-fn-linkname.rs | 29 --- tests/run-pass/format.rs | 4 - tests/run-pass/format.stdout | 2 - tests/run-pass/from_utf8.rs | 3 - tests/run-pass/function_pointers.rs | 59 ------ tests/run-pass/generator.rs | 70 ------- tests/run-pass/hashmap.rs | 38 ---- tests/run-pass/heap.rs | 34 --- tests/run-pass/heap_allocator.rs | 3 + tests/run-pass/hello.rs | 3 - tests/run-pass/hello.stdout | 1 - tests/run-pass/integer-ops.rs | 171 --------------- tests/run-pass/intrinsics-integer.rs | 142 ------------- tests/run-pass/intrinsics-math.rs | 67 ------ tests/run-pass/intrinsics.rs | 10 - tests/run-pass/ints.rs | 58 ----- tests/run-pass/issue-15063.rs | 10 - tests/run-pass/issue-15080.rs | 22 -- tests/run-pass/issue-15523-big.rs | 38 ---- tests/run-pass/issue-17877.rs | 16 -- tests/run-pass/issue-20575.rs | 7 - tests/run-pass/issue-23261.rs | 60 ------ tests/run-pass/issue-26709.rs | 16 -- tests/run-pass/issue-27901.rs | 10 - tests/run-pass/issue-29746.rs | 35 ---- tests/run-pass/issue-30530.rs | 35 ---- tests/run-pass/issue-31267-additional.rs | 17 -- tests/run-pass/issue-33387.rs | 9 - tests/run-pass/issue-34571.rs | 10 - tests/run-pass/issue-35815.rs | 15 -- tests/run-pass/issue-36278-prefix-nesting.rs | 21 -- tests/run-pass/issue-3794.rs | 31 --- tests/run-pass/issue-3794.stdout | 2 - tests/run-pass/issue-53728.rs | 16 -- tests/run-pass/issue-5917.rs | 7 - tests/run-pass/issue-miri-184.rs | 4 - tests/run-pass/iter.rs | 40 ---- tests/run-pass/last-use-in-cap-clause.rs | 15 -- tests/run-pass/linked-list.rs | 33 --- tests/run-pass/loop-break-value.rs | 133 ------------ tests/run-pass/loops.rs | 35 ---- tests/run-pass/main_fn.rs | 5 - tests/run-pass/many_shr_bor.rs | 35 ---- tests/run-pass/match_slice.rs | 8 - tests/run-pass/memchr.rs | 89 -------- tests/run-pass/mir_coercions.rs | 73 ------- tests/run-pass/mir_fat_ptr.rs | 51 ----- tests/run-pass/miri-issue-133.rs | 30 --- tests/run-pass/move-arg-2-unique.rs | 9 - tests/run-pass/move-arg-3-unique.rs | 7 - tests/run-pass/move-undef-primval.rs | 12 -- tests/run-pass/multi_arg_closure.rs | 8 - tests/run-pass/negative_discriminant.rs | 13 -- .../run-pass/non_capture_closure_to_fn_ptr.rs | 20 -- tests/run-pass/observed_local_mut.rs | 24 --- tests/run-pass/option_box_transmute_ptr.rs | 15 -- tests/run-pass/option_eq.rs | 3 - tests/run-pass/overloaded-calls-simple.rs | 23 -- tests/run-pass/packed_static.rs | 10 - tests/run-pass/packed_struct.rs | 105 ---------- tests/run-pass/pointers.rs | 86 -------- tests/run-pass/products.rs | 32 --- tests/run-pass/ptr_arith_offset.rs | 6 - tests/run-pass/ptr_arith_offset_overflow.rs | 9 - tests/run-pass/ptr_int_casts.rs | 35 ---- tests/run-pass/ptr_int_ops.rs | 20 -- tests/run-pass/ptr_offset.rs | 16 -- tests/run-pass/raw.rs | 21 -- tests/run-pass/rc.rs | 80 ------- tests/run-pass/realloc.rs | 45 ---- tests/run-pass/recursive_static.rs | 9 - tests/run-pass/ref-invalid-ptr.rs | 12 -- tests/run-pass/refcell.rs | 33 --- .../regions-lifetime-nonfree-late-bound.rs | 32 --- tests/run-pass/regions-mock-trans.rs | 53 ----- tests/run-pass/rfc1623.rs | 71 ------- tests/run-pass/rust-lang-org.rs | 21 -- tests/run-pass/send-is-not-static-par-for.rs | 31 --- tests/run-pass/sendable-class.rs | 22 -- .../simd-intrinsic-generic-elements.rs | 32 --- tests/run-pass/slices.rs | 175 ---------------- tests/run-pass/small_enum_size_bug.rs | 14 -- tests/run-pass/specialization.rs | 21 -- tests/run-pass/stacked-borrows/2phase.rs | 89 -------- .../stacked-borrows/interior_mutability.rs | 59 ------ .../stacked-borrows/stacked-borrows.rs | 151 ------------- tests/run-pass/static_memory_modification.rs | 14 -- tests/run-pass/static_mut.rs | 17 -- tests/run-pass/strings.rs | 34 --- tests/run-pass/subslice_array.rs | 13 -- tests/run-pass/sums.rs | 56 ----- tests/run-pass/tag-align-dyn-u64.rs | 37 ---- tests/run-pass/thread-local.rs | 67 ------ tests/run-pass/threads.rs | 19 -- .../too-large-primval-write-problem.rs | 23 -- tests/run-pass/traits.rs | 30 --- tests/run-pass/transmute_fat.rs | 10 - tests/run-pass/trivial.rs | 11 - tests/run-pass/try-operator-custom.rs | 3 - .../tuple_like_enum_variant_constructor.rs | 3 - ...ke_enum_variant_constructor_pointer_opt.rs | 4 - ..._variant_constructor_struct_pointer_opt.rs | 33 --- .../run-pass/tuple_like_struct_constructor.rs | 5 - tests/run-pass/u128.rs | 65 ------ tests/run-pass/union-overwrite.rs | 71 ------- tests/run-pass/union.rs | 88 -------- tests/run-pass/unique-send.rs | 10 - tests/run-pass/unops.rs | 5 - tests/run-pass/unsized-tuple-impls.rs | 13 -- .../validation_lifetime_resolution.rs | 30 --- tests/run-pass/vec-matching-fold.rs | 44 ---- tests/run-pass/vecdeque.rs | 23 -- tests/run-pass/vecdeque.stdout | 2 - tests/run-pass/vecs.rs | 92 -------- tests/run-pass/volatile.rs | 12 -- tests/run-pass/write-bytes.rs | 45 ---- tests/run-pass/zero-sized-binary-heap-push.rs | 18 -- tests/run-pass/zst.rs | 33 --- tests/run-pass/zst_box.rs | 8 - tests/run-pass/zst_variant_drop.rs | 23 -- 174 files changed, 6 insertions(+), 5519 deletions(-) delete mode 100644 tests/run-pass/args.rs delete mode 100644 tests/run-pass/args.stdout delete mode 100644 tests/run-pass/arrays.rs delete mode 100644 tests/run-pass/associated-const.rs delete mode 100644 tests/run-pass/assume_bug.rs delete mode 100644 tests/run-pass/async-fn.rs delete mode 100644 tests/run-pass/atomic-access-bool.rs delete mode 100644 tests/run-pass/atomic-compare_exchange.rs delete mode 100644 tests/run-pass/bad_substs.rs delete mode 100644 tests/run-pass/binops.rs delete mode 100644 tests/run-pass/bools.rs delete mode 100644 tests/run-pass/box-pair-to-vec.rs delete mode 100644 tests/run-pass/box-pair-to-vec.stdout delete mode 100644 tests/run-pass/box_box_trait.rs delete mode 100644 tests/run-pass/btreemap.rs delete mode 100644 tests/run-pass/c_enums.rs delete mode 100644 tests/run-pass/call_drop_on_array_elements.rs delete mode 100644 tests/run-pass/call_drop_on_fat_ptr_array_elements.rs delete mode 100644 tests/run-pass/call_drop_on_zst_array_elements.rs delete mode 100644 tests/run-pass/call_drop_through_owned_slice.rs delete mode 100644 tests/run-pass/call_drop_through_trait_object.rs delete mode 100644 tests/run-pass/call_drop_through_trait_object_rc.rs delete mode 100644 tests/run-pass/calloc.rs delete mode 100644 tests/run-pass/calls.rs delete mode 100644 tests/run-pass/cast-rfc0401-vtable-kinds.rs delete mode 100644 tests/run-pass/cast_fn_ptr.rs delete mode 100644 tests/run-pass/cast_fn_ptr_unsafe.rs delete mode 100644 tests/run-pass/catch.rs delete mode 100644 tests/run-pass/catch.stdout delete mode 100644 tests/run-pass/char.rs delete mode 100644 tests/run-pass/closure-drop.rs delete mode 100644 tests/run-pass/closure-field-ty.rs delete mode 100644 tests/run-pass/closures.rs delete mode 100644 tests/run-pass/const-vec-of-fns.rs delete mode 100644 tests/run-pass/constants.rs delete mode 100644 tests/run-pass/deriving-associated-types.rs delete mode 100644 tests/run-pass/drop_empty_slice.rs delete mode 100644 tests/run-pass/dst-field-align.rs delete mode 100644 tests/run-pass/dst-irrefutable-bind.rs delete mode 100644 tests/run-pass/dst-raw.rs delete mode 100644 tests/run-pass/dst-struct-sole.rs delete mode 100644 tests/run-pass/dst-struct.rs delete mode 100644 tests/run-pass/enum-nullable-const-null-with-fields.rs delete mode 100644 tests/run-pass/enums.rs delete mode 100644 tests/run-pass/env.rs delete mode 100644 tests/run-pass/exit.rs delete mode 100644 tests/run-pass/extern_types.rs delete mode 100644 tests/run-pass/float_fast_math.rs delete mode 100644 tests/run-pass/floats.rs delete mode 100644 tests/run-pass/fn_item_as_closure_trait_object.rs delete mode 100644 tests/run-pass/fn_item_with_args_as_closure_trait_object.rs delete mode 100644 tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs delete mode 100644 tests/run-pass/fn_ptr_as_closure_trait_object.rs delete mode 100644 tests/run-pass/foreign-fn-linkname.rs delete mode 100644 tests/run-pass/format.rs delete mode 100644 tests/run-pass/format.stdout delete mode 100644 tests/run-pass/from_utf8.rs delete mode 100644 tests/run-pass/function_pointers.rs delete mode 100644 tests/run-pass/generator.rs delete mode 100644 tests/run-pass/hashmap.rs delete mode 100644 tests/run-pass/heap.rs delete mode 100644 tests/run-pass/hello.rs delete mode 100644 tests/run-pass/hello.stdout delete mode 100644 tests/run-pass/integer-ops.rs delete mode 100644 tests/run-pass/intrinsics-integer.rs delete mode 100644 tests/run-pass/intrinsics-math.rs delete mode 100644 tests/run-pass/intrinsics.rs delete mode 100644 tests/run-pass/ints.rs delete mode 100644 tests/run-pass/issue-15063.rs delete mode 100644 tests/run-pass/issue-15080.rs delete mode 100644 tests/run-pass/issue-15523-big.rs delete mode 100644 tests/run-pass/issue-17877.rs delete mode 100644 tests/run-pass/issue-20575.rs delete mode 100644 tests/run-pass/issue-23261.rs delete mode 100644 tests/run-pass/issue-26709.rs delete mode 100644 tests/run-pass/issue-27901.rs delete mode 100644 tests/run-pass/issue-29746.rs delete mode 100644 tests/run-pass/issue-30530.rs delete mode 100644 tests/run-pass/issue-31267-additional.rs delete mode 100644 tests/run-pass/issue-33387.rs delete mode 100644 tests/run-pass/issue-34571.rs delete mode 100644 tests/run-pass/issue-35815.rs delete mode 100644 tests/run-pass/issue-36278-prefix-nesting.rs delete mode 100644 tests/run-pass/issue-3794.rs delete mode 100644 tests/run-pass/issue-3794.stdout delete mode 100644 tests/run-pass/issue-53728.rs delete mode 100644 tests/run-pass/issue-5917.rs delete mode 100644 tests/run-pass/issue-miri-184.rs delete mode 100644 tests/run-pass/iter.rs delete mode 100644 tests/run-pass/last-use-in-cap-clause.rs delete mode 100644 tests/run-pass/linked-list.rs delete mode 100644 tests/run-pass/loop-break-value.rs delete mode 100644 tests/run-pass/loops.rs delete mode 100644 tests/run-pass/main_fn.rs delete mode 100644 tests/run-pass/many_shr_bor.rs delete mode 100644 tests/run-pass/match_slice.rs delete mode 100644 tests/run-pass/memchr.rs delete mode 100644 tests/run-pass/mir_coercions.rs delete mode 100644 tests/run-pass/mir_fat_ptr.rs delete mode 100644 tests/run-pass/miri-issue-133.rs delete mode 100644 tests/run-pass/move-arg-2-unique.rs delete mode 100644 tests/run-pass/move-arg-3-unique.rs delete mode 100644 tests/run-pass/move-undef-primval.rs delete mode 100644 tests/run-pass/multi_arg_closure.rs delete mode 100644 tests/run-pass/negative_discriminant.rs delete mode 100644 tests/run-pass/non_capture_closure_to_fn_ptr.rs delete mode 100644 tests/run-pass/observed_local_mut.rs delete mode 100644 tests/run-pass/option_box_transmute_ptr.rs delete mode 100644 tests/run-pass/option_eq.rs delete mode 100644 tests/run-pass/overloaded-calls-simple.rs delete mode 100644 tests/run-pass/packed_static.rs delete mode 100644 tests/run-pass/packed_struct.rs delete mode 100644 tests/run-pass/pointers.rs delete mode 100644 tests/run-pass/products.rs delete mode 100644 tests/run-pass/ptr_arith_offset.rs delete mode 100644 tests/run-pass/ptr_arith_offset_overflow.rs delete mode 100644 tests/run-pass/ptr_int_casts.rs delete mode 100644 tests/run-pass/ptr_int_ops.rs delete mode 100644 tests/run-pass/ptr_offset.rs delete mode 100644 tests/run-pass/raw.rs delete mode 100644 tests/run-pass/rc.rs delete mode 100644 tests/run-pass/realloc.rs delete mode 100644 tests/run-pass/recursive_static.rs delete mode 100644 tests/run-pass/ref-invalid-ptr.rs delete mode 100644 tests/run-pass/refcell.rs delete mode 100644 tests/run-pass/regions-lifetime-nonfree-late-bound.rs delete mode 100644 tests/run-pass/regions-mock-trans.rs delete mode 100644 tests/run-pass/rfc1623.rs delete mode 100644 tests/run-pass/rust-lang-org.rs delete mode 100644 tests/run-pass/send-is-not-static-par-for.rs delete mode 100644 tests/run-pass/sendable-class.rs delete mode 100644 tests/run-pass/simd-intrinsic-generic-elements.rs delete mode 100644 tests/run-pass/slices.rs delete mode 100644 tests/run-pass/small_enum_size_bug.rs delete mode 100644 tests/run-pass/specialization.rs delete mode 100644 tests/run-pass/stacked-borrows/2phase.rs delete mode 100644 tests/run-pass/stacked-borrows/interior_mutability.rs delete mode 100644 tests/run-pass/stacked-borrows/stacked-borrows.rs delete mode 100644 tests/run-pass/static_memory_modification.rs delete mode 100644 tests/run-pass/static_mut.rs delete mode 100644 tests/run-pass/strings.rs delete mode 100644 tests/run-pass/subslice_array.rs delete mode 100644 tests/run-pass/sums.rs delete mode 100644 tests/run-pass/tag-align-dyn-u64.rs delete mode 100644 tests/run-pass/thread-local.rs delete mode 100644 tests/run-pass/threads.rs delete mode 100644 tests/run-pass/too-large-primval-write-problem.rs delete mode 100644 tests/run-pass/traits.rs delete mode 100644 tests/run-pass/transmute_fat.rs delete mode 100644 tests/run-pass/trivial.rs delete mode 100644 tests/run-pass/try-operator-custom.rs delete mode 100644 tests/run-pass/tuple_like_enum_variant_constructor.rs delete mode 100644 tests/run-pass/tuple_like_enum_variant_constructor_pointer_opt.rs delete mode 100644 tests/run-pass/tuple_like_enum_variant_constructor_struct_pointer_opt.rs delete mode 100644 tests/run-pass/tuple_like_struct_constructor.rs delete mode 100644 tests/run-pass/u128.rs delete mode 100644 tests/run-pass/union-overwrite.rs delete mode 100644 tests/run-pass/union.rs delete mode 100644 tests/run-pass/unique-send.rs delete mode 100644 tests/run-pass/unops.rs delete mode 100644 tests/run-pass/unsized-tuple-impls.rs delete mode 100644 tests/run-pass/validation_lifetime_resolution.rs delete mode 100644 tests/run-pass/vec-matching-fold.rs delete mode 100644 tests/run-pass/vecdeque.rs delete mode 100644 tests/run-pass/vecdeque.stdout delete mode 100644 tests/run-pass/vecs.rs delete mode 100644 tests/run-pass/volatile.rs delete mode 100644 tests/run-pass/write-bytes.rs delete mode 100644 tests/run-pass/zero-sized-binary-heap-push.rs delete mode 100644 tests/run-pass/zst.rs delete mode 100644 tests/run-pass/zst_box.rs delete mode 100644 tests/run-pass/zst_variant_drop.rs diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 7f2c896647..192b4c88b1 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -113,6 +113,9 @@ fn compile_fail_miri(opt: bool) { } fn test_runner(_tests: &[&()]) { + std::env::set_var("MIRI_BACKTRACE", "1"); + std::env::set_var("MIRI_LOG", "info"); + run_pass_miri(false); run_pass_miri(true); diff --git a/tests/run-pass/args.rs b/tests/run-pass/args.rs deleted file mode 100644 index 0116dce499..0000000000 --- a/tests/run-pass/args.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - for arg in std::env::args() { - println!("{}", arg); - } -} diff --git a/tests/run-pass/args.stdout b/tests/run-pass/args.stdout deleted file mode 100644 index 9564f5a1aa..0000000000 --- a/tests/run-pass/args.stdout +++ /dev/null @@ -1 +0,0 @@ -args diff --git a/tests/run-pass/arrays.rs b/tests/run-pass/arrays.rs deleted file mode 100644 index 469dde3091..0000000000 --- a/tests/run-pass/arrays.rs +++ /dev/null @@ -1,45 +0,0 @@ -fn empty_array() -> [u16; 0] { - [] -} - -fn mini_array() -> [u16; 1] { - [42] -} - -fn big_array() -> [u16; 5] { - [5, 4, 3, 2, 1] -} - -fn array_array() -> [[u8; 2]; 3] { - [[5, 4], [3, 2], [1, 0]] -} - -fn index_unsafe() -> i32 { - let a = [0, 10, 20, 30]; - unsafe { *a.get_unchecked(2) } -} - -fn index() -> i32 { - let a = [0, 10, 20, 30]; - a[2] -} - -fn array_repeat() -> [u8; 8] { - [42; 8] -} - -fn slice_index() -> u8 { - let arr: &[_] = &[101, 102, 103, 104, 105, 106]; - arr[5] -} - -fn main() { - assert_eq!(empty_array(), []); - assert_eq!(index_unsafe(), 20); - assert_eq!(index(), 20); - assert_eq!(slice_index(), 106); - assert_eq!(big_array(), [5, 4, 3, 2, 1]); - assert_eq!(array_array(), [[5, 4], [3, 2], [1, 0]]); - assert_eq!(array_repeat(), [42; 8]); - assert_eq!(mini_array(), [42]); -} diff --git a/tests/run-pass/associated-const.rs b/tests/run-pass/associated-const.rs deleted file mode 100644 index 2ff08ffc4b..0000000000 --- a/tests/run-pass/associated-const.rs +++ /dev/null @@ -1,11 +0,0 @@ -trait Foo { - const ID: i32; -} - -impl Foo for i32 { - const ID: i32 = 1; -} - -fn main() { - assert_eq!(1, ::ID); -} diff --git a/tests/run-pass/assume_bug.rs b/tests/run-pass/assume_bug.rs deleted file mode 100644 index e14f875c02..0000000000 --- a/tests/run-pass/assume_bug.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - vec![()].into_iter(); -} diff --git a/tests/run-pass/async-fn.rs b/tests/run-pass/async-fn.rs deleted file mode 100644 index 1608ea1888..0000000000 --- a/tests/run-pass/async-fn.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![feature( - async_await, - await_macro, - futures_api, -)] - -use std::{future::Future, pin::Pin, task::Poll, ptr}; -use std::task::{Waker, RawWaker, RawWakerVTable, Context}; - -// See if we can run a basic `async fn` -pub async fn foo(x: &u32, y: u32) -> u32 { - let y = &y; - let z = 9; - let z = &z; - let y = await!(async { *y + *z }); - let a = 10; - let a = &a; - *x + y + *a -} - -fn raw_waker_clone(_this: *const ()) -> RawWaker { - panic!("unimplemented"); -} -fn raw_waker_wake(_this: *const ()) { - panic!("unimplemented"); -} -fn raw_waker_wake_by_ref(_this: *const ()) { - panic!("unimplemented"); -} -fn raw_waker_drop(_this: *const ()) {} - -static RAW_WAKER: RawWakerVTable = RawWakerVTable::new( - raw_waker_clone, - raw_waker_wake, - raw_waker_wake_by_ref, - raw_waker_drop, -); - -fn main() { - let x = 5; - let mut fut = foo(&x, 7); - let waker = unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &RAW_WAKER)) }; - let mut context = Context::from_waker(&waker); - assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(31)); -} diff --git a/tests/run-pass/atomic-access-bool.rs b/tests/run-pass/atomic-access-bool.rs deleted file mode 100644 index 68a5d7295f..0000000000 --- a/tests/run-pass/atomic-access-bool.rs +++ /dev/null @@ -1,19 +0,0 @@ -use std::sync::atomic::{AtomicBool, Ordering::*}; - -static mut ATOMIC: AtomicBool = AtomicBool::new(false); - -fn main() { - unsafe { - assert_eq!(*ATOMIC.get_mut(), false); - ATOMIC.store(true, SeqCst); - assert_eq!(*ATOMIC.get_mut(), true); - ATOMIC.fetch_or(false, SeqCst); - assert_eq!(*ATOMIC.get_mut(), true); - ATOMIC.fetch_and(false, SeqCst); - assert_eq!(*ATOMIC.get_mut(), false); - ATOMIC.fetch_nand(true, SeqCst); - assert_eq!(*ATOMIC.get_mut(), true); - ATOMIC.fetch_xor(true, SeqCst); - assert_eq!(*ATOMIC.get_mut(), false); - } -} diff --git a/tests/run-pass/atomic-compare_exchange.rs b/tests/run-pass/atomic-compare_exchange.rs deleted file mode 100644 index 575b53fb44..0000000000 --- a/tests/run-pass/atomic-compare_exchange.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::sync::atomic::{AtomicIsize, Ordering::*}; - -static ATOMIC: AtomicIsize = AtomicIsize::new(0); - -fn main() { - // Make sure trans can emit all the intrinsics correctly - assert_eq!(ATOMIC.compare_exchange(0, 1, Relaxed, Relaxed), Ok(0)); - assert_eq!(ATOMIC.compare_exchange(0, 2, Acquire, Relaxed), Err(1)); - assert_eq!(ATOMIC.compare_exchange(0, 1, Release, Relaxed), Err(1)); - assert_eq!(ATOMIC.compare_exchange(1, 0, AcqRel, Relaxed), Ok(1)); - ATOMIC.compare_exchange(0, 1, SeqCst, Relaxed).ok(); - ATOMIC.compare_exchange(0, 1, Acquire, Acquire).ok(); - ATOMIC.compare_exchange(0, 1, AcqRel, Acquire).ok(); - ATOMIC.compare_exchange(0, 1, SeqCst, Acquire).ok(); - ATOMIC.compare_exchange(0, 1, SeqCst, SeqCst).ok(); - - ATOMIC.store(0, SeqCst); - - assert_eq!(ATOMIC.compare_exchange_weak(0, 1, Relaxed, Relaxed), Ok(0)); - assert_eq!(ATOMIC.compare_exchange_weak(0, 2, Acquire, Relaxed), Err(1)); - assert_eq!(ATOMIC.compare_exchange_weak(0, 1, Release, Relaxed), Err(1)); - assert_eq!(ATOMIC.compare_exchange_weak(1, 0, AcqRel, Relaxed), Ok(1)); - ATOMIC.compare_exchange_weak(0, 1, AcqRel, Relaxed).ok(); - ATOMIC.compare_exchange_weak(0, 1, SeqCst, Relaxed).ok(); - ATOMIC.compare_exchange_weak(0, 1, Acquire, Acquire).ok(); - ATOMIC.compare_exchange_weak(0, 1, AcqRel, Acquire).ok(); - ATOMIC.compare_exchange_weak(0, 1, SeqCst, Acquire).ok(); - ATOMIC.compare_exchange_weak(0, 1, SeqCst, SeqCst).ok(); -} diff --git a/tests/run-pass/bad_substs.rs b/tests/run-pass/bad_substs.rs deleted file mode 100644 index d8da2de5d6..0000000000 --- a/tests/run-pass/bad_substs.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let f: fn(i32) -> Option = Some::; - f(42); -} diff --git a/tests/run-pass/binops.rs b/tests/run-pass/binops.rs deleted file mode 100644 index 1d03c8b3d0..0000000000 --- a/tests/run-pass/binops.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Binop corner cases - -fn test_nil() { - assert_eq!((), ()); - assert!((!(() != ()))); - assert!((!(() < ()))); - assert!((() <= ())); - assert!((!(() > ()))); - assert!((() >= ())); -} - -fn test_bool() { - assert!((!(true < false))); - assert!((!(true <= false))); - assert!((true > false)); - assert!((true >= false)); - - assert!((false < true)); - assert!((false <= true)); - assert!((!(false > true))); - assert!((!(false >= true))); - - // Bools support bitwise binops - assert_eq!(false & false, false); - assert_eq!(true & false, false); - assert_eq!(true & true, true); - assert_eq!(false | false, false); - assert_eq!(true | false, true); - assert_eq!(true | true, true); - assert_eq!(false ^ false, false); - assert_eq!(true ^ false, true); - assert_eq!(true ^ true, false); -} - -fn test_ptr() { - unsafe { - let p1: *const u8 = ::std::mem::transmute(0_usize); - let p2: *const u8 = ::std::mem::transmute(0_usize); - let p3: *const u8 = ::std::mem::transmute(1_usize); - - assert_eq!(p1, p2); - assert!(p1 != p3); - assert!(p1 < p3); - assert!(p1 <= p3); - assert!(p3 > p1); - assert!(p3 >= p3); - assert!(p1 <= p2); - assert!(p1 >= p2); - } -} - -#[derive(PartialEq, Debug)] -struct P { - x: isize, - y: isize, -} - -fn p(x: isize, y: isize) -> P { - P { - x: x, - y: y - } -} - -fn test_class() { - let q = p(1, 2); - let mut r = p(1, 2); - - assert_eq!(q, r); - r.y = 17; - assert!((r.y != q.y)); - assert_eq!(r.y, 17); - assert!((q != r)); -} - -pub fn main() { - test_nil(); - test_bool(); - test_ptr(); - test_class(); -} diff --git a/tests/run-pass/bools.rs b/tests/run-pass/bools.rs deleted file mode 100644 index 30fc14704d..0000000000 --- a/tests/run-pass/bools.rs +++ /dev/null @@ -1,29 +0,0 @@ -fn boolean() -> bool { - true -} - -fn if_false() -> i64 { - let c = false; - if c { 1 } else { 0 } -} - -fn if_true() -> i64 { - let c = true; - if c { 1 } else { 0 } -} - -fn match_bool() -> i16 { - let b = true; - match b { - true => 1, - _ => 0, - } -} - -fn main() { - assert!(boolean()); - assert_eq!(if_false(), 0); - assert_eq!(if_true(), 1); - assert_eq!(match_bool(), 1); - assert_eq!(true == true, true); -} diff --git a/tests/run-pass/box-pair-to-vec.rs b/tests/run-pass/box-pair-to-vec.rs deleted file mode 100644 index 353afb9d32..0000000000 --- a/tests/run-pass/box-pair-to-vec.rs +++ /dev/null @@ -1,28 +0,0 @@ -#[repr(C)] -#[derive(Debug)] -struct PairFoo { - fst: Foo, - snd: Foo, -} - -#[derive(Debug)] -struct Foo(u64); -fn reinterstruct(box_pair: Box) -> Vec { - let ref_pair = Box::leak(box_pair) as *mut PairFoo; - let ptr_foo = unsafe { &mut (*ref_pair).fst as *mut Foo }; - unsafe { - Vec::from_raw_parts(ptr_foo, 2, 2) - } -} - -fn main() { - let pair_foo = Box::new(PairFoo { - fst: Foo(42), - snd: Foo(1337), - }); - println!("pair_foo = {:?}", pair_foo); - for (n, foo) in reinterstruct(pair_foo).into_iter().enumerate() { - println!("foo #{} = {:?}", n, foo); - } -} - diff --git a/tests/run-pass/box-pair-to-vec.stdout b/tests/run-pass/box-pair-to-vec.stdout deleted file mode 100644 index 230ef368da..0000000000 --- a/tests/run-pass/box-pair-to-vec.stdout +++ /dev/null @@ -1,3 +0,0 @@ -pair_foo = PairFoo { fst: Foo(42), snd: Foo(1337) } -foo #0 = Foo(42) -foo #1 = Foo(1337) diff --git a/tests/run-pass/box_box_trait.rs b/tests/run-pass/box_box_trait.rs deleted file mode 100644 index 7fe568522d..0000000000 --- a/tests/run-pass/box_box_trait.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![feature(box_syntax)] - -struct DroppableStruct; - -static mut DROPPED: bool = false; - -impl Drop for DroppableStruct { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} - -trait MyTrait { fn dummy(&self) { } } -impl MyTrait for Box {} - -#[allow(dead_code)] -struct Whatever { w: Box } - -impl Whatever { - fn new(w: Box) -> Whatever { - Whatever { w: w } - } -} - -fn main() { - { - let f: Box<_> = box DroppableStruct; - let _a = Whatever::new(box f as Box); - } - assert!(unsafe { DROPPED }); -} diff --git a/tests/run-pass/btreemap.rs b/tests/run-pass/btreemap.rs deleted file mode 100644 index e2049d9480..0000000000 --- a/tests/run-pass/btreemap.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::collections::{BTreeMap, BTreeSet}; - -#[derive(PartialEq, Eq, PartialOrd, Ord)] -pub enum Foo { - A(&'static str), - _B, - _C, -} - -pub fn main() { - let mut b = BTreeSet::new(); - b.insert(Foo::A("\'")); - b.insert(Foo::A("/=")); - b.insert(Foo::A("#")); - b.insert(Foo::A("0o")); - assert!(b.remove(&Foo::A("/="))); - assert!(!b.remove(&Foo::A("/="))); - - // Also test a lower-alignment type, where the NodeHeader overlaps with - // the keys. - let mut b = BTreeSet::new(); - b.insert(1024); - b.insert(7); - - let mut b = BTreeMap::new(); - b.insert("bar", 1024); - b.insert("baz", 7); - for _val in b.iter_mut() {} -} diff --git a/tests/run-pass/c_enums.rs b/tests/run-pass/c_enums.rs deleted file mode 100644 index 11897b73eb..0000000000 --- a/tests/run-pass/c_enums.rs +++ /dev/null @@ -1,32 +0,0 @@ -enum Foo { - Bar = 42, - Baz, - Quux = 100, -} - -enum Signed { - Bar = -42, - Baz, - Quux = 100, -} - -fn foo() -> [u8; 3] { - [Foo::Bar as u8, Foo::Baz as u8, Foo::Quux as u8] -} - -fn signed() -> [i8; 3] { - [Signed::Bar as i8, Signed::Baz as i8, Signed::Quux as i8] -} - -fn unsafe_match() -> bool { - match unsafe { std::mem::transmute::(43) } { - Foo::Baz => true, - _ => false, - } -} - -fn main() { - assert_eq!(foo(), [42, 43, 100]); - assert_eq!(signed(), [-42, -41, 100]); - assert!(unsafe_match()); -} diff --git a/tests/run-pass/call_drop_on_array_elements.rs b/tests/run-pass/call_drop_on_array_elements.rs deleted file mode 100644 index c9b59f635e..0000000000 --- a/tests/run-pass/call_drop_on_array_elements.rs +++ /dev/null @@ -1,22 +0,0 @@ -struct Bar(u16); // ZSTs are tested separately - -static mut DROP_COUNT: usize = 0; - -impl Drop for Bar { - fn drop(&mut self) { - assert_eq!(self.0 as usize, unsafe { DROP_COUNT }); // tests whether we are called at a valid address - unsafe { DROP_COUNT += 1; } - } -} - -fn main() { - let b = [Bar(0), Bar(1), Bar(2), Bar(3)]; - assert_eq!(unsafe { DROP_COUNT }, 0); - drop(b); - assert_eq!(unsafe { DROP_COUNT }, 4); - - // check empty case - let b : [Bar; 0] = []; - drop(b); - assert_eq!(unsafe { DROP_COUNT }, 4); -} diff --git a/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs b/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs deleted file mode 100644 index a1ab5c45e3..0000000000 --- a/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs +++ /dev/null @@ -1,20 +0,0 @@ -trait Foo {} - -struct Bar; - -impl Foo for Bar {} - -static mut DROP_COUNT: usize = 0; - -impl Drop for Bar { - fn drop(&mut self) { - unsafe { DROP_COUNT += 1; } - } -} - -fn main() { - let b: [Box; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)]; - assert_eq!(unsafe { DROP_COUNT }, 0); - drop(b); - assert_eq!(unsafe { DROP_COUNT }, 4); -} diff --git a/tests/run-pass/call_drop_on_zst_array_elements.rs b/tests/run-pass/call_drop_on_zst_array_elements.rs deleted file mode 100644 index 1887130fdd..0000000000 --- a/tests/run-pass/call_drop_on_zst_array_elements.rs +++ /dev/null @@ -1,21 +0,0 @@ -struct Bar; - -static mut DROP_COUNT: usize = 0; - -impl Drop for Bar { - fn drop(&mut self) { - unsafe { DROP_COUNT += 1; } - } -} - -fn main() { - let b = [Bar, Bar, Bar, Bar]; - assert_eq!(unsafe { DROP_COUNT }, 0); - drop(b); - assert_eq!(unsafe { DROP_COUNT }, 4); - - // check empty case - let b : [Bar; 0] = []; - drop(b); - assert_eq!(unsafe { DROP_COUNT }, 4); -} diff --git a/tests/run-pass/call_drop_through_owned_slice.rs b/tests/run-pass/call_drop_through_owned_slice.rs deleted file mode 100644 index 3ec6be65ed..0000000000 --- a/tests/run-pass/call_drop_through_owned_slice.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct Bar; - -static mut DROP_COUNT: usize = 0; - -impl Drop for Bar { - fn drop(&mut self) { - unsafe { DROP_COUNT += 1; } - } -} - -fn main() { - let b: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_slice(); - assert_eq!(unsafe { DROP_COUNT }, 0); - drop(b); - assert_eq!(unsafe { DROP_COUNT }, 4); -} diff --git a/tests/run-pass/call_drop_through_trait_object.rs b/tests/run-pass/call_drop_through_trait_object.rs deleted file mode 100644 index 9b6acf0b14..0000000000 --- a/tests/run-pass/call_drop_through_trait_object.rs +++ /dev/null @@ -1,20 +0,0 @@ -trait Foo {} - -struct Bar; - -static mut DROP_CALLED: bool = false; - -impl Drop for Bar { - fn drop(&mut self) { - unsafe { DROP_CALLED = true; } - } -} - -impl Foo for Bar {} - -fn main() { - let b: Box = Box::new(Bar); - assert!(unsafe { !DROP_CALLED }); - drop(b); - assert!(unsafe { DROP_CALLED }); -} diff --git a/tests/run-pass/call_drop_through_trait_object_rc.rs b/tests/run-pass/call_drop_through_trait_object_rc.rs deleted file mode 100644 index ce56ca6a1c..0000000000 --- a/tests/run-pass/call_drop_through_trait_object_rc.rs +++ /dev/null @@ -1,22 +0,0 @@ -trait Foo {} - -struct Bar; - -static mut DROP_CALLED: bool = false; - -impl Drop for Bar { - fn drop(&mut self) { - unsafe { DROP_CALLED = true; } - } -} - -impl Foo for Bar {} - -use std::rc::Rc; - -fn main() { - let b: Rc = Rc::new(Bar); - assert!(unsafe { !DROP_CALLED }); - drop(b); - assert!(unsafe { DROP_CALLED }); -} diff --git a/tests/run-pass/calloc.rs b/tests/run-pass/calloc.rs deleted file mode 100644 index 4c520da85e..0000000000 --- a/tests/run-pass/calloc.rs +++ /dev/null @@ -1,26 +0,0 @@ -//ignore-windows: Uses POSIX APIs - -#![feature(rustc_private)] - -use core::slice; - -extern crate libc; - -fn main() { - unsafe { - let p1 = libc::calloc(0, 0); - assert!(p1.is_null()); - - let p2 = libc::calloc(20, 0); - assert!(p2.is_null()); - - let p3 = libc::calloc(0, 20); - assert!(p3.is_null()); - - let p4 = libc::calloc(4, 8); - assert!(!p4.is_null()); - let slice = slice::from_raw_parts(p4 as *const u8, 4 * 8); - assert_eq!(&slice, &[0_u8; 4 * 8]); - libc::free(p4); - } -} diff --git a/tests/run-pass/calls.rs b/tests/run-pass/calls.rs deleted file mode 100644 index c4ba4a9b70..0000000000 --- a/tests/run-pass/calls.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![feature(const_fn)] - -fn call() -> i32 { - fn increment(x: i32) -> i32 { - x + 1 - } - increment(1) -} - -fn factorial_recursive() -> i64 { - fn fact(n: i64) -> i64 { - if n == 0 { - 1 - } else { - n * fact(n - 1) - } - } - fact(10) -} - -fn call_generic() -> (i16, bool) { - fn id(t: T) -> T { t } - (id(42), id(true)) -} - -// Test calling a very simple function from the standard library. -fn cross_crate_fn_call() -> i64 { - if 1i32.is_positive() { 1 } else { 0 } -} - -const fn foo(i: i64) -> i64 { *&i + 1 } - -fn const_fn_call() -> i64 { - let x = 5 + foo(5); - assert_eq!(x, 11); - x -} - -fn main() { - assert_eq!(call(), 2); - assert_eq!(factorial_recursive(), 3628800); - assert_eq!(call_generic(), (42, true)); - assert_eq!(cross_crate_fn_call(), 1); - assert_eq!(const_fn_call(), 11); -} diff --git a/tests/run-pass/cast-rfc0401-vtable-kinds.rs b/tests/run-pass/cast-rfc0401-vtable-kinds.rs deleted file mode 100644 index 6442eab30a..0000000000 --- a/tests/run-pass/cast-rfc0401-vtable-kinds.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Check that you can cast between different pointers to trait objects -// whose vtable have the same kind (both lengths, or both trait pointers). - -trait Foo { - fn foo(&self, _: T) -> u32 { 42 } -} - -trait Bar { - fn bar(&self) { println!("Bar!"); } -} - -impl Foo for () {} -impl Foo for u32 { fn foo(&self, _: u32) -> u32 { self+43 } } -impl Bar for () {} - -unsafe fn round_trip_and_call<'a>(t: *const (Foo+'a)) -> u32 { - let foo_e : *const Foo = t as *const _; - let r_1 = foo_e as *mut Foo; - - (&*r_1).foo(0) -} - -#[repr(C)] -struct FooS(T); -#[repr(C)] -struct BarS(T); - -fn foo_to_bar(u: *const FooS) -> *const BarS { - u as *const BarS -} - -fn main() { - let x = 4u32; - let y : &Foo = &x; - let fl = unsafe { round_trip_and_call(y as *const Foo) }; - assert_eq!(fl, (43+4)); - - let s = FooS([0,1,2]); - let u: &FooS<[u32]> = &s; - let u: *const FooS<[u32]> = u; - let bar_ref : *const BarS<[u32]> = foo_to_bar(u); - let z : &BarS<[u32]> = unsafe{&*bar_ref}; - assert_eq!(&z.0, &[0,1,2]); - // If validation fails here, that's likely because an immutable suspension is recovered mutably. -} diff --git a/tests/run-pass/cast_fn_ptr.rs b/tests/run-pass/cast_fn_ptr.rs deleted file mode 100644 index 109e8dfc2a..0000000000 --- a/tests/run-pass/cast_fn_ptr.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - fn f(_: *const u8) {} - - let g = unsafe { - std::mem::transmute::(f) - }; - - g(&42 as *const _); -} diff --git a/tests/run-pass/cast_fn_ptr_unsafe.rs b/tests/run-pass/cast_fn_ptr_unsafe.rs deleted file mode 100644 index 0cabb369bf..0000000000 --- a/tests/run-pass/cast_fn_ptr_unsafe.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - fn f() {} - - let g = f as fn() as unsafe fn(); - unsafe { - g(); - } -} diff --git a/tests/run-pass/catch.rs b/tests/run-pass/catch.rs deleted file mode 100644 index 5fd65f138a..0000000000 --- a/tests/run-pass/catch.rs +++ /dev/null @@ -1,7 +0,0 @@ -use std::panic::{catch_unwind, AssertUnwindSafe}; - -fn main() { - let mut i = 3; - let _val = catch_unwind(AssertUnwindSafe(|| {i -= 2;} )); - println!("{}", i); -} diff --git a/tests/run-pass/catch.stdout b/tests/run-pass/catch.stdout deleted file mode 100644 index d00491fd7e..0000000000 --- a/tests/run-pass/catch.stdout +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/tests/run-pass/char.rs b/tests/run-pass/char.rs deleted file mode 100644 index 5524f0ae7a..0000000000 --- a/tests/run-pass/char.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - let c = 'x'; - assert_eq!(c, 'x'); - assert!('a' < 'z'); - assert!('1' < '9'); - assert_eq!(std::char::from_u32('x' as u32), Some('x')); -} diff --git a/tests/run-pass/closure-drop.rs b/tests/run-pass/closure-drop.rs deleted file mode 100644 index 374efb6032..0000000000 --- a/tests/run-pass/closure-drop.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct Foo<'a>(&'a mut bool); - -impl<'a> Drop for Foo<'a> { - fn drop(&mut self) { - *self.0 = true; - } -} - -fn f(t: T) { - t() -} - -fn main() { - let mut ran_drop = false; - { - let x = Foo(&mut ran_drop); - // this closure never by val uses its captures - // so it's basically a fn(&self) - // the shim used to not drop the `x` - let x = move || { let _val = x; }; - f(x); - } - assert!(ran_drop); -} - diff --git a/tests/run-pass/closure-field-ty.rs b/tests/run-pass/closure-field-ty.rs deleted file mode 100644 index 0d27728d22..0000000000 --- a/tests/run-pass/closure-field-ty.rs +++ /dev/null @@ -1,10 +0,0 @@ -// miri issue #304 -fn main() { - let mut y = 0; - { - let mut box_maybe_closure = Box::new(None); - *box_maybe_closure = Some(|| { y += 1; }); - (box_maybe_closure.unwrap())(); - } - assert_eq!(y, 1); -} diff --git a/tests/run-pass/closures.rs b/tests/run-pass/closures.rs deleted file mode 100644 index 141e6cd6d0..0000000000 --- a/tests/run-pass/closures.rs +++ /dev/null @@ -1,53 +0,0 @@ -fn simple() -> i32 { - let y = 10; - let f = |x| x + y; - f(2) -} - -fn crazy_closure() -> (i32, i32, i32) { - fn inner(t: T) -> (i32, T, T) { - struct NonCopy; - let x = NonCopy; - - let a = 2; - let b = 40; - let f = move |y, z, asdf| { - drop(x); - (a + b + y + z, asdf, t) - }; - f(a, b, t) - } - - inner(10) -} - -fn closure_arg_adjustment_problem() -> i64 { - fn once(f: F) { f(2); } - let mut y = 1; - { - let f = |x| y += x; - once(f); - } - y -} - -fn fn_once_closure_with_multiple_args() -> i64 { - fn once i64>(f: F) -> i64 { f(2, 3) } - let y = 1; - { - let f = |x, z| x + y + z; - once(f) - } -} - -fn boxed(f: Box i32>) -> i32 { - f() -} - -fn main() { - assert_eq!(simple(), 12); - assert_eq!(crazy_closure(), (84, 10, 10)); - assert_eq!(closure_arg_adjustment_problem(), 3); - assert_eq!(fn_once_closure_with_multiple_args(), 6); - assert_eq!(boxed(Box::new({let x = 13; move || x})), 13); -} diff --git a/tests/run-pass/const-vec-of-fns.rs b/tests/run-pass/const-vec-of-fns.rs deleted file mode 100644 index 9b6c6fcc32..0000000000 --- a/tests/run-pass/const-vec-of-fns.rs +++ /dev/null @@ -1,17 +0,0 @@ -/*! - * Try to double-check that static fns have the right size (with or - * without dummy env ptr, as appropriate) by iterating a size-2 array. - * If the static size differs from the runtime size, the second element - * should be read as a null or otherwise wrong pointer and crash. - */ - -fn f() { } -static mut CLOSURES: &'static mut [fn()] = &mut [f as fn(), f as fn()]; - -pub fn main() { - unsafe { - for closure in &mut *CLOSURES { - (*closure)() - } - } -} diff --git a/tests/run-pass/constants.rs b/tests/run-pass/constants.rs deleted file mode 100644 index 718c852601..0000000000 --- a/tests/run-pass/constants.rs +++ /dev/null @@ -1,9 +0,0 @@ -const A: usize = *&5; - -fn foo() -> usize { - A -} - -fn main() { - assert_eq!(foo(), A); -} diff --git a/tests/run-pass/deriving-associated-types.rs b/tests/run-pass/deriving-associated-types.rs deleted file mode 100644 index 52104d8486..0000000000 --- a/tests/run-pass/deriving-associated-types.rs +++ /dev/null @@ -1,198 +0,0 @@ -pub trait DeclaredTrait { - type Type; -} - -impl DeclaredTrait for i32 { - type Type = i32; -} - -pub trait WhereTrait { - type Type; -} - -impl WhereTrait for i32 { - type Type = i32; -} - -// Make sure we don't add a bound that just shares a name with an associated -// type. -pub mod module { - pub type Type = i32; -} - -#[derive(PartialEq, Debug)] -struct PrivateStruct(T); - -#[derive(PartialEq, Debug)] -struct TupleStruct( - module::Type, - Option, - A, - PrivateStruct, - B, - B::Type, - Option, - ::Type, - Option<::Type>, - C, - C::Type, - Option, - ::Type, - Option<::Type>, - ::Type, -) where C: WhereTrait; - -#[derive(PartialEq, Debug)] -pub struct Struct where C: WhereTrait { - m1: module::Type, - m2: Option, - a1: A, - a2: PrivateStruct, - b: B, - b1: B::Type, - b2: Option, - b3: ::Type, - b4: Option<::Type>, - c: C, - c1: C::Type, - c2: Option, - c3: ::Type, - c4: Option<::Type>, - d: ::Type, -} - -#[derive(PartialEq, Debug)] -enum Enum where C: WhereTrait { - Unit, - Seq( - module::Type, - Option, - A, - PrivateStruct, - B, - B::Type, - Option, - ::Type, - Option<::Type>, - C, - C::Type, - Option, - ::Type, - Option<::Type>, - ::Type, - ), - Map { - m1: module::Type, - m2: Option, - a1: A, - a2: PrivateStruct, - b: B, - b1: B::Type, - b2: Option, - b3: ::Type, - b4: Option<::Type>, - c: C, - c1: C::Type, - c2: Option, - c3: ::Type, - c4: Option<::Type>, - d: ::Type, - }, -} - -fn main() { - - let e: Enum< - i32, - i32, - i32, - > = Enum::Seq( - 0, - None, - 0, - PrivateStruct(0), - 0, - 0, - None, - 0, - None, - 0, - 0, - None, - 0, - None, - 0, - ); - assert_eq!(e, e); - - let e: Enum< - i32, - i32, - i32, - > = Enum::Map { - m1: 0, - m2: None, - a1: 0, - a2: PrivateStruct(0), - b: 0, - b1: 0, - b2: None, - b3: 0, - b4: None, - c: 0, - c1: 0, - c2: None, - c3: 0, - c4: None, - d: 0, - }; - assert_eq!(e, e); - let e: TupleStruct< - i32, - i32, - i32, - > = TupleStruct( - 0, - None, - 0, - PrivateStruct(0), - 0, - 0, - None, - 0, - None, - 0, - 0, - None, - 0, - None, - 0, - ); - assert_eq!(e, e); - - let e: Struct< - i32, - i32, - i32, - > = Struct { - m1: 0, - m2: None, - a1: 0, - a2: PrivateStruct(0), - b: 0, - b1: 0, - b2: None, - b3: 0, - b4: None, - c: 0, - c1: 0, - c2: None, - c3: 0, - c4: None, - d: 0, - }; - assert_eq!(e, e); - - let e = Enum::Unit::; - assert_eq!(e, e); -} diff --git a/tests/run-pass/drop_empty_slice.rs b/tests/run-pass/drop_empty_slice.rs deleted file mode 100644 index 8b481a0a2d..0000000000 --- a/tests/run-pass/drop_empty_slice.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(box_syntax)] - -fn main() { - // With the nested Vec, this is calling Offset(Unique::empty(), 0) on drop. - let args : Vec> = Vec::new(); - let _val = box args; -} diff --git a/tests/run-pass/dst-field-align.rs b/tests/run-pass/dst-field-align.rs deleted file mode 100644 index b8e9815640..0000000000 --- a/tests/run-pass/dst-field-align.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(dead_code)] - -struct Foo { - a: u16, - b: T -} - -trait Bar { - fn get(&self) -> usize; -} - -impl Bar for usize { - fn get(&self) -> usize { *self } -} - -struct Baz { - a: T -} - -struct HasDrop { - ptr: Box, - data: T -} - -fn main() { - // Test that zero-offset works properly - let b : Baz = Baz { a: 7 }; - assert_eq!(b.a.get(), 7); - let b : &Baz = &b; - assert_eq!(b.a.get(), 7); - - // Test that the field is aligned properly - let f : Foo = Foo { a: 0, b: 11 }; - assert_eq!(f.b.get(), 11); - let ptr1 : *const u8 = &f.b as *const _ as *const u8; - - let f : &Foo = &f; - let ptr2 : *const u8 = &f.b as *const _ as *const u8; - assert_eq!(f.b.get(), 11); - - // The pointers should be the same - assert_eq!(ptr1, ptr2); - - // Test that nested DSTs work properly - let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; - assert_eq!(f.b.b.get(), 17); - let f : &Foo> = &f; - assert_eq!(f.b.b.get(), 17); - - // Test that get the pointer via destructuring works - - let f : Foo = Foo { a: 0, b: 11 }; - let f : &Foo = &f; - let &Foo { a: _, b: ref bar } = f; - assert_eq!(bar.get(), 11); - - // Make sure that drop flags don't screw things up - - let d : HasDrop> = HasDrop { - ptr: Box::new(0), - data: Baz { a: [1,2,3,4] } - }; - assert_eq!([1,2,3,4], d.data.a); - - let d : &HasDrop> = &d; - assert_eq!(&[1,2,3,4], &d.data.a); -} diff --git a/tests/run-pass/dst-irrefutable-bind.rs b/tests/run-pass/dst-irrefutable-bind.rs deleted file mode 100644 index eeddfce75f..0000000000 --- a/tests/run-pass/dst-irrefutable-bind.rs +++ /dev/null @@ -1,14 +0,0 @@ -struct Test(T); - -fn main() { - let x = Test([1,2,3]); - let x : &Test<[i32]> = &x; - - let & ref _y = x; - - // Make sure binding to a fat pointer behind a reference - // still works - let slice = &[1,2,3]; - let x = Test(&slice); - let Test(&_slice) = x; -} diff --git a/tests/run-pass/dst-raw.rs b/tests/run-pass/dst-raw.rs deleted file mode 100644 index a3ee982d19..0000000000 --- a/tests/run-pass/dst-raw.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Test DST raw pointers - - -trait Trait { - fn foo(&self) -> isize; -} - -struct A { - f: isize -} -impl Trait for A { - fn foo(&self) -> isize { - self.f - } -} - -struct Foo { - f: T -} - -pub fn main() { - // raw trait object - let x = A { f: 42 }; - let z: *const Trait = &x; - let r = unsafe { - (&*z).foo() - }; - assert_eq!(r, 42); - - // raw DST struct - let p = Foo {f: A { f: 42 }}; - let o: *const Foo = &p; - let r = unsafe { - (&*o).f.foo() - }; - assert_eq!(r, 42); - - // raw slice - let a: *const [_] = &[1, 2, 3]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - // raw slice with explicit cast - let a = &[1, 2, 3] as *const [i32]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - // raw DST struct with slice - let c: *const Foo<[_]> = &Foo {f: [1, 2, 3]}; - unsafe { - let b = (&*c).f[0]; - assert_eq!(b, 1); - let len = (&*c).f.len(); - assert_eq!(len, 3); - } - - // all of the above with *mut - let mut x = A { f: 42 }; - let z: *mut Trait = &mut x; - let r = unsafe { - (&*z).foo() - }; - assert_eq!(r, 42); - - let mut p = Foo {f: A { f: 42 }}; - let o: *mut Foo = &mut p; - let r = unsafe { - (&*o).f.foo() - }; - assert_eq!(r, 42); - - let a: *mut [_] = &mut [1, 2, 3]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - let a = &mut [1, 2, 3] as *mut [i32]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - let c: *mut Foo<[_]> = &mut Foo {f: [1, 2, 3]}; - unsafe { - let b = (&*c).f[0]; - assert_eq!(b, 1); - let len = (&*c).f.len(); - assert_eq!(len, 3); - } -} diff --git a/tests/run-pass/dst-struct-sole.rs b/tests/run-pass/dst-struct-sole.rs deleted file mode 100644 index 770af864a4..0000000000 --- a/tests/run-pass/dst-struct-sole.rs +++ /dev/null @@ -1,75 +0,0 @@ -// As dst-struct.rs, but the unsized field is the only field in the struct. - - -struct Fat { - ptr: T -} - -// x is a fat pointer -fn foo(x: &Fat<[isize]>) { - let y = &x.ptr; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.ptr[1], 2); -} - -fn foo2(x: &Fat<[T]>) { - let y = &x.ptr; - let bar = Bar; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0].to_bar(), bar); - assert_eq!(x.ptr[1].to_bar(), bar); -} - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -trait ToBar { - fn to_bar(&self) -> Bar; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } -} - -pub fn main() { - // With a vec of ints. - let f1 = Fat { ptr: [1, 2, 3] }; - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat<[isize]> = f2; - foo(f3); - let f4: &Fat<[isize]> = &f1; - foo(f4); - let f5: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; - foo(f5); - - // With a vec of Bars. - let bar = Bar; - let f1 = Fat { ptr: [bar, bar, bar] }; - foo2(&f1); - let f2 = &f1; - foo2(f2); - let f3: &Fat<[Bar]> = f2; - foo2(f3); - let f4: &Fat<[Bar]> = &f1; - foo2(f4); - let f5: &Fat<[Bar]> = &Fat { ptr: [bar, bar, bar] }; - foo2(f5); - - // Assignment. - let f5: &mut Fat<[isize]> = &mut Fat { ptr: [1, 2, 3] }; - f5.ptr[1] = 34; - assert_eq!(f5.ptr[0], 1); - assert_eq!(f5.ptr[1], 34); - assert_eq!(f5.ptr[2], 3); - - // Zero size vec. - let f5: &Fat<[isize]> = &Fat { ptr: [] }; - assert!(f5.ptr.is_empty()); - let f5: &Fat<[Bar]> = &Fat { ptr: [] }; - assert!(f5.ptr.is_empty()); -} diff --git a/tests/run-pass/dst-struct.rs b/tests/run-pass/dst-struct.rs deleted file mode 100644 index bd6517bd1f..0000000000 --- a/tests/run-pass/dst-struct.rs +++ /dev/null @@ -1,123 +0,0 @@ -#![feature(box_syntax)] - -struct Fat { - f1: isize, - f2: &'static str, - ptr: T -} - -// x is a fat pointer -fn foo(x: &Fat<[isize]>) { - let y = &x.ptr; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.ptr[1], 2); - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); -} - -fn foo2(x: &Fat<[T]>) { - let y = &x.ptr; - let bar = Bar; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0].to_bar(), bar); - assert_eq!(x.ptr[1].to_bar(), bar); - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); -} - -fn foo3(x: &Fat>) { - let y = &x.ptr.ptr; - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); - assert_eq!(x.ptr.f1, 8); - assert_eq!(x.ptr.f2, "deep str"); - assert_eq!(x.ptr.ptr.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.ptr.ptr[1], 2); -} - - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -trait ToBar { - fn to_bar(&self) -> Bar; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } -} - -pub fn main() { - // With a vec of ints. - let f1 : Fat<[isize; 3]> = Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(&f1); - let f2 : &Fat<[isize; 3]> = &f1; - foo(f2); - let f3: &Fat<[isize]> = f2; - foo(f3); - let f4: &Fat<[isize]> = &f1; - foo(f4); - let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(f5); - - // With a vec of Bars. - let bar = Bar; - let f1 = Fat { f1: 5, f2: "some str", ptr: [bar, bar, bar] }; - foo2(&f1); - let f2 = &f1; - foo2(f2); - let f3: &Fat<[Bar]> = f2; - foo2(f3); - let f4: &Fat<[Bar]> = &f1; - foo2(f4); - let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [bar, bar, bar] }; - foo2(f5); - - // Assignment. - let f5: &mut Fat<[isize]> = &mut Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - f5.ptr[1] = 34; - assert_eq!(f5.ptr[0], 1); - assert_eq!(f5.ptr[1], 34); - assert_eq!(f5.ptr[2], 3); - - // Zero size vec. - let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [] }; - assert!(f5.ptr.is_empty()); - let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [] }; - assert!(f5.ptr.is_empty()); - - // Deeply nested. - let f1 = Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} }; - foo3(&f1); - let f2 = &f1; - foo3(f2); - let f3: &Fat> = f2; - foo3(f3); - let f4: &Fat> = &f1; - foo3(f4); - let f5: &Fat> = - &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} }; - foo3(f5); - - // Box. - let f1 = Box::new([1, 2, 3]); - assert_eq!((*f1)[1], 2); - let f2: Box<[isize]> = f1; - assert_eq!((*f2)[1], 2); - - // Nested Box. - let f1 : Box> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(&*f1); - let f2 : Box> = f1; - foo(&*f2); - - let f3 : Box> = - Box::>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }); - foo(&*f3); - let f4 : Box> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(&*f4); -} diff --git a/tests/run-pass/enum-nullable-const-null-with-fields.rs b/tests/run-pass/enum-nullable-const-null-with-fields.rs deleted file mode 100644 index 87389c9c3a..0000000000 --- a/tests/run-pass/enum-nullable-const-null-with-fields.rs +++ /dev/null @@ -1,12 +0,0 @@ - -use std::result::Result; -use std::result::Result::Ok; - -static C: Result<(), Box> = Ok(()); - -// This is because of yet another bad assertion (ICE) about the null side of a nullable enum. -// So we won't actually compile if the bug is present, but we check the value in main anyway. - -pub fn main() { - assert!(C.is_ok()); -} diff --git a/tests/run-pass/enums.rs b/tests/run-pass/enums.rs deleted file mode 100644 index 1f27292904..0000000000 --- a/tests/run-pass/enums.rs +++ /dev/null @@ -1,34 +0,0 @@ -enum MyEnum { - MyEmptyVariant, - MyNewtypeVariant(i32), - MyTupleVariant(i32, i32), - MyStructVariant { - my_first_field: i32, - my_second_field: i32, - } -} - -fn test(me: MyEnum) { - match me { - MyEnum::MyEmptyVariant => {}, - MyEnum::MyNewtypeVariant(ref val) => assert_eq!(val, &42), - MyEnum::MyTupleVariant(ref a, ref b) => { - assert_eq!(a, &43); - assert_eq!(b, &44); - }, - MyEnum::MyStructVariant { ref my_first_field, ref my_second_field } => { - assert_eq!(my_first_field, &45); - assert_eq!(my_second_field, &46); - }, - } -} - -fn main() { - test(MyEnum::MyEmptyVariant); - test(MyEnum::MyNewtypeVariant(42)); - test(MyEnum::MyTupleVariant(43, 44)); - test(MyEnum::MyStructVariant{ - my_first_field: 45, - my_second_field: 46, - }); -} diff --git a/tests/run-pass/env.rs b/tests/run-pass/env.rs deleted file mode 100644 index 91e15f249d..0000000000 --- a/tests/run-pass/env.rs +++ /dev/null @@ -1,9 +0,0 @@ -//ignore-windows: TODO env var emulation stubbed out on Windows - -use std::env; - -fn main() { - assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent)); - env::set_var("MIRI_TEST", "the answer"); - assert_eq!(env::var("MIRI_TEST"), Ok("the answer".to_owned())); -} diff --git a/tests/run-pass/exit.rs b/tests/run-pass/exit.rs deleted file mode 100644 index d93f004537..0000000000 --- a/tests/run-pass/exit.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - std::process::exit(0) -} diff --git a/tests/run-pass/extern_types.rs b/tests/run-pass/extern_types.rs deleted file mode 100644 index b37cd8408b..0000000000 --- a/tests/run-pass/extern_types.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(extern_types)] - -extern { - type Foo; -} - -fn main() { - let x: &Foo = unsafe { &*(16 as *const Foo) }; - let _y: &Foo = &*x; -} diff --git a/tests/run-pass/float_fast_math.rs b/tests/run-pass/float_fast_math.rs deleted file mode 100644 index ba7e6ac3ec..0000000000 --- a/tests/run-pass/float_fast_math.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(core_intrinsics)] - -use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast}; - -#[inline(never)] -pub fn test_operations(a: f64, b: f64) { - // make sure they all map to the correct operation - unsafe { - assert_eq!(fadd_fast(a, b), a + b); - assert_eq!(fsub_fast(a, b), a - b); - assert_eq!(fmul_fast(a, b), a * b); - assert_eq!(fdiv_fast(a, b), a / b); - assert_eq!(frem_fast(a, b), a % b); - } -} - -fn main() { - test_operations(1., 2.); - test_operations(10., 5.); -} diff --git a/tests/run-pass/floats.rs b/tests/run-pass/floats.rs deleted file mode 100644 index 39fdbce492..0000000000 --- a/tests/run-pass/floats.rs +++ /dev/null @@ -1,15 +0,0 @@ - -fn main() { - assert_eq!(6.0_f32*6.0_f32, 36.0_f32); - assert_eq!(6.0_f64*6.0_f64, 36.0_f64); - assert_eq!(-{5.0_f32}, -5.0_f32); - assert!((5.0_f32/0.0).is_infinite()); - assert!((-5.0_f32).sqrt().is_nan()); - let x: u64 = unsafe { std::mem::transmute(42.0_f64) }; - let y: f64 = unsafe { std::mem::transmute(x) }; - assert_eq!(y, 42.0_f64); - - assert_eq!(5.0f32 as u32, 5); - assert_eq!(5.0f32 as i32, 5); - assert_eq!(-5.0f32 as i32, -5); -} diff --git a/tests/run-pass/fn_item_as_closure_trait_object.rs b/tests/run-pass/fn_item_as_closure_trait_object.rs deleted file mode 100644 index 799f97a4f6..0000000000 --- a/tests/run-pass/fn_item_as_closure_trait_object.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn foo() {} - -fn main() { - let f: &Fn() = &foo; - f(); -} diff --git a/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs b/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs deleted file mode 100644 index 79ece75c77..0000000000 --- a/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn foo(i: i32) { - assert_eq!(i, 42); -} - -fn main() { - let f: &Fn(i32) = &foo; - f(42); -} diff --git a/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs b/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs deleted file mode 100644 index f4b5b449aa..0000000000 --- a/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs +++ /dev/null @@ -1,18 +0,0 @@ -fn foo(i: i32, j: i32) { - assert_eq!(i, 42); - assert_eq!(j, 55); -} - -fn bar(i: i32, j: i32, k: f32) { - assert_eq!(i, 42); - assert_eq!(j, 55); - assert_eq!(k, 3.14159) -} - - -fn main() { - let f: &Fn(i32, i32) = &foo; - f(42, 55); - let f: &Fn(i32, i32, f32) = &bar; - f(42, 55, 3.14159); -} diff --git a/tests/run-pass/fn_ptr_as_closure_trait_object.rs b/tests/run-pass/fn_ptr_as_closure_trait_object.rs deleted file mode 100644 index 24ae1f35bb..0000000000 --- a/tests/run-pass/fn_ptr_as_closure_trait_object.rs +++ /dev/null @@ -1,15 +0,0 @@ -fn foo() {} -fn bar(u: u32) { assert_eq!(u, 42); } -fn baa(u: u32, f: f32) { - assert_eq!(u, 42); - assert_eq!(f, 3.141); -} - -fn main() { - let f: &Fn() = &(foo as fn()); - f(); - let f: &Fn(u32) = &(bar as fn(u32)); - f(42); - let f: &Fn(u32, f32) = &(baa as fn(u32, f32)); - f(42, 3.141); -} diff --git a/tests/run-pass/foreign-fn-linkname.rs b/tests/run-pass/foreign-fn-linkname.rs deleted file mode 100644 index ebb0e5364b..0000000000 --- a/tests/run-pass/foreign-fn-linkname.rs +++ /dev/null @@ -1,29 +0,0 @@ -//ignore-windows: Uses POSIX APIs - -#![feature(rustc_private)] -#![allow(unused_extern_crates)] // rustc bug https://github.com/rust-lang/rust/issues/56098 - -extern crate libc; - -use std::ffi::CString; - -mod mlibc { - use libc::{c_char, size_t}; - extern { - #[link_name = "strlen"] - pub fn my_strlen(str: *const c_char) -> size_t; - } -} - -fn strlen(str: String) -> usize { - // C string is terminated with a zero - let s = CString::new(str).unwrap(); - unsafe { - mlibc::my_strlen(s.as_ptr()) as usize - } -} - -pub fn main() { - let len = strlen("Rust".to_string()); - assert_eq!(len, 4); -} diff --git a/tests/run-pass/format.rs b/tests/run-pass/format.rs deleted file mode 100644 index 053cce3613..0000000000 --- a/tests/run-pass/format.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - println!("Hello {}", 13); - println!("{:0 Self; -} - -impl Answer for i32 { - fn answer() -> i32 { - 42 - } -} - -// A generic function, to make its address unstable -fn f() -> T { - Answer::answer() -} - -fn g(i: i32) -> i32 { - i*42 -} - -fn h(i: i32, j: i32) -> i32 { - j * i * 7 -} - -fn return_fn_ptr(f: fn() -> i32) -> fn() -> i32 { - f -} - -fn call_fn_ptr() -> i32 { - return_fn_ptr(f)() -} - -fn indirect i32>(f: F) -> i32 { f() } -fn indirect_mut i32>(mut f: F) -> i32 { f() } -fn indirect_once i32>(f: F) -> i32 { f() } - -fn indirect2 i32>(f: F) -> i32 { f(10) } -fn indirect_mut2 i32>(mut f: F) -> i32 { f(10) } -fn indirect_once2 i32>(f: F) -> i32 { f(10) } - -fn indirect3 i32>(f: F) -> i32 { f(10, 3) } -fn indirect_mut3 i32>(mut f: F) -> i32 { f(10, 3) } -fn indirect_once3 i32>(f: F) -> i32 { f(10, 3) } - -fn main() { - assert_eq!(call_fn_ptr(), 42); - assert_eq!(indirect(f), 42); - assert_eq!(indirect_mut(f), 42); - assert_eq!(indirect_once(f), 42); - assert_eq!(indirect2(g), 420); - assert_eq!(indirect_mut2(g), 420); - assert_eq!(indirect_once2(g), 420); - assert_eq!(indirect3(h), 210); - assert_eq!(indirect_mut3(h), 210); - assert_eq!(indirect_once3(h), 210); - let g = f as fn() -> i32; - assert!(return_fn_ptr(g) == g); - assert!(return_fn_ptr(g) as unsafe fn() -> i32 == g as fn() -> i32 as unsafe fn() -> i32); - assert!(return_fn_ptr(f) != f); -} diff --git a/tests/run-pass/generator.rs b/tests/run-pass/generator.rs deleted file mode 100644 index 477f548a7b..0000000000 --- a/tests/run-pass/generator.rs +++ /dev/null @@ -1,70 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -fn finish(mut amt: usize, mut t: T) -> T::Return - where T: Generator -{ - // We are not moving the `t` around until it gets dropped, so this is okay. - let mut t = unsafe { Pin::new_unchecked(&mut t) }; - loop { - match t.as_mut().resume() { - GeneratorState::Yielded(y) => amt -= y, - GeneratorState::Complete(ret) => { - assert_eq!(amt, 0); - return ret - } - } - } - -} - -fn main() { - finish(1, || yield 1); - finish(3, || { - let mut x = 0; - yield 1; - x += 1; - yield 1; - x += 1; - yield 1; - assert_eq!(x, 2); - }); - finish(7*8/2, || { - for i in 0..8 { - yield i; - } - }); - finish(1, || { - if true { - yield 1; - } else { - } - }); - finish(1, || { - if false { - } else { - yield 1; - } - }); - finish(2, || { - if { yield 1; false } { - yield 1; - panic!() - } - yield 1; - }); - // also test a self-referential generator - assert_eq!( - finish(5, || { - let mut x = Box::new(5); - let y = &mut *x; - *y = 5; - yield *y; - *y = 10; - *x - }), - 10 - ); -} diff --git a/tests/run-pass/hashmap.rs b/tests/run-pass/hashmap.rs deleted file mode 100644 index 25a816bcf2..0000000000 --- a/tests/run-pass/hashmap.rs +++ /dev/null @@ -1,38 +0,0 @@ -// compile-flags: -Zmiri-seed=0000000000000000 - -use std::collections::{self, HashMap}; -use std::hash::{BuildHasherDefault, BuildHasher}; - -fn test_map(mut map: HashMap) { - map.insert(0, 0); - assert_eq!(map.values().fold(0, |x, y| x+y), 0); - - let table_base = map.get(&0).unwrap() as *const _; - - let num = 22; // large enough to trigger a resize - for i in 1..num { - map.insert(i, i); - } - assert!(table_base != map.get(&0).unwrap() as *const _); // make sure relocation happened - assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2); // check the right things are in the table now - - // Inserting again replaces the existing entries - for i in 0..num { - map.insert(i, num-1-i); - } - assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2); - - // TODO: Test Entry API, Iterators, ... - -} - -fn main() { - if cfg!(target_os = "macos") { // TODO: Implement random number generation on OS X. - // Until then, use a deterministic map. - let map : HashMap> = HashMap::default(); - test_map(map); - } else { - let map: HashMap = HashMap::default(); - test_map(map); - } -} diff --git a/tests/run-pass/heap.rs b/tests/run-pass/heap.rs deleted file mode 100644 index b533f91646..0000000000 --- a/tests/run-pass/heap.rs +++ /dev/null @@ -1,34 +0,0 @@ -#![feature(box_syntax)] - -fn make_box() -> Box<(i16, i16)> { - Box::new((1, 2)) -} - -fn make_box_syntax() -> Box<(i16, i16)> { - box (1, 2) -} - -fn allocate_reallocate() { - let mut s = String::new(); - - // 6 byte heap alloc (__rust_allocate) - s.push_str("foobar"); - assert_eq!(s.len(), 6); - assert_eq!(s.capacity(), 6); - - // heap size doubled to 12 (__rust_reallocate) - s.push_str("baz"); - assert_eq!(s.len(), 9); - assert_eq!(s.capacity(), 12); - - // heap size reduced to 9 (__rust_reallocate) - s.shrink_to_fit(); - assert_eq!(s.len(), 9); - assert_eq!(s.capacity(), 9); -} - -fn main() { - assert_eq!(*make_box(), (1, 2)); - assert_eq!(*make_box_syntax(), (1, 2)); - allocate_reallocate(); -} diff --git a/tests/run-pass/heap_allocator.rs b/tests/run-pass/heap_allocator.rs index b201f24e25..10d4d82501 100644 --- a/tests/run-pass/heap_allocator.rs +++ b/tests/run-pass/heap_allocator.rs @@ -80,4 +80,7 @@ fn main() { check_overalign_requests(Global); global_to_box(); box_to_global(); + + #[cfg(target_os = "windows")] + panic!("Making sure this does not land in rustc"); } diff --git a/tests/run-pass/hello.rs b/tests/run-pass/hello.rs deleted file mode 100644 index e7a11a969c..0000000000 --- a/tests/run-pass/hello.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/tests/run-pass/hello.stdout b/tests/run-pass/hello.stdout deleted file mode 100644 index af5626b4a1..0000000000 --- a/tests/run-pass/hello.stdout +++ /dev/null @@ -1 +0,0 @@ -Hello, world! diff --git a/tests/run-pass/integer-ops.rs b/tests/run-pass/integer-ops.rs deleted file mode 100644 index 0264099eb6..0000000000 --- a/tests/run-pass/integer-ops.rs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::i32; - -pub fn main() { - // This tests that do (not) do sign extension properly when loading integers - assert_eq!(u32::max_value() as i64, 4294967295); - assert_eq!(i32::min_value() as i64, -2147483648); - - assert_eq!(i8::min_value(), -128); - - assert_eq!(i8::max_value(), 127); - - assert_eq!(i32::from_str_radix("A", 16), Ok(10)); - - let n = -0b1000_0000i8; - assert_eq!(n.count_ones(), 1); - - let n = -0b1000_0000i8; - assert_eq!(n.count_zeros(), 7); - - let n = -1i16; - assert_eq!(n.leading_zeros(), 0); - - let n = -4i8; - assert_eq!(n.trailing_zeros(), 2); - - let n = 0x0123456789ABCDEFi64; - let m = -0x76543210FEDCBA99i64; - assert_eq!(n.rotate_left(32), m); - - let n = 0x0123456789ABCDEFi64; - let m = -0xFEDCBA987654322i64; - assert_eq!(n.rotate_right(4), m); - - let n = 0x0123456789ABCDEFi64; - let m = -0x1032547698BADCFFi64; - assert_eq!(n.swap_bytes(), m); - - let n = 0x0123456789ABCDEFi64; - if cfg!(target_endian = "big") { - assert_eq!(i64::from_be(n), n) - } else { - assert_eq!(i64::from_be(n), n.swap_bytes()) - } - - let n = 0x0123456789ABCDEFi64; - if cfg!(target_endian = "little") { - assert_eq!(i64::from_le(n), n) - } else { - assert_eq!(i64::from_le(n), n.swap_bytes()) - } - - let n = 0x0123456789ABCDEFi64; - if cfg!(target_endian = "big") { - assert_eq!(n.to_be(), n) - } else { - assert_eq!(n.to_be(), n.swap_bytes()) - } - - let n = 0x0123456789ABCDEFi64; - if cfg!(target_endian = "little") { - assert_eq!(n.to_le(), n) - } else { - assert_eq!(n.to_le(), n.swap_bytes()) - } - - assert_eq!(7i16.checked_add(32760), Some(32767)); - assert_eq!(8i16.checked_add(32760), None); - - assert_eq!((-127i8).checked_sub(1), Some(-128)); - assert_eq!((-128i8).checked_sub(1), None); - - assert_eq!(6i8.checked_mul(21), Some(126)); - assert_eq!(6i8.checked_mul(22), None); - - assert_eq!((-127i8).checked_div(-1), Some(127)); - assert_eq!((-128i8).checked_div(-1), None); - assert_eq!((1i8).checked_div(0), None); - - assert_eq!(5i32.checked_rem(2), Some(1)); - assert_eq!(5i32.checked_rem(0), None); - assert_eq!(i32::MIN.checked_rem(-1), None); - - assert_eq!(5i32.checked_neg(), Some(-5)); - assert_eq!(i32::MIN.checked_neg(), None); - - assert_eq!(0x10i32.checked_shl(4), Some(0x100)); - assert_eq!(0x10i32.checked_shl(33), None); - - assert_eq!(0x10i32.checked_shr(4), Some(0x1)); - assert_eq!(0x10i32.checked_shr(33), None); - - assert_eq!((-5i32).checked_abs(), Some(5)); - assert_eq!(i32::MIN.checked_abs(), None); - - assert_eq!(100i8.saturating_add(1), 101); - assert_eq!(100i8.saturating_add(127), 127); - - assert_eq!(100i8.saturating_sub(127), -27); - assert_eq!((-100i8).saturating_sub(127), -128); - - assert_eq!(100i32.saturating_mul(127), 12700); - assert_eq!((1i32 << 23).saturating_mul(1 << 23), i32::MAX); - assert_eq!((-1i32 << 23).saturating_mul(1 << 23), i32::MIN); - - assert_eq!(100i8.wrapping_add(27), 127); - assert_eq!(100i8.wrapping_add(127), -29); - - assert_eq!(0i8.wrapping_sub(127), -127); - assert_eq!((-2i8).wrapping_sub(127), 127); - - assert_eq!(10i8.wrapping_mul(12), 120); - assert_eq!(11i8.wrapping_mul(12), -124); - - assert_eq!(100u8.wrapping_div(10), 10); - assert_eq!((-128i8).wrapping_div(-1), -128); - - assert_eq!(100i8.wrapping_rem(10), 0); - assert_eq!((-128i8).wrapping_rem(-1), 0); - - assert_eq!(100i8.wrapping_neg(), -100); - assert_eq!((-128i8).wrapping_neg(), -128); - - assert_eq!((-1i8).wrapping_shl(7), -128); - assert_eq!((-1i8).wrapping_shl(8), -1); - - assert_eq!((-128i8).wrapping_shr(7), -1); - assert_eq!((-128i8).wrapping_shr(8), -128); - - assert_eq!(100i8.wrapping_abs(), 100); - assert_eq!((-100i8).wrapping_abs(), 100); - assert_eq!((-128i8).wrapping_abs(), -128); - assert_eq!((-128i8).wrapping_abs() as u8, 128); - - assert_eq!(5i32.overflowing_add(2), (7, false)); - assert_eq!(i32::MAX.overflowing_add(1), (i32::MIN, true)); - - assert_eq!(5i32.overflowing_sub(2), (3, false)); - assert_eq!(i32::MIN.overflowing_sub(1), (i32::MAX, true)); - - assert_eq!(5i32.overflowing_mul(2), (10, false)); - assert_eq!(1_000_000_000i32.overflowing_mul(10), (1410065408, true)); - - assert_eq!(5i32.overflowing_div(2), (2, false)); - assert_eq!(i32::MIN.overflowing_div(-1), (i32::MIN, true)); - - assert_eq!(5i32.overflowing_rem(2), (1, false)); - assert_eq!(i32::MIN.overflowing_rem(-1), (0, true)); - - assert_eq!(2i32.overflowing_neg(), (-2, false)); - assert_eq!(i32::MIN.overflowing_neg(), (i32::MIN, true)); - - assert_eq!(0x10i32.overflowing_shl(4), (0x100, false)); - assert_eq!(0x10i32.overflowing_shl(36), (0x100, true)); - - assert_eq!(0x10i32.overflowing_shr(4), (0x1, false)); - assert_eq!(0x10i32.overflowing_shr(36), (0x1, true)); - - assert_eq!(10i8.overflowing_abs(), (10,false)); - assert_eq!((-10i8).overflowing_abs(), (10,false)); - assert_eq!((-128i8).overflowing_abs(), (-128,true)); -} diff --git a/tests/run-pass/intrinsics-integer.rs b/tests/run-pass/intrinsics-integer.rs deleted file mode 100644 index de59314eff..0000000000 --- a/tests/run-pass/intrinsics-integer.rs +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn ctpop(x: T) -> T; - pub fn ctlz(x: T) -> T; - pub fn ctlz_nonzero(x: T) -> T; - pub fn cttz(x: T) -> T; - pub fn cttz_nonzero(x: T) -> T; - pub fn bswap(x: T) -> T; - } -} - -pub fn main() { - unsafe { - use crate::rusti::*; - - assert_eq!(ctpop(0u8), 0); assert_eq!(ctpop(0i8), 0); - assert_eq!(ctpop(0u16), 0); assert_eq!(ctpop(0i16), 0); - assert_eq!(ctpop(0u32), 0); assert_eq!(ctpop(0i32), 0); - assert_eq!(ctpop(0u64), 0); assert_eq!(ctpop(0i64), 0); - - assert_eq!(ctpop(1u8), 1); assert_eq!(ctpop(1i8), 1); - assert_eq!(ctpop(1u16), 1); assert_eq!(ctpop(1i16), 1); - assert_eq!(ctpop(1u32), 1); assert_eq!(ctpop(1i32), 1); - assert_eq!(ctpop(1u64), 1); assert_eq!(ctpop(1i64), 1); - - assert_eq!(ctpop(10u8), 2); assert_eq!(ctpop(10i8), 2); - assert_eq!(ctpop(10u16), 2); assert_eq!(ctpop(10i16), 2); - assert_eq!(ctpop(10u32), 2); assert_eq!(ctpop(10i32), 2); - assert_eq!(ctpop(10u64), 2); assert_eq!(ctpop(10i64), 2); - - assert_eq!(ctpop(100u8), 3); assert_eq!(ctpop(100i8), 3); - assert_eq!(ctpop(100u16), 3); assert_eq!(ctpop(100i16), 3); - assert_eq!(ctpop(100u32), 3); assert_eq!(ctpop(100i32), 3); - assert_eq!(ctpop(100u64), 3); assert_eq!(ctpop(100i64), 3); - - assert_eq!(ctpop(-1i8 as u8), 8); assert_eq!(ctpop(-1i8), 8); - assert_eq!(ctpop(-1i16 as u16), 16); assert_eq!(ctpop(-1i16), 16); - assert_eq!(ctpop(-1i32 as u32), 32); assert_eq!(ctpop(-1i32), 32); - assert_eq!(ctpop(-1i64 as u64), 64); assert_eq!(ctpop(-1i64), 64); - - assert_eq!(ctlz(0u8), 8); assert_eq!(ctlz(0i8), 8); - assert_eq!(ctlz(0u16), 16); assert_eq!(ctlz(0i16), 16); - assert_eq!(ctlz(0u32), 32); assert_eq!(ctlz(0i32), 32); - assert_eq!(ctlz(0u64), 64); assert_eq!(ctlz(0i64), 64); - - assert_eq!(ctlz(1u8), 7); assert_eq!(ctlz(1i8), 7); - assert_eq!(ctlz(1u16), 15); assert_eq!(ctlz(1i16), 15); - assert_eq!(ctlz(1u32), 31); assert_eq!(ctlz(1i32), 31); - assert_eq!(ctlz(1u64), 63); assert_eq!(ctlz(1i64), 63); - - assert_eq!(ctlz(10u8), 4); assert_eq!(ctlz(10i8), 4); - assert_eq!(ctlz(10u16), 12); assert_eq!(ctlz(10i16), 12); - assert_eq!(ctlz(10u32), 28); assert_eq!(ctlz(10i32), 28); - assert_eq!(ctlz(10u64), 60); assert_eq!(ctlz(10i64), 60); - - assert_eq!(ctlz(100u8), 1); assert_eq!(ctlz(100i8), 1); - assert_eq!(ctlz(100u16), 9); assert_eq!(ctlz(100i16), 9); - assert_eq!(ctlz(100u32), 25); assert_eq!(ctlz(100i32), 25); - assert_eq!(ctlz(100u64), 57); assert_eq!(ctlz(100i64), 57); - - assert_eq!(ctlz_nonzero(1u8), 7); assert_eq!(ctlz_nonzero(1i8), 7); - assert_eq!(ctlz_nonzero(1u16), 15); assert_eq!(ctlz_nonzero(1i16), 15); - assert_eq!(ctlz_nonzero(1u32), 31); assert_eq!(ctlz_nonzero(1i32), 31); - assert_eq!(ctlz_nonzero(1u64), 63); assert_eq!(ctlz_nonzero(1i64), 63); - - assert_eq!(ctlz_nonzero(10u8), 4); assert_eq!(ctlz_nonzero(10i8), 4); - assert_eq!(ctlz_nonzero(10u16), 12); assert_eq!(ctlz_nonzero(10i16), 12); - assert_eq!(ctlz_nonzero(10u32), 28); assert_eq!(ctlz_nonzero(10i32), 28); - assert_eq!(ctlz_nonzero(10u64), 60); assert_eq!(ctlz_nonzero(10i64), 60); - - assert_eq!(ctlz_nonzero(100u8), 1); assert_eq!(ctlz_nonzero(100i8), 1); - assert_eq!(ctlz_nonzero(100u16), 9); assert_eq!(ctlz_nonzero(100i16), 9); - assert_eq!(ctlz_nonzero(100u32), 25); assert_eq!(ctlz_nonzero(100i32), 25); - assert_eq!(ctlz_nonzero(100u64), 57); assert_eq!(ctlz_nonzero(100i64), 57); - - assert_eq!(cttz(-1i8 as u8), 0); assert_eq!(cttz(-1i8), 0); - assert_eq!(cttz(-1i16 as u16), 0); assert_eq!(cttz(-1i16), 0); - assert_eq!(cttz(-1i32 as u32), 0); assert_eq!(cttz(-1i32), 0); - assert_eq!(cttz(-1i64 as u64), 0); assert_eq!(cttz(-1i64), 0); - - assert_eq!(cttz(0u8), 8); assert_eq!(cttz(0i8), 8); - assert_eq!(cttz(0u16), 16); assert_eq!(cttz(0i16), 16); - assert_eq!(cttz(0u32), 32); assert_eq!(cttz(0i32), 32); - assert_eq!(cttz(0u64), 64); assert_eq!(cttz(0i64), 64); - - assert_eq!(cttz(1u8), 0); assert_eq!(cttz(1i8), 0); - assert_eq!(cttz(1u16), 0); assert_eq!(cttz(1i16), 0); - assert_eq!(cttz(1u32), 0); assert_eq!(cttz(1i32), 0); - assert_eq!(cttz(1u64), 0); assert_eq!(cttz(1i64), 0); - - assert_eq!(cttz(10u8), 1); assert_eq!(cttz(10i8), 1); - assert_eq!(cttz(10u16), 1); assert_eq!(cttz(10i16), 1); - assert_eq!(cttz(10u32), 1); assert_eq!(cttz(10i32), 1); - assert_eq!(cttz(10u64), 1); assert_eq!(cttz(10i64), 1); - - assert_eq!(cttz(100u8), 2); assert_eq!(cttz(100i8), 2); - assert_eq!(cttz(100u16), 2); assert_eq!(cttz(100i16), 2); - assert_eq!(cttz(100u32), 2); assert_eq!(cttz(100i32), 2); - assert_eq!(cttz(100u64), 2); assert_eq!(cttz(100i64), 2); - - assert_eq!(cttz_nonzero(-1i8 as u8), 0); assert_eq!(cttz_nonzero(-1i8), 0); - assert_eq!(cttz_nonzero(-1i16 as u16), 0); assert_eq!(cttz_nonzero(-1i16), 0); - assert_eq!(cttz_nonzero(-1i32 as u32), 0); assert_eq!(cttz_nonzero(-1i32), 0); - assert_eq!(cttz_nonzero(-1i64 as u64), 0); assert_eq!(cttz_nonzero(-1i64), 0); - - assert_eq!(cttz_nonzero(1u8), 0); assert_eq!(cttz_nonzero(1i8), 0); - assert_eq!(cttz_nonzero(1u16), 0); assert_eq!(cttz_nonzero(1i16), 0); - assert_eq!(cttz_nonzero(1u32), 0); assert_eq!(cttz_nonzero(1i32), 0); - assert_eq!(cttz_nonzero(1u64), 0); assert_eq!(cttz_nonzero(1i64), 0); - - assert_eq!(cttz_nonzero(10u8), 1); assert_eq!(cttz_nonzero(10i8), 1); - assert_eq!(cttz_nonzero(10u16), 1); assert_eq!(cttz_nonzero(10i16), 1); - assert_eq!(cttz_nonzero(10u32), 1); assert_eq!(cttz_nonzero(10i32), 1); - assert_eq!(cttz_nonzero(10u64), 1); assert_eq!(cttz_nonzero(10i64), 1); - - assert_eq!(cttz_nonzero(100u8), 2); assert_eq!(cttz_nonzero(100i8), 2); - assert_eq!(cttz_nonzero(100u16), 2); assert_eq!(cttz_nonzero(100i16), 2); - assert_eq!(cttz_nonzero(100u32), 2); assert_eq!(cttz_nonzero(100i32), 2); - assert_eq!(cttz_nonzero(100u64), 2); assert_eq!(cttz_nonzero(100i64), 2); - - assert_eq!(bswap(0x0Au8), 0x0A); // no-op - assert_eq!(bswap(0x0Ai8), 0x0A); // no-op - assert_eq!(bswap(0x0A0Bu16), 0x0B0A); - assert_eq!(bswap(0x0A0Bi16), 0x0B0A); - assert_eq!(bswap(0x0ABBCC0Du32), 0x0DCCBB0A); - assert_eq!(bswap(0x0ABBCC0Di32), 0x0DCCBB0A); - assert_eq!(bswap(0x0122334455667708u64), 0x0877665544332201); - assert_eq!(bswap(0x0122334455667708i64), 0x0877665544332201); - } -} diff --git a/tests/run-pass/intrinsics-math.rs b/tests/run-pass/intrinsics-math.rs deleted file mode 100644 index a2c5563474..0000000000 --- a/tests/run-pass/intrinsics-math.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! assert_approx_eq { - ($a:expr, $b:expr) => ({ - let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, - "{} is not approximately equal to {}", *a, *b); - }) -} - -pub fn main() { - use std::f32; - use std::f64; - - assert_approx_eq!(64f32.sqrt(), 8f32); - assert_approx_eq!(64f64.sqrt(), 8f64); - - assert_approx_eq!(25f32.powi(-2), 0.0016f32); - assert_approx_eq!(23.2f64.powi(2), 538.24f64); - - assert_approx_eq!(0f32.sin(), 0f32); - assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64); - - assert_approx_eq!(0f32.cos(), 1f32); - assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64); - - assert_approx_eq!(25f32.powf(-2f32), 0.0016f32); - assert_approx_eq!(400f64.powf(0.5f64), 20f64); - - assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32); - assert_approx_eq!(1f64.exp(), f64::consts::E); - - assert_approx_eq!(10f32.exp2(), 1024f32); - assert_approx_eq!(50f64.exp2(), 1125899906842624f64); - - assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32); - assert_approx_eq!(1f64.ln(), 0f64); - - assert_approx_eq!(10f32.log10(), 1f32); - assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E); - - assert_approx_eq!(8f32.log2(), 3f32); - assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E); - - assert_approx_eq!(1.0f32.mul_add(2.0f32, 5.0f32), 7.0f32); - assert_approx_eq!(0.0f64.mul_add(-2.0f64, f64::consts::E), f64::consts::E); - - assert_approx_eq!((-1.0f32).abs(), 1.0f32); - assert_approx_eq!(34.2f64.abs(), 34.2f64); - - assert_approx_eq!(3.8f32.floor(), 3.0f32); - assert_approx_eq!((-1.1f64).floor(), -2.0f64); - - assert_approx_eq!((-2.3f32).ceil(), -2.0f32); - assert_approx_eq!(3.8f64.ceil(), 4.0f64); - - assert_approx_eq!(0.1f32.trunc(), 0.0f32); - assert_approx_eq!((-0.1f64).trunc(), 0.0f64); -} diff --git a/tests/run-pass/intrinsics.rs b/tests/run-pass/intrinsics.rs deleted file mode 100644 index 3152737a60..0000000000 --- a/tests/run-pass/intrinsics.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::mem::{size_of, size_of_val}; - -fn main() { - assert_eq!(size_of::>(), 8); - assert_eq!(size_of_val(&()), 0); - assert_eq!(size_of_val(&42), 4); - assert_eq!(size_of_val(&[] as &[i32]), 0); - assert_eq!(size_of_val(&[1, 2, 3] as &[i32]), 12); - assert_eq!(size_of_val("foobar"), 6); -} diff --git a/tests/run-pass/ints.rs b/tests/run-pass/ints.rs deleted file mode 100644 index 4f23b5ec9c..0000000000 --- a/tests/run-pass/ints.rs +++ /dev/null @@ -1,58 +0,0 @@ -fn ret() -> i64 { - 1 -} - -fn neg() -> i64 { - -1 -} - -fn add() -> i64 { - 1 + 2 -} - -fn indirect_add() -> i64 { - let x = 1; - let y = 2; - x + y -} - -fn arith() -> i32 { - 3*3 + 4*4 -} - -fn match_int() -> i16 { - let n = 2; - match n { - 0 => 0, - 1 => 10, - 2 => 20, - 3 => 30, - _ => 100, - } -} - -fn match_int_range() -> i64 { - let n = 42; - match n { - 0...9 => 0, - 10...19 => 1, - 20...29 => 2, - 30...39 => 3, - 40...49 => 4, - _ => 5, - } -} - -fn main() { - assert_eq!(ret(), 1); - assert_eq!(neg(), -1); - assert_eq!(add(), 3); - assert_eq!(indirect_add(), 3); - assert_eq!(arith(), 5*5); - assert_eq!(match_int(), 20); - assert_eq!(match_int_range(), 4); - assert_eq!(i64::min_value().overflowing_mul(-1), (i64::min_value(), true)); - assert_eq!(i32::min_value().overflowing_mul(-1), (i32::min_value(), true)); - assert_eq!(i16::min_value().overflowing_mul(-1), (i16::min_value(), true)); - assert_eq!(i8::min_value().overflowing_mul(-1), (i8::min_value(), true)); -} diff --git a/tests/run-pass/issue-15063.rs b/tests/run-pass/issue-15063.rs deleted file mode 100644 index 8ccf87ee70..0000000000 --- a/tests/run-pass/issue-15063.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![allow(dead_code)] - -enum Two { A, B } -impl Drop for Two { - fn drop(&mut self) { - } -} -fn main() { - let _k = Two::A; -} diff --git a/tests/run-pass/issue-15080.rs b/tests/run-pass/issue-15080.rs deleted file mode 100644 index 3ef3718d52..0000000000 --- a/tests/run-pass/issue-15080.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![feature(slice_patterns)] - -fn main() { - let mut x: &[_] = &[1, 2, 3, 4]; - - let mut result = vec!(); - loop { - x = match *x { - [1, n, 3, ref rest..] => { - result.push(n); - rest - } - [n, ref rest..] => { - result.push(n); - rest - } - [] => - break - } - } - assert_eq!(result, [2, 4]); -} diff --git a/tests/run-pass/issue-15523-big.rs b/tests/run-pass/issue-15523-big.rs deleted file mode 100644 index 75fd8d8dfc..0000000000 --- a/tests/run-pass/issue-15523-big.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Issue 15523: derive(PartialOrd) should use the provided -// discriminant values for the derived ordering. -// -// This test is checking corner cases that arise when you have -// 64-bit values in the variants. - -#[derive(PartialEq, PartialOrd)] -#[repr(u64)] -enum Eu64 { - Pos2 = 2, - PosMax = !0, - Pos1 = 1, -} - -#[derive(PartialEq, PartialOrd)] -#[repr(i64)] -enum Ei64 { - Pos2 = 2, - Neg1 = -1, - NegMin = 1 << 63, - PosMax = !(1 << 63), - Pos1 = 1, -} - -fn main() { - assert!(Eu64::Pos2 > Eu64::Pos1); - assert!(Eu64::Pos2 < Eu64::PosMax); - assert!(Eu64::Pos1 < Eu64::PosMax); - - - assert!(Ei64::Pos2 > Ei64::Pos1); - assert!(Ei64::Pos2 > Ei64::Neg1); - assert!(Ei64::Pos1 > Ei64::Neg1); - assert!(Ei64::Pos2 > Ei64::NegMin); - assert!(Ei64::Pos1 > Ei64::NegMin); - assert!(Ei64::Pos2 < Ei64::PosMax); - assert!(Ei64::Pos1 < Ei64::PosMax); -} diff --git a/tests/run-pass/issue-17877.rs b/tests/run-pass/issue-17877.rs deleted file mode 100644 index caad8b2776..0000000000 --- a/tests/run-pass/issue-17877.rs +++ /dev/null @@ -1,16 +0,0 @@ -//ignore-windows: Causes a stack overflow?!? Likely a rustc bug: https://github.com/rust-lang/rust/issues/53820 -//FIXME: Once that bug is fixed, increase the size to 16*1024 and enable on all platforms. - -#![feature(slice_patterns)] - -fn main() { - assert_eq!(match [0u8; 1024] { - _ => 42_usize, - }, 42_usize); - - assert_eq!(match [0u8; 1024] { - [1, _..] => 0_usize, - [0, _..] => 1_usize, - _ => 2_usize - }, 1_usize); -} diff --git a/tests/run-pass/issue-20575.rs b/tests/run-pass/issue-20575.rs deleted file mode 100644 index 1443ec78fd..0000000000 --- a/tests/run-pass/issue-20575.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Test that overloaded calls work with zero arity closures - -fn main() { - let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; - - let _val: Option> = functions.iter().map(|f| (*f)()).collect(); -} diff --git a/tests/run-pass/issue-23261.rs b/tests/run-pass/issue-23261.rs deleted file mode 100644 index 3e1aa295af..0000000000 --- a/tests/run-pass/issue-23261.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Matching on a DST struct should not trigger an LLVM assertion. - -struct Foo { - a: i32, - inner: T -} - -trait Get { - fn get(&self) -> i32; -} - -impl Get for i32 { - fn get(&self) -> i32 { - *self - } -} - -fn check_val(val: &Foo<[u8]>) { - match *val { - Foo { a, .. } => { - assert_eq!(a, 32); - } - } -} - -fn check_dst_val(val: &Foo<[u8]>) { - match *val { - Foo { ref inner, .. } => { - assert_eq!(inner, [1, 2, 3]); - } - } -} - -fn check_both(val: &Foo<[u8]>) { - match *val { - Foo { a, ref inner } => { - assert_eq!(a, 32); - assert_eq!(inner, [1, 2, 3]); - } - } -} - -fn check_trait_obj(val: &Foo) { - match *val { - Foo { a, ref inner } => { - assert_eq!(a, 32); - assert_eq!(inner.get(), 32); - } - } -} - -fn main() { - let foo: &Foo<[u8]> = &Foo { a: 32, inner: [1, 2, 3] }; - check_val(foo); - check_dst_val(foo); - check_both(foo); - - let foo: &Foo = &Foo { a: 32, inner: 32 }; - check_trait_obj(foo); -} diff --git a/tests/run-pass/issue-26709.rs b/tests/run-pass/issue-26709.rs deleted file mode 100644 index a283d8743c..0000000000 --- a/tests/run-pass/issue-26709.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct Wrapper<'a, T: ?Sized>(&'a mut i32, T); - -impl<'a, T: ?Sized> Drop for Wrapper<'a, T> { - fn drop(&mut self) { - *self.0 = 432; - } -} - -fn main() { - let mut x = 0; - { - let wrapper = Box::new(Wrapper(&mut x, 123)); - let _val: Box> = wrapper; - } - assert_eq!(432, x) -} diff --git a/tests/run-pass/issue-27901.rs b/tests/run-pass/issue-27901.rs deleted file mode 100644 index b0822accb6..0000000000 --- a/tests/run-pass/issue-27901.rs +++ /dev/null @@ -1,10 +0,0 @@ -trait Stream { type Item; } -impl<'a> Stream for &'a str { type Item = u8; } -fn f<'s>(s: &'s str) -> (&'s str, <&'s str as Stream>::Item) { - (s, 42) -} - -fn main() { - let fx = f as for<'t> fn(&'t str) -> (&'t str, <&'t str as Stream>::Item); - assert_eq!(fx("hi"), ("hi", 42)); -} diff --git a/tests/run-pass/issue-29746.rs b/tests/run-pass/issue-29746.rs deleted file mode 100644 index d04703d687..0000000000 --- a/tests/run-pass/issue-29746.rs +++ /dev/null @@ -1,35 +0,0 @@ -// zip!(a1,a2,a3,a4) is equivalent to: -// a1.zip(a2).zip(a3).zip(a4).map(|(((x1,x2),x3),x4)| (x1,x2,x3,x4)) -macro_rules! zip { - // Entry point - ([$a:expr, $b:expr, $($rest:expr),*]) => { - zip!([$($rest),*], $a.zip($b), (x,y), [x,y]) - }; - - // Intermediate steps to build the zipped expression, the match pattern, and - // and the output tuple of the closure, using macro hygene to repeatedly - // introduce new variables named 'x'. - ([$a:expr, $($rest:expr),*], $zip:expr, $pat:pat, [$($flat:expr),*]) => { - zip!([$($rest),*], $zip.zip($a), ($pat,x), [$($flat),*, x]) - }; - - // Final step - ([], $zip:expr, $pat:pat, [$($flat:expr),+]) => { - $zip.map(|$pat| ($($flat),+)) - }; - - // Comma - ([$a:expr], $zip:expr, $pat:pat, [$($flat:expr),*]) => { - zip!([$a,], $zip, $pat, [$($flat),*]) - }; -} - -fn main() { - let p1 = vec![1i32, 2].into_iter(); - let p2 = vec!["10", "20"].into_iter(); - let p3 = vec![100u16, 200].into_iter(); - let p4 = vec![1000i64, 2000].into_iter(); - - let e = zip!([p1,p2,p3,p4]).collect::>(); - assert_eq!(e[0], (1i32,"10",100u16,1000i64)); -} diff --git a/tests/run-pass/issue-30530.rs b/tests/run-pass/issue-30530.rs deleted file mode 100644 index d5139c908b..0000000000 --- a/tests/run-pass/issue-30530.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for Issue #30530: alloca's created for storing -// intermediate scratch values during brace-less match arms need to be -// initialized with their drop-flag set to "dropped" (or else we end -// up running the destructors on garbage data at the end of the -// function). - -pub enum Handler { - Default, - #[allow(dead_code)] - Custom(*mut Box), -} - -fn main() { - take(Handler::Default, Box::new(main)); -} - -#[inline(never)] -pub fn take(h: Handler, f: Box) -> Box { - unsafe { - match h { - Handler::Custom(ptr) => *Box::from_raw(ptr), - Handler::Default => f, - } - } -} diff --git a/tests/run-pass/issue-31267-additional.rs b/tests/run-pass/issue-31267-additional.rs deleted file mode 100644 index f6d7209369..0000000000 --- a/tests/run-pass/issue-31267-additional.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[derive(Clone, Copy, Debug)] -struct Bar; - -const BAZ: Bar = Bar; - -#[derive(Debug)] -struct Foo([Bar; 1]); - -struct Biz; - -impl Biz { - const BAZ: Foo = Foo([BAZ; 1]); -} - -fn main() { - let _foo = Biz::BAZ; -} diff --git a/tests/run-pass/issue-33387.rs b/tests/run-pass/issue-33387.rs deleted file mode 100644 index 2335f9c1b9..0000000000 --- a/tests/run-pass/issue-33387.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::sync::Arc; - -trait Foo {} - -impl Foo for [u8; 2] {} - -fn main() { - let _val: Arc = Arc::new([3, 4]); -} diff --git a/tests/run-pass/issue-34571.rs b/tests/run-pass/issue-34571.rs deleted file mode 100644 index 28fe076b64..0000000000 --- a/tests/run-pass/issue-34571.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[repr(u8)] -enum Foo { - Foo(u8), -} - -fn main() { - match Foo::Foo(1) { - _ => () - } -} diff --git a/tests/run-pass/issue-35815.rs b/tests/run-pass/issue-35815.rs deleted file mode 100644 index e17c37f92a..0000000000 --- a/tests/run-pass/issue-35815.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![allow(dead_code)] - -use std::mem; - -struct Foo { - a: i64, - b: bool, - c: T, -} - -fn main() { - let foo: &Foo = &Foo { a: 1, b: false, c: 2i32 }; - let foo_unsized: &Foo = foo; - assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized)); -} diff --git a/tests/run-pass/issue-36278-prefix-nesting.rs b/tests/run-pass/issue-36278-prefix-nesting.rs deleted file mode 100644 index cbffbbc0e0..0000000000 --- a/tests/run-pass/issue-36278-prefix-nesting.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Issue 36278: On an unsized struct with >1 level of nontrivial -// nesting, ensure we are computing dynamic size of prefix correctly. - -use std::mem; - -const SZ: usize = 100; -struct P([u8; SZ], T); - -type Ack = P>; - -fn main() { - let size_of_sized; let size_of_unsized; - let x: Box> = Box::new(P([0; SZ], P([0; SZ], [0; 0]))); - size_of_sized = mem::size_of_val::>(&x); - let align_of_sized = mem::align_of_val::>(&x); - let y: Box> = x; - size_of_unsized = mem::size_of_val::>(&y); - assert_eq!(size_of_sized, size_of_unsized); - assert_eq!(align_of_sized, 1); - assert_eq!(mem::align_of_val::>(&y), 1); -} diff --git a/tests/run-pass/issue-3794.rs b/tests/run-pass/issue-3794.rs deleted file mode 100644 index 9161fefef3..0000000000 --- a/tests/run-pass/issue-3794.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![feature(box_syntax)] - -trait T { - fn print(&self); -} - -#[derive(Debug)] -struct S { - s: isize, -} - -impl T for S { - fn print(&self) { - println!("{:?}", self); - } -} - -fn print_t(t: &T) { - t.print(); -} - -fn print_s(s: &S) { - s.print(); -} - -pub fn main() { - let s: Box = box S { s: 5 }; - print_s(&*s); - let t: Box = s as Box; - print_t(&*t); -} diff --git a/tests/run-pass/issue-3794.stdout b/tests/run-pass/issue-3794.stdout deleted file mode 100644 index e4afe6fa55..0000000000 --- a/tests/run-pass/issue-3794.stdout +++ /dev/null @@ -1,2 +0,0 @@ -S { s: 5 } -S { s: 5 } diff --git a/tests/run-pass/issue-53728.rs b/tests/run-pass/issue-53728.rs deleted file mode 100644 index 6d440b66b3..0000000000 --- a/tests/run-pass/issue-53728.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![allow(dead_code)] - -#[repr(u16)] -enum DeviceKind { - Nil = 0, -} -#[repr(packed)] -struct DeviceInfo { - endianness: u8, - device_kind: DeviceKind, -} -fn main() { - let _x = None::<(DeviceInfo, u8)>; - let _y = None::<(DeviceInfo, u16)>; - let _z = None::<(DeviceInfo, u64)>; -} diff --git a/tests/run-pass/issue-5917.rs b/tests/run-pass/issue-5917.rs deleted file mode 100644 index eb506dd3a1..0000000000 --- a/tests/run-pass/issue-5917.rs +++ /dev/null @@ -1,7 +0,0 @@ - -struct T (&'static [isize]); -static STATIC : T = T (&[5, 4, 3]); -pub fn main () { - let T(ref v) = STATIC; - assert_eq!(v[0], 5); -} diff --git a/tests/run-pass/issue-miri-184.rs b/tests/run-pass/issue-miri-184.rs deleted file mode 100644 index 39c841403e..0000000000 --- a/tests/run-pass/issue-miri-184.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub fn main() { - let bytes: [u8; 8] = unsafe { ::std::mem::transmute(0u64) }; - let _val: &[u8] = &bytes; -} diff --git a/tests/run-pass/iter.rs b/tests/run-pass/iter.rs deleted file mode 100644 index 1bef21d83b..0000000000 --- a/tests/run-pass/iter.rs +++ /dev/null @@ -1,40 +0,0 @@ -fn iter_empty_and_zst() { - for _ in Vec::::new().iter() { // this iterates over a Unique::empty() - panic!("We should never be here."); - } - - // Iterate over a ZST (uses arith_offset internally) - let mut count = 0; - for _ in &[(), (), ()] { - count += 1; - } - assert_eq!(count, 3); -} - -fn test_iterator_step_by_nth() { - let mut it = (0..16).step_by(5); - assert_eq!(it.nth(0), Some(0)); - assert_eq!(it.nth(0), Some(5)); - assert_eq!(it.nth(0), Some(10)); - assert_eq!(it.nth(0), Some(15)); - assert_eq!(it.nth(0), None); -} - -fn iter_any() { - let f = |x: &u8| { 10u8 == *x }; - f(&1u8); - - let g = |(), x: &u8| { 10u8 == *x }; - g((), &1u8); - - let h = |(), (), x: &u8| { 10u8 == *x }; - h((), (), &1u8); - - [1, 2, 3u8].into_iter().any(|elt| 10 == *elt); -} - -fn main() { - test_iterator_step_by_nth(); - iter_any(); - iter_empty_and_zst(); -} diff --git a/tests/run-pass/last-use-in-cap-clause.rs b/tests/run-pass/last-use-in-cap-clause.rs deleted file mode 100644 index f75f00b87f..0000000000 --- a/tests/run-pass/last-use-in-cap-clause.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Make sure #1399 stays fixed - -#[allow(dead_code)] -struct A { a: Box } - -fn foo() -> Box isize + 'static> { - let k: Box<_> = Box::new(22); - let _u = A {a: k.clone()}; - let result = || 22; - Box::new(result) -} - -pub fn main() { - assert_eq!(foo()(), 22); -} diff --git a/tests/run-pass/linked-list.rs b/tests/run-pass/linked-list.rs deleted file mode 100644 index f1d21728b2..0000000000 --- a/tests/run-pass/linked-list.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![feature(linked_list_extras)] -use std::collections::LinkedList; - -fn list_from(v: &[T]) -> LinkedList { - v.iter().cloned().collect() -} - -fn main() { - let mut m = list_from(&[0, 2, 4, 6, 8]); - let len = m.len(); - { - let mut it = m.iter_mut(); - it.insert_next(-2); - loop { - match it.next() { - None => break, - Some(elt) => { - it.insert_next(*elt + 1); - match it.peek_next() { - Some(x) => assert_eq!(*x, *elt + 2), - None => assert_eq!(8, *elt), - } - } - } - } - it.insert_next(0); - it.insert_next(1); - } - - assert_eq!(m.len(), 3 + len * 2); - assert_eq!(m.into_iter().collect::>(), - [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]); -} diff --git a/tests/run-pass/loop-break-value.rs b/tests/run-pass/loop-break-value.rs deleted file mode 100644 index bd7afa7ec1..0000000000 --- a/tests/run-pass/loop-break-value.rs +++ /dev/null @@ -1,133 +0,0 @@ -#![feature(never_type)] -#![allow(unreachable_code)] - -#[allow(unused)] -fn never_returns() { - loop { - break loop {}; - } -} - -pub fn main() { - let value = 'outer: loop { - if 1 == 1 { - break 13; - } else { - let _never: ! = loop { - break loop { - break 'outer panic!(); - } - }; - } - }; - assert_eq!(value, 13); - - let x = [1, 3u32, 5]; - let y = [17]; - let z = []; - let coerced: &[_] = loop { - match 2 { - 1 => break &x, - 2 => break &y, - 3 => break &z, - _ => (), - } - }; - assert_eq!(coerced, &[17u32]); - - let trait_unified = loop { - break if true { - break Default::default() - } else { - break [13, 14] - }; - }; - assert_eq!(trait_unified, [0, 0]); - - let trait_unified_2 = loop { - if false { - break [String::from("Hello")] - } else { - break Default::default() - }; - }; - // compare lengths; ptr comparison is not deterministic - assert_eq!(trait_unified_2.len(), 1); - assert_eq!(trait_unified_2[0].len(), 0); - - let trait_unified_3 = loop { - break if false { - break [String::from("Hello")] - } else { - ["Yes".into()] - }; - }; - assert_eq!(trait_unified_3, ["Yes"]); - - let regular_break = loop { - if true { - break; - } else { - break break Default::default(); - } - }; - assert_eq!(regular_break, ()); - - let regular_break_2 = loop { - if true { - break Default::default(); - } else { - break; - } - }; - assert_eq!(regular_break_2, ()); - - let regular_break_3 = loop { - break if true { - Default::default() - } else { - break; - } - }; - assert_eq!(regular_break_3, ()); - - let regular_break_4 = loop { - break (); - break; - }; - assert_eq!(regular_break_4, ()); - - let regular_break_5 = loop { - break; - break (); - }; - assert_eq!(regular_break_5, ()); - - let nested_break_value = 'outer2: loop { - let _a: u32 = 'inner: loop { - if true { - break 'outer2 "hello"; - } else { - break 'inner 17; - } - }; - panic!(); - }; - assert_eq!(nested_break_value, "hello"); - - let break_from_while_cond = loop { - 'inner_loop: while break 'inner_loop { - panic!(); - } - break 123; - }; - assert_eq!(break_from_while_cond, 123); - - let break_from_while_to_outer = 'outer_loop: loop { - while break 'outer_loop 567 { - panic!("from_inner"); - } - panic!("from outer"); - }; - assert_eq!(break_from_while_to_outer, 567); -} diff --git a/tests/run-pass/loops.rs b/tests/run-pass/loops.rs deleted file mode 100644 index 222287cbe0..0000000000 --- a/tests/run-pass/loops.rs +++ /dev/null @@ -1,35 +0,0 @@ -fn factorial_loop() -> i64 { - let mut product = 1; - let mut i = 1; - - while i <= 10 { - product *= i; - i += 1; - } - - product -} - -fn index_for_loop() -> usize { - let mut sum = 0; - let a = [0, 10, 20, 30]; - for i in 0..a.len() { - sum += a[i]; - } - sum -} - -fn for_loop() -> usize { - let mut sum = 0; - let a = [0, 10, 20, 30]; - for &n in &a { - sum += n; - } - sum -} - -fn main() { - assert_eq!(factorial_loop(), 3628800); - assert_eq!(index_for_loop(), 60); - assert_eq!(for_loop(), 60); -} diff --git a/tests/run-pass/main_fn.rs b/tests/run-pass/main_fn.rs deleted file mode 100644 index 91d183ee6a..0000000000 --- a/tests/run-pass/main_fn.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(main)] - -#[main] -fn foo() { -} diff --git a/tests/run-pass/many_shr_bor.rs b/tests/run-pass/many_shr_bor.rs deleted file mode 100644 index d4901abb80..0000000000 --- a/tests/run-pass/many_shr_bor.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Make sure validation can handle many overlapping shared borrows for different parts of a data structure -use std::cell::RefCell; - -struct Test { - a: u32, - b: u32, -} - -fn test1() { - let t = &mut Test { a: 0, b: 0 }; - { - let x; - { - let y = &t.a; - x = &t; - let _y = *y; - } - let _x = x.a; - } - t.b = 42; -} - -fn test2(r: &mut RefCell) { - let x = &*r; // releasing write lock, first suspension recorded - let mut x_ref = x.borrow_mut(); - let x_inner : &mut i32 = &mut *x_ref; // new inner write lock, with same lifetime as outer lock - let _x_inner_shr = &*x_inner; // releasing inner write lock, recording suspension - let _y = &*r; // second suspension for the outer write lock - let _x_inner_shr2 = &*x_inner; // 2nd suspension for inner write lock -} - -fn main() { - test1(); - test2(&mut RefCell::new(0)); -} diff --git a/tests/run-pass/match_slice.rs b/tests/run-pass/match_slice.rs deleted file mode 100644 index 568a1a1c88..0000000000 --- a/tests/run-pass/match_slice.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - let x = "hello"; - match x { - "foo" => {}, - "bar" => {}, - _ => {}, - } -} diff --git a/tests/run-pass/memchr.rs b/tests/run-pass/memchr.rs deleted file mode 100644 index 2f5e2c4bb7..0000000000 --- a/tests/run-pass/memchr.rs +++ /dev/null @@ -1,89 +0,0 @@ -#![feature(slice_internals)] - -use core::slice::memchr::{memchr, memrchr}; - -// test fallback implementations on all platforms -fn matches_one() { - assert_eq!(Some(0), memchr(b'a', b"a")); -} - -fn matches_begin() { - assert_eq!(Some(0), memchr(b'a', b"aaaa")); -} - -fn matches_end() { - assert_eq!(Some(4), memchr(b'z', b"aaaaz")); -} - -fn matches_nul() { - assert_eq!(Some(4), memchr(b'\x00', b"aaaa\x00")); -} - -fn matches_past_nul() { - assert_eq!(Some(5), memchr(b'z', b"aaaa\x00z")); -} - -fn no_match_empty() { - assert_eq!(None, memchr(b'a', b"")); -} - -fn no_match() { - assert_eq!(None, memchr(b'a', b"xyz")); -} - -fn matches_one_reversed() { - assert_eq!(Some(0), memrchr(b'a', b"a")); -} - -fn matches_begin_reversed() { - assert_eq!(Some(3), memrchr(b'a', b"aaaa")); -} - -fn matches_end_reversed() { - assert_eq!(Some(0), memrchr(b'z', b"zaaaa")); -} - -fn matches_nul_reversed() { - assert_eq!(Some(4), memrchr(b'\x00', b"aaaa\x00")); -} - -fn matches_past_nul_reversed() { - assert_eq!(Some(0), memrchr(b'z', b"z\x00aaaa")); -} - -fn no_match_empty_reversed() { - assert_eq!(None, memrchr(b'a', b"")); -} - -fn no_match_reversed() { - assert_eq!(None, memrchr(b'a', b"xyz")); -} - -fn each_alignment_reversed() { - let mut data = [1u8; 64]; - let needle = 2; - let pos = 40; - data[pos] = needle; - for start in 0..16 { - assert_eq!(Some(pos - start), memrchr(needle, &data[start..])); - } -} - -fn main() { - matches_one(); - matches_begin(); - matches_end(); - matches_nul(); - matches_past_nul(); - no_match_empty(); - no_match(); - - matches_one_reversed(); - matches_begin_reversed(); - matches_end_reversed(); - matches_nul_reversed(); - matches_past_nul_reversed(); - no_match_empty_reversed(); - no_match_reversed(); - each_alignment_reversed(); -} diff --git a/tests/run-pass/mir_coercions.rs b/tests/run-pass/mir_coercions.rs deleted file mode 100644 index f3d8e519d2..0000000000 --- a/tests/run-pass/mir_coercions.rs +++ /dev/null @@ -1,73 +0,0 @@ -#![feature(coerce_unsized, unsize)] - -use std::ops::CoerceUnsized; -use std::marker::Unsize; - -fn identity_coercion(x: &(Fn(u32)->u32 + Send)) -> &Fn(u32)->u32 { - x -} -fn fn_coercions(f: &fn(u32) -> u32) -> - (unsafe fn(u32) -> u32, - &(Fn(u32) -> u32+Send)) -{ - (*f, f) -} - -fn simple_array_coercion(x: &[u8; 3]) -> &[u8] { x } - -fn square(a: u32) -> u32 { a * a } - -#[derive(PartialEq,Eq)] -struct PtrWrapper<'a, T: 'a+?Sized>(u32, u32, (), &'a T); -impl<'a, T: ?Sized+Unsize, U: ?Sized> - CoerceUnsized> for PtrWrapper<'a, T> {} - -struct TrivPtrWrapper<'a, T: 'a+?Sized>(&'a T); -impl<'a, T: ?Sized+Unsize, U: ?Sized> - CoerceUnsized> for TrivPtrWrapper<'a, T> {} - -fn coerce_ptr_wrapper(p: PtrWrapper<[u8; 3]>) -> PtrWrapper<[u8]> { - p -} - -fn coerce_triv_ptr_wrapper(p: TrivPtrWrapper<[u8; 3]>) -> TrivPtrWrapper<[u8]> { - p -} - -fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) - -> PtrWrapper u32> { - p -} - -fn coerce_ptr_wrapper_poly<'a, T, Trait: ?Sized>(p: PtrWrapper<'a, T>) - -> PtrWrapper<'a, Trait> - where PtrWrapper<'a, T>: CoerceUnsized> -{ - p -} - -fn main() { - let a = [0,1,2]; - let square_local : fn(u32) -> u32 = square; - let (f,g) = fn_coercions(&square_local); - // cannot use `square as *const ()` because we can't know whether the compiler duplicates - // functions, so two function pointers are only equal if they result from the same function - // to function pointer cast - assert_eq!(f as *const (), square_local as *const()); - assert_eq!(g(4), 16); - assert_eq!(identity_coercion(g)(5), 25); - - assert_eq!(simple_array_coercion(&a), &a); - let w = coerce_ptr_wrapper(PtrWrapper(2,3,(),&a)); - assert!(w == PtrWrapper(2,3,(),&a) as PtrWrapper<[u8]>); - - let w = coerce_triv_ptr_wrapper(TrivPtrWrapper(&a)); - assert_eq!(&w.0, &a); - - let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local)); - assert_eq!((z.3)(6), 36); - - let z: PtrWrapper u32> = - coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local)); - assert_eq!((z.3)(6), 36); -} diff --git a/tests/run-pass/mir_fat_ptr.rs b/tests/run-pass/mir_fat_ptr.rs deleted file mode 100644 index 55418c4802..0000000000 --- a/tests/run-pass/mir_fat_ptr.rs +++ /dev/null @@ -1,51 +0,0 @@ -// test that ordinary fat pointer operations work. - -struct Wrapper(u32, T); - -struct FatPtrContainer<'a> { - ptr: &'a [u8] -} - -fn fat_ptr_project(a: &Wrapper<[u8]>) -> &[u8] { - &a.1 -} - -fn fat_ptr_simple(a: &[u8]) -> &[u8] { - a -} - -fn fat_ptr_via_local(a: &[u8]) -> &[u8] { - let x = a; - x -} - -fn fat_ptr_from_struct(s: FatPtrContainer) -> &[u8] { - s.ptr -} - -fn fat_ptr_to_struct(a: &[u8]) -> FatPtrContainer { - FatPtrContainer { ptr: a } -} - -fn fat_ptr_store_to<'a>(a: &'a [u8], b: &mut &'a [u8]) { - *b = a; -} - -fn fat_ptr_constant() -> &'static str { - "HELLO" -} - -fn main() { - let a = Wrapper(4, [7,6,5]); - - let p = fat_ptr_project(&a); - let p = fat_ptr_simple(p); - let p = fat_ptr_via_local(p); - let p = fat_ptr_from_struct(fat_ptr_to_struct(p)); - - let mut target : &[u8] = &[42]; - fat_ptr_store_to(p, &mut target); - assert_eq!(target, &a.1); - - assert_eq!(fat_ptr_constant(), "HELLO"); -} diff --git a/tests/run-pass/miri-issue-133.rs b/tests/run-pass/miri-issue-133.rs deleted file mode 100644 index 406b5e102c..0000000000 --- a/tests/run-pass/miri-issue-133.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::mem::size_of; - -struct S { - _u: U, - size_of_u: usize, - _v: V, - size_of_v: usize -} - -impl S { - fn new(u: U, v: V) -> Self { - S { - _u: u, - size_of_u: size_of::(), - _v: v, - size_of_v: size_of::() - } - } -} - -impl Drop for S { - fn drop(&mut self) { - assert_eq!(size_of::(), self.size_of_u); - assert_eq!(size_of::(), self.size_of_v); - } -} - -fn main() { - S::new(0u8, 1u16); -} diff --git a/tests/run-pass/move-arg-2-unique.rs b/tests/run-pass/move-arg-2-unique.rs deleted file mode 100644 index b31b868bb9..0000000000 --- a/tests/run-pass/move-arg-2-unique.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(box_syntax)] - -fn test(foo: Box> ) { assert_eq!((*foo)[0], 10); } - -pub fn main() { - let x = box vec![10]; - // Test forgetting a local by move-in - test(x); -} diff --git a/tests/run-pass/move-arg-3-unique.rs b/tests/run-pass/move-arg-3-unique.rs deleted file mode 100644 index 3b5c7cbbd4..0000000000 --- a/tests/run-pass/move-arg-3-unique.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(box_syntax)] - -pub fn main() { - let x = box 10; - let y = x; - assert_eq!(*y, 10); -} diff --git a/tests/run-pass/move-undef-primval.rs b/tests/run-pass/move-undef-primval.rs deleted file mode 100644 index 73c33943a6..0000000000 --- a/tests/run-pass/move-undef-primval.rs +++ /dev/null @@ -1,12 +0,0 @@ -struct Foo { - _inner: i32, -} - -fn main() { - unsafe { - let foo = Foo { - _inner: std::mem::uninitialized(), - }; - let _bar = foo; - } -} diff --git a/tests/run-pass/multi_arg_closure.rs b/tests/run-pass/multi_arg_closure.rs deleted file mode 100644 index 30cfb5b685..0000000000 --- a/tests/run-pass/multi_arg_closure.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn foo(f: &mut FnMut(isize, isize) -> isize) -> isize { - f(1, 2) -} - -fn main() { - let z = foo(&mut |x, y| x * 10 + y); - assert_eq!(z, 12); -} diff --git a/tests/run-pass/negative_discriminant.rs b/tests/run-pass/negative_discriminant.rs deleted file mode 100644 index 16f175e7df..0000000000 --- a/tests/run-pass/negative_discriminant.rs +++ /dev/null @@ -1,13 +0,0 @@ -enum AB { A = -1, B = 1 } - -fn main() { - match AB::A { - AB::A => (), - AB::B => panic!(), - } - - match AB::B { - AB::A => panic!(), - AB::B => (), - } -} diff --git a/tests/run-pass/non_capture_closure_to_fn_ptr.rs b/tests/run-pass/non_capture_closure_to_fn_ptr.rs deleted file mode 100644 index d48c4df459..0000000000 --- a/tests/run-pass/non_capture_closure_to_fn_ptr.rs +++ /dev/null @@ -1,20 +0,0 @@ -// allow(const_err) to work around a bug in warnings -#[allow(const_err)] -static FOO: fn() = || { assert_ne!(42, 43) }; -#[allow(const_err)] -static BAR: fn(i32, i32) = |a, b| { assert_ne!(a, b) }; - -// use to first make the closure FnOnce() before making it fn() -fn magic(f: F) -> F { f } - -fn main() { - FOO(); - BAR(44, 45); - let bar: unsafe fn(i32, i32) = BAR; - unsafe { bar(46, 47) }; - let boo: &Fn(i32, i32) = &BAR; - boo(48, 49); - - let f = magic(||{}) as fn(); - f(); -} diff --git a/tests/run-pass/observed_local_mut.rs b/tests/run-pass/observed_local_mut.rs deleted file mode 100644 index c58e8c84bb..0000000000 --- a/tests/run-pass/observed_local_mut.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Validation catches this (correctly) as UB. -// compile-flags: -Zmiri-disable-validation - -// This test is intended to guard against the problem described in commit -// 39bb1254d1eaf74f45a4e741097e33fc942168d5. -// -// As written, it might be considered UB in compiled Rust, but of course Miri gives it a safe, -// deterministic behaviour (one that might not correspond with how an eventual Rust spec would -// defined this). -// -// An alternative way to write the test without `unsafe` would be to use `Cell`, but it would -// only surface the bug described by the above commit if `Cell` on the stack got represented -// as a primitive `PrimVal::I32` which is not yet the case. - -fn main() { - let mut x = 0; - let y: *const i32 = &x; - x = 1; - - // When the described bug is in place, this results in `0`, not observing the `x = 1` line. - assert_eq!(unsafe { *y }, 1); - - assert_eq!(x, 1); -} diff --git a/tests/run-pass/option_box_transmute_ptr.rs b/tests/run-pass/option_box_transmute_ptr.rs deleted file mode 100644 index 0786db1ef8..0000000000 --- a/tests/run-pass/option_box_transmute_ptr.rs +++ /dev/null @@ -1,15 +0,0 @@ -// This tests that the size of Option> is the same as *const i32. -fn option_box_deref() -> i32 { - let val = Some(Box::new(42)); - unsafe { - let ptr: *const i32 = std::mem::transmute::>, *const i32>(val); - let ret = *ptr; - // unleak memory - std::mem::transmute::<*const i32, Option>>(ptr); - ret - } -} - -fn main() { - assert_eq!(option_box_deref(), 42); -} diff --git a/tests/run-pass/option_eq.rs b/tests/run-pass/option_eq.rs deleted file mode 100644 index e698f87677..0000000000 --- a/tests/run-pass/option_eq.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - assert_eq!(std::char::from_u32('x' as u32), Some('x')); -} diff --git a/tests/run-pass/overloaded-calls-simple.rs b/tests/run-pass/overloaded-calls-simple.rs deleted file mode 100644 index 12e632c251..0000000000 --- a/tests/run-pass/overloaded-calls-simple.rs +++ /dev/null @@ -1,23 +0,0 @@ - -#![feature(lang_items, unboxed_closures, fn_traits)] - -struct S3 { - x: i32, - y: i32, -} - -impl FnOnce<(i32,i32)> for S3 { - type Output = i32; - extern "rust-call" fn call_once(self, (z,zz): (i32,i32)) -> i32 { - self.x * self.y * z * zz - } -} - -fn main() { - let s = S3 { - x: 3, - y: 3, - }; - let ans = s(3, 1); - assert_eq!(ans, 27); -} diff --git a/tests/run-pass/packed_static.rs b/tests/run-pass/packed_static.rs deleted file mode 100644 index 1fa3a36967..0000000000 --- a/tests/run-pass/packed_static.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[repr(packed)] -struct Foo { - i: i32 -} - -fn main() { - assert_eq!({FOO.i}, 42); -} - -static FOO: Foo = Foo { i: 42 }; diff --git a/tests/run-pass/packed_struct.rs b/tests/run-pass/packed_struct.rs deleted file mode 100644 index 303e90742f..0000000000 --- a/tests/run-pass/packed_struct.rs +++ /dev/null @@ -1,105 +0,0 @@ -#![allow(dead_code)] -#![feature(unsize, coerce_unsized)] - -#[repr(packed)] -struct S { - a: i32, - b: i64, -} - -#[repr(packed)] -struct Test1<'a> { - x: u8, - other: &'a u32, -} - -#[repr(packed)] -struct Test2<'a> { - x: u8, - other: &'a Test1<'a>, -} - -fn test(t: Test2) { - let x = *t.other.other; - assert_eq!(x, 42); -} - -fn test_unsizing() { - #[repr(packed)] - struct UnalignedPtr<'a, T: ?Sized> - where T: 'a, - { - data: &'a T, - } - - impl<'a, T, U> std::ops::CoerceUnsized> for UnalignedPtr<'a, T> - where - T: std::marker::Unsize + ?Sized, - U: ?Sized, - { } - - let arr = [1, 2, 3]; - let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr }; - let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned; - let _unused = &arr_unaligned; // forcing an allocation, which could also yield "unaligned write"-errors -} - -fn test_drop() { - struct Wrap(u32); - impl Drop for Wrap { - fn drop(&mut self) { - // Do an (aligned) load - let _test = self.0; - // For the fun of it, test alignment - assert_eq!(&self.0 as *const _ as usize % std::mem::align_of::(), 0); - } - } - - #[repr(packed,C)] - struct Packed { - f1: u8, // this should move the second field to something not very aligned - f2: T, - } - - let p = Packed { f1: 42, f2: Wrap(23) }; - drop(p); -} - -fn test_inner_packed() { - // Even if just the inner struct is packed, accesses to the outer field can get unaligned. - // Make sure that works. - #[repr(packed)] - #[derive(Clone,Copy)] - struct Inner(u32); - - #[derive(Clone,Copy)] - struct Outer(u8, Inner); - - let o = Outer(0, Inner(42)); - let _x = o.1; - let _y = (o.1).0; - let _o2 = o.clone(); -} - -fn main() { - let mut x = S { - a: 42, - b: 99, - }; - let a = x.a; - let b = x.b; - assert_eq!(a, 42); - assert_eq!(b, 99); - // can't do `assert_eq!(x.a, 42)`, because `assert_eq!` takes a reference - assert_eq!({x.a}, 42); - assert_eq!({x.b}, 99); - - x.b = 77; - assert_eq!({x.b}, 77); - - test(Test2 { x: 0, other: &Test1 { x: 0, other: &42 }}); - - test_unsizing(); - test_drop(); - test_inner_packed(); -} diff --git a/tests/run-pass/pointers.rs b/tests/run-pass/pointers.rs deleted file mode 100644 index 2b26791328..0000000000 --- a/tests/run-pass/pointers.rs +++ /dev/null @@ -1,86 +0,0 @@ -use std::usize; - -fn one_line_ref() -> i16 { - *&1 -} - -fn basic_ref() -> i16 { - let x = &1; - *x -} - -fn basic_ref_mut() -> i16 { - let x = &mut 1; - *x += 2; - *x -} - -fn basic_ref_mut_var() -> i16 { - let mut a = 1; - { - let x = &mut a; - *x += 2; - } - a -} - -fn tuple_ref_mut() -> (i8, i8) { - let mut t = (10, 20); - { - let x = &mut t.1; - *x += 2; - } - t -} - -fn match_ref_mut() -> i8 { - let mut t = (20, 22); - { - let opt = Some(&mut t); - match opt { - Some(&mut (ref mut x, ref mut y)) => *x += *y, - None => {}, - } - } - t.0 -} - -fn dangling_pointer() -> *const i32 { - let b = Box::new((42, 42)); // make it bigger than the alignment, so that there is some "room" after this pointer - &b.0 as *const i32 -} - -fn main() { - assert_eq!(one_line_ref(), 1); - assert_eq!(basic_ref(), 1); - assert_eq!(basic_ref_mut(), 3); - assert_eq!(basic_ref_mut_var(), 3); - assert_eq!(tuple_ref_mut(), (10, 22)); - assert_eq!(match_ref_mut(), 42); - - // Compare even dangling pointers with NULL, and with others in the same allocation, including - // out-of-bounds. - assert!(dangling_pointer() != std::ptr::null()); - assert!(match dangling_pointer() as usize { 0 => false, _ => true }); - let dangling = dangling_pointer(); - assert!(dangling == dangling); - assert!(dangling.wrapping_add(1) != dangling); - assert!(dangling.wrapping_sub(1) != dangling); - - // Compare pointer with BIG integers - let dangling = dangling as usize; - assert!(dangling != usize::MAX); - assert!(dangling != usize::MAX - 1); - assert!(dangling != usize::MAX - 2); - assert!(dangling != usize::MAX - 3); // this is even 4-aligned, but it still cannot be equal because of the extra "room" after this pointer - assert_eq!((usize::MAX - 3) % 4, 0); // just to be sure we got this right - - // Compare pointer with unaligned integers - assert!(dangling != 1usize); - assert!(dangling != 2usize); - assert!(dangling != 3usize); - // 4 is a possible choice! So we cannot compare with that. - assert!(dangling != 5usize); - assert!(dangling != 6usize); - assert!(dangling != 7usize); -} diff --git a/tests/run-pass/products.rs b/tests/run-pass/products.rs deleted file mode 100644 index 86bb71a0be..0000000000 --- a/tests/run-pass/products.rs +++ /dev/null @@ -1,32 +0,0 @@ -fn tuple() -> (i16,) { - (1,) -} - -fn tuple_2() -> (i16, i16) { - (1, 2) -} - -fn tuple_5() -> (i16, i16, i16, i16, i16) { - (1, 2, 3, 4, 5) -} - -#[derive(Debug, PartialEq)] -struct Pair { x: i8, y: i8 } - -fn pair() -> Pair { - Pair { x: 10, y: 20 } -} - -fn field_access() -> (i8, i8) { - let mut p = Pair { x: 10, y: 20 }; - p.x += 5; - (p.x, p.y) -} - -fn main() { - assert_eq!(tuple(), (1,)); - assert_eq!(tuple_2(), (1, 2)); - assert_eq!(tuple_5(), (1, 2, 3, 4, 5)); - assert_eq!(pair(), Pair { x: 10, y: 20} ); - assert_eq!(field_access(), (15, 20)); -} diff --git a/tests/run-pass/ptr_arith_offset.rs b/tests/run-pass/ptr_arith_offset.rs deleted file mode 100644 index a6ee151e3e..0000000000 --- a/tests/run-pass/ptr_arith_offset.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let v = [1i16, 2]; - let x = &v as *const [i16] as *const i16; - let x = x.wrapping_offset(1); - assert_eq!(unsafe { *x }, 2); -} diff --git a/tests/run-pass/ptr_arith_offset_overflow.rs b/tests/run-pass/ptr_arith_offset_overflow.rs deleted file mode 100644 index 6b778248be..0000000000 --- a/tests/run-pass/ptr_arith_offset_overflow.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - let v = [1i16, 2]; - let x = v.as_ptr().wrapping_offset(1); // ptr to the 2nd element - // Adding 2*isize::max and then 1 is like substracting 1 - let x = x.wrapping_offset(isize::max_value()); - let x = x.wrapping_offset(isize::max_value()); - let x = x.wrapping_offset(1); - assert_eq!(unsafe { *x }, 1); -} diff --git a/tests/run-pass/ptr_int_casts.rs b/tests/run-pass/ptr_int_casts.rs deleted file mode 100644 index b1b0626305..0000000000 --- a/tests/run-pass/ptr_int_casts.rs +++ /dev/null @@ -1,35 +0,0 @@ -use std::mem; - -fn eq_ref(x: &T, y: &T) -> bool { - x as *const _ == y as *const _ -} - -fn f() -> i32 { 42 } - -fn main() { - // int-ptr-int - assert_eq!(1 as *const i32 as usize, 1); - assert_eq!((1 as *const i32).wrapping_offset(4) as usize, 1 + 4*4); - - { // ptr-int-ptr - let x = 13; - let mut y = &x as &_ as *const _ as usize; - y += 13; - y -= 13; - let y = y as *const _; - assert!(eq_ref(&x, unsafe { &*y })); - } - - { // fnptr-int-fnptr - let x : fn() -> i32 = f; - let y : *mut u8 = unsafe { mem::transmute(x as fn() -> i32) }; - let mut y = y as usize; - y += 13; - y -= 13; - let x : fn() -> i32 = unsafe { mem::transmute(y as *mut u8) }; - assert_eq!(x(), 42); - } - - // involving types other than usize - assert_eq!((-1i32) as usize as *const i32 as usize, (-1i32) as usize); -} diff --git a/tests/run-pass/ptr_int_ops.rs b/tests/run-pass/ptr_int_ops.rs deleted file mode 100644 index 9a29c2d308..0000000000 --- a/tests/run-pass/ptr_int_ops.rs +++ /dev/null @@ -1,20 +0,0 @@ -fn main() { - let v = [1i16, 2]; - let x = &v[1] as *const i16 as usize; - // arithmetic - let _y = x + 4; - let _y = 4 + x; - let _y = x - 2; - // bit-operations, covered by alignment - assert_eq!(x & 1, 0); - assert_eq!(x & 0, 0); - assert_eq!(1 & (x+1), 1); - let _y = !1 & x; - let _y = !0 & x; - let _y = x & !1; - // remainder, covered by alignment - assert_eq!(x % 2, 0); - assert_eq!((x+1) % 2, 1); - // remainder with 1 is always 0 - assert_eq!(x % 1, 0); -} diff --git a/tests/run-pass/ptr_offset.rs b/tests/run-pass/ptr_offset.rs deleted file mode 100644 index 1c7f0eb717..0000000000 --- a/tests/run-pass/ptr_offset.rs +++ /dev/null @@ -1,16 +0,0 @@ -fn f() -> i32 { 42 } - -fn main() { - let v = [1i16, 2]; - let x = &v as *const [i16; 2] as *const i16; - let x = unsafe { x.offset(1) }; - assert_eq!(unsafe { *x }, 2); - - // fn ptr offset - unsafe { - let p = f as fn() -> i32 as usize; - let x = (p as *mut u32).offset(0) as usize; - let f: fn() -> i32 = std::mem::transmute(x); - assert_eq!(f(), 42); - } -} diff --git a/tests/run-pass/raw.rs b/tests/run-pass/raw.rs deleted file mode 100644 index 4fbbb27095..0000000000 --- a/tests/run-pass/raw.rs +++ /dev/null @@ -1,21 +0,0 @@ -fn basic_raw() { - let mut x = 12; - let x = &mut x; - - assert_eq!(*x, 12); - - let raw = x as *mut i32; - unsafe { *raw = 42; } - - assert_eq!(*x, 42); - - let raw = x as *mut i32; - unsafe { *raw = 12; } - *x = 23; - - assert_eq!(*x, 23); -} - -fn main() { - basic_raw(); -} diff --git a/tests/run-pass/rc.rs b/tests/run-pass/rc.rs deleted file mode 100644 index 164842ab4d..0000000000 --- a/tests/run-pass/rc.rs +++ /dev/null @@ -1,80 +0,0 @@ -use std::cell::{Cell, RefCell}; -use std::rc::Rc; -use std::sync::Arc; -use std::fmt::Debug; - -fn rc_refcell() { - let r = Rc::new(RefCell::new(42)); - let r2 = r.clone(); - *r.borrow_mut() += 10; - let x = *r2.borrow(); - assert_eq!(x, 52); -} - -fn rc_cell() { - let r = Rc::new(Cell::new(42)); - let r2 = r.clone(); - let x = r.get(); - r2.set(x + x); - assert_eq!(r.get(), 84); -} - -fn rc_refcell2() { - let r = Rc::new(RefCell::new(42)); - let r2 = r.clone(); - *r.borrow_mut() += 10; - let x = r2.borrow(); - let r3 = r.clone(); - let y = r3.borrow(); - assert_eq!((*x + *y)/2, 52); -} - -fn rc_raw() { - let r = Rc::new(0); - let r2 = Rc::into_raw(r.clone()); - let r2 = unsafe { Rc::from_raw(r2) }; - assert!(Rc::ptr_eq(&r, &r2)); - drop(r); - assert!(Rc::try_unwrap(r2).is_ok()); -} - -fn arc() { - fn test() -> Arc { - let a = Arc::new(42); - a - } - assert_eq!(*test(), 42); -} - -// Make sure this Rc doesn't fall apart when touched -fn check_unique_rc(mut r: Rc) { - let r2 = r.clone(); - assert!(Rc::get_mut(&mut r).is_none()); - drop(r2); - assert!(Rc::get_mut(&mut r).is_some()); -} - -fn rc_from() { - check_unique_rc::<[_]>(Rc::from(&[1,2,3] as &[_])); - check_unique_rc::<[_]>(Rc::from(vec![1,2,3])); - check_unique_rc::<[_]>(Rc::from(Box::new([1,2,3]) as Box<[_]>)); - check_unique_rc::(Rc::from("Hello, World!")); -} - -fn rc_fat_ptr_eq() { - let p = Rc::new(1) as Rc; - let a: *const Debug = &*p; - let r = Rc::into_raw(p); - assert!(a == r); - drop(unsafe { Rc::from_raw(r) }); -} - -fn main() { - rc_fat_ptr_eq(); - rc_refcell(); - rc_refcell2(); - rc_cell(); - rc_raw(); - rc_from(); - arc(); -} diff --git a/tests/run-pass/realloc.rs b/tests/run-pass/realloc.rs deleted file mode 100644 index c23b3e645c..0000000000 --- a/tests/run-pass/realloc.rs +++ /dev/null @@ -1,45 +0,0 @@ -//ignore-windows: Uses POSIX APIs - -#![feature(rustc_private)] - -use core::{slice, ptr}; - -extern crate libc; - -fn main() { - unsafe { - // Use calloc for initialized memory - let p1 = libc::calloc(20, 1); - - // old size < new size - let p2 = libc::realloc(p1, 40); - let slice = slice::from_raw_parts(p2 as *const u8, 20); - assert_eq!(&slice, &[0_u8; 20]); - - // old size == new size - let p3 = libc::realloc(p2, 40); - let slice = slice::from_raw_parts(p3 as *const u8, 20); - assert_eq!(&slice, &[0_u8; 20]); - - // old size > new size - let p4 = libc::realloc(p3, 10); - let slice = slice::from_raw_parts(p4 as *const u8, 10); - assert_eq!(&slice, &[0_u8; 10]); - - libc::free(p4); - } - - unsafe { - let p1 = libc::malloc(20); - - let p2 = libc::realloc(p1, 0); - assert!(p2.is_null()); - } - - unsafe { - let p1 = libc::realloc(ptr::null_mut(), 20); - assert!(!p1.is_null()); - - libc::free(p1); - } -} diff --git a/tests/run-pass/recursive_static.rs b/tests/run-pass/recursive_static.rs deleted file mode 100644 index 77f2902917..0000000000 --- a/tests/run-pass/recursive_static.rs +++ /dev/null @@ -1,9 +0,0 @@ -struct S(&'static S); -static S1: S = S(&S2); -static S2: S = S(&S1); - -fn main() { - let p: *const S = S2.0; - let q: *const S = &S1; - assert_eq!(p, q); -} diff --git a/tests/run-pass/ref-invalid-ptr.rs b/tests/run-pass/ref-invalid-ptr.rs deleted file mode 100644 index e0e7d2afef..0000000000 --- a/tests/run-pass/ref-invalid-ptr.rs +++ /dev/null @@ -1,12 +0,0 @@ -// FIXME: validation disabled because it checks these references too eagerly. -// compile-flags: -Zmiri-disable-validation - -fn main() { - let x = 2usize as *const u32; - // This is not aligned, but we immediately cast it to a raw ptr so that must be ok. - let _y = unsafe { &*x as *const u32 }; - - let x = 0usize as *const u32; - // This is NULL, but we immediately cast it to a raw ptr so that must be ok. - let _y = unsafe { &*x as *const u32 }; -} diff --git a/tests/run-pass/refcell.rs b/tests/run-pass/refcell.rs deleted file mode 100644 index 93cef1572a..0000000000 --- a/tests/run-pass/refcell.rs +++ /dev/null @@ -1,33 +0,0 @@ -use std::cell::RefCell; - -fn main() { - let c = RefCell::new(42); - { - let s1 = c.borrow(); - let _x: i32 = *s1; - let s2 = c.borrow(); - let _x: i32 = *s1; - let _y: i32 = *s2; - let _x: i32 = *s1; - let _y: i32 = *s2; - } - { - let mut m = c.borrow_mut(); - let _z: i32 = *m; - { - let s: &i32 = &*m; - let _x = *s; - } - *m = 23; - let _z: i32 = *m; - } - { - let s1 = c.borrow(); - let _x: i32 = *s1; - let s2 = c.borrow(); - let _x: i32 = *s1; - let _y: i32 = *s2; - let _x: i32 = *s1; - let _y: i32 = *s2; - } -} diff --git a/tests/run-pass/regions-lifetime-nonfree-late-bound.rs b/tests/run-pass/regions-lifetime-nonfree-late-bound.rs deleted file mode 100644 index 85a189007c..0000000000 --- a/tests/run-pass/regions-lifetime-nonfree-late-bound.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This is a regression test for the ICE from issue #10846. -// -// The original issue causing the ICE: the LUB-computations during -// type inference were encountering late-bound lifetimes, and -// asserting that such lifetimes should have already been substituted -// with a concrete lifetime. -// -// However, those encounters were occurring within the lexical scope -// of the binding for the late-bound lifetime; that is, the late-bound -// lifetimes were perfectly valid. The core problem was that the type -// folding code was over-zealously passing back all lifetimes when -// doing region-folding, when really all clients of the region-folding -// case only want to see *free* lifetime variables, not bound ones. - -#![feature(box_syntax)] - -pub fn main() { - fn explicit() { - fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} - test(Some(box |_f: Box FnMut(&'a isize)>| {})); - } - - // The code below is shorthand for the code above (and more likely - // to represent what one encounters in practice). - fn implicit() { - fn test(_x: Option>) where F: FnMut(Box< FnMut(& isize)>) {} - test(Some(box |_f: Box< FnMut(& isize)>| {})); - } - - explicit(); - implicit(); -} diff --git a/tests/run-pass/regions-mock-trans.rs b/tests/run-pass/regions-mock-trans.rs deleted file mode 100644 index 020ed4927a..0000000000 --- a/tests/run-pass/regions-mock-trans.rs +++ /dev/null @@ -1,53 +0,0 @@ -//ignore-windows: Uses POSIX APIs - -#![feature(rustc_private)] - -#![allow(dead_code)] - -extern crate libc; -use std::mem; - -struct Arena(()); - -struct Bcx<'a> { - fcx: &'a Fcx<'a> -} - -struct Fcx<'a> { - arena: &'a Arena, - ccx: &'a Ccx -} - -struct Ccx { - x: isize -} - -fn alloc<'a>(_bcx : &'a Arena) -> &'a mut Bcx<'a> { - unsafe { - mem::transmute(libc::malloc(mem::size_of::>() - as libc::size_t)) - } -} - -fn h<'a>(bcx : &'a Bcx<'a>) -> &'a mut Bcx<'a> { - return alloc(bcx.fcx.arena); -} - -fn g(fcx : &Fcx) { - let bcx = Bcx { fcx: fcx }; - let bcx2 = h(&bcx); - unsafe { - libc::free(mem::transmute(bcx2)); - } -} - -fn f(ccx : &Ccx) { - let a = Arena(()); - let fcx = Fcx { arena: &a, ccx: ccx }; - return g(&fcx); -} - -pub fn main() { - let ccx = Ccx { x: 0 }; - f(&ccx); -} diff --git a/tests/run-pass/rfc1623.rs b/tests/run-pass/rfc1623.rs deleted file mode 100644 index 2f893d8150..0000000000 --- a/tests/run-pass/rfc1623.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![allow(dead_code)] - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &str = "&'static str"; -const CONST_STR: &str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_FN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_FN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(_a: &u8, _b: &u8, _c: &u8) {} - -static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo = Foo { bools: &[true, false] }; -const CONST_FOO: Foo = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar = Bar { bools: &[true, false] }; -const CONST_BAR: Bar = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &Baz = &(baz as Baz); -const CONST_BAZ: &Baz = &(baz as Baz); - -static BYTES: &[u8] = &[1, 2, 3]; - -fn main() { - // make sure that the lifetime is actually elided (and not defaulted) - let x = &[1u8, 2, 3]; - STATIC_SIMPLE_FN(x); - CONST_SIMPLE_FN(x); - - STATIC_BAZ(BYTES); // neees static lifetime - CONST_BAZ(BYTES); - - // make sure this works with different lifetimes - let a = &1; - { - let b = &2; - let c = &3; - CONST_MULTI_FN(a, b, c); - } -} diff --git a/tests/run-pass/rust-lang-org.rs b/tests/run-pass/rust-lang-org.rs deleted file mode 100644 index 7ba68e6b23..0000000000 --- a/tests/run-pass/rust-lang-org.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This code is editable and runnable! -fn main() { - // A simple integer calculator: - // `+` or `-` means add or subtract by 1 - // `*` or `/` means multiply or divide by 2 - - let program = "+ + * - /"; - let mut accumulator = 0; - - for token in program.chars() { - match token { - '+' => accumulator += 1, - '-' => accumulator -= 1, - '*' => accumulator *= 2, - '/' => accumulator /= 2, - _ => { /* ignore everything else */ } - } - } - - assert_eq!(accumulator, 1); -} diff --git a/tests/run-pass/send-is-not-static-par-for.rs b/tests/run-pass/send-is-not-static-par-for.rs deleted file mode 100644 index 396a87fca0..0000000000 --- a/tests/run-pass/send-is-not-static-par-for.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::sync::Mutex; - -fn par_for(iter: I, f: F) - where I: Iterator, - I::Item: Send, - F: Fn(I::Item) + Sync -{ - for item in iter { - f(item) - } -} - -fn sum(x: &[i32]) { - let sum_lengths = Mutex::new(0); - par_for(x.windows(4), |x| { - *sum_lengths.lock().unwrap() += x.len() - }); - - assert_eq!(*sum_lengths.lock().unwrap(), (x.len() - 3) * 4); -} - -fn main() { - let mut elements = [0; 20]; - - // iterators over references into this stack frame - par_for(elements.iter_mut().enumerate(), |(i, x)| { - *x = i as i32 - }); - - sum(&elements) -} diff --git a/tests/run-pass/sendable-class.rs b/tests/run-pass/sendable-class.rs deleted file mode 100644 index b2feb5316f..0000000000 --- a/tests/run-pass/sendable-class.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Test that a class with only sendable fields can be sent - -use std::sync::mpsc::channel; - -#[allow(dead_code)] -struct Foo { - i: isize, - j: char, -} - -fn foo(i:isize, j: char) -> Foo { - Foo { - i: i, - j: j - } -} - -pub fn main() { - let (tx, rx) = channel(); - tx.send(foo(42, 'c')).unwrap(); - let _val = rx; -} diff --git a/tests/run-pass/simd-intrinsic-generic-elements.rs b/tests/run-pass/simd-intrinsic-generic-elements.rs deleted file mode 100644 index e8fba6707d..0000000000 --- a/tests/run-pass/simd-intrinsic-generic-elements.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x2(i32, i32); -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x3(i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x8(i32, i32, i32, i32, - i32, i32, i32, i32); - -fn main() { - let _x2 = i32x2(20, 21); - let _x3 = i32x3(30, 31, 32); - let _x4 = i32x4(40, 41, 42, 43); - let _x8 = i32x8(80, 81, 82, 83, 84, 85, 86, 87); - - let _y2 = i32x2(120, 121); - let _y3 = i32x3(130, 131, 132); - let _y4 = i32x4(140, 141, 142, 143); - let _y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187); - -} diff --git a/tests/run-pass/slices.rs b/tests/run-pass/slices.rs deleted file mode 100644 index 4506a72e8d..0000000000 --- a/tests/run-pass/slices.rs +++ /dev/null @@ -1,175 +0,0 @@ -use std::slice; - -fn slice_of_zst() { - fn foo(v: &[T]) -> Option<&[T]> { - let mut it = v.iter(); - for _ in 0..5 { - it.next(); - } - Some(it.as_slice()) - } - - fn foo_mut(v: &mut [T]) -> Option<&mut [T]> { - let mut it = v.iter_mut(); - for _ in 0..5 { - it.next(); - } - Some(it.into_slice()) - } - - // In a slice of zero-size elements the pointer is meaningless. - // Ensure iteration still works even if the pointer is at the end of the address space. - let slice: &[()] = unsafe { slice::from_raw_parts(-5isize as *const (), 10) }; - assert_eq!(slice.len(), 10); - assert_eq!(slice.iter().count(), 10); - - // .nth() on the iterator should also behave correctly - let mut it = slice.iter(); - assert!(it.nth(5).is_some()); - assert_eq!(it.count(), 4); - - // Converting Iter to a slice should never have a null pointer - assert!(foo(slice).is_some()); - - // Test mutable iterators as well - let slice: &mut [()] = unsafe { slice::from_raw_parts_mut(-5isize as *mut (), 10) }; - assert_eq!(slice.len(), 10); - assert_eq!(slice.iter_mut().count(), 10); - - { - let mut it = slice.iter_mut(); - assert!(it.nth(5).is_some()); - assert_eq!(it.count(), 4); - } - - assert!(foo_mut(slice).is_some()) -} - -fn test_iter_ref_consistency() { - use std::fmt::Debug; - - fn test(x : T) { - let v : &[T] = &[x, x, x]; - let v_ptrs : [*const T; 3] = match v { - [ref v1, ref v2, ref v3] => [v1 as *const _, v2 as *const _, v3 as *const _], - _ => unreachable!() - }; - let len = v.len(); - - // nth(i) - for i in 0..len { - assert_eq!(&v[i] as *const _, v_ptrs[i]); // check the v_ptrs array, just to be sure - let nth = v.iter().nth(i).unwrap(); - assert_eq!(nth as *const _, v_ptrs[i]); - } - assert_eq!(v.iter().nth(len), None, "nth(len) should return None"); - - // stepping through with nth(0) - { - let mut it = v.iter(); - for i in 0..len { - let next = it.nth(0).unwrap(); - assert_eq!(next as *const _, v_ptrs[i]); - } - assert_eq!(it.nth(0), None); - } - - // next() - { - let mut it = v.iter(); - for i in 0..len { - let remaining = len - i; - assert_eq!(it.size_hint(), (remaining, Some(remaining))); - - let next = it.next().unwrap(); - assert_eq!(next as *const _, v_ptrs[i]); - } - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next(), None, "The final call to next() should return None"); - } - - // next_back() - { - let mut it = v.iter(); - for i in 0..len { - let remaining = len - i; - assert_eq!(it.size_hint(), (remaining, Some(remaining))); - - let prev = it.next_back().unwrap(); - assert_eq!(prev as *const _, v_ptrs[remaining-1]); - } - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next_back(), None, "The final call to next_back() should return None"); - } - } - - fn test_mut(x : T) { - let v : &mut [T] = &mut [x, x, x]; - let v_ptrs : [*mut T; 3] = match v { - [ref v1, ref v2, ref v3] => - [v1 as *const _ as *mut _, v2 as *const _ as *mut _, v3 as *const _ as *mut _], - _ => unreachable!() - }; - let len = v.len(); - - // nth(i) - for i in 0..len { - assert_eq!(&mut v[i] as *mut _, v_ptrs[i]); // check the v_ptrs array, just to be sure - let nth = v.iter_mut().nth(i).unwrap(); - assert_eq!(nth as *mut _, v_ptrs[i]); - } - assert_eq!(v.iter().nth(len), None, "nth(len) should return None"); - - // stepping through with nth(0) - { - let mut it = v.iter(); - for i in 0..len { - let next = it.nth(0).unwrap(); - assert_eq!(next as *const _, v_ptrs[i]); - } - assert_eq!(it.nth(0), None); - } - - // next() - { - let mut it = v.iter_mut(); - for i in 0..len { - let remaining = len - i; - assert_eq!(it.size_hint(), (remaining, Some(remaining))); - - let next = it.next().unwrap(); - assert_eq!(next as *mut _, v_ptrs[i]); - } - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next(), None, "The final call to next() should return None"); - } - - // next_back() - { - let mut it = v.iter_mut(); - for i in 0..len { - let remaining = len - i; - assert_eq!(it.size_hint(), (remaining, Some(remaining))); - - let prev = it.next_back().unwrap(); - assert_eq!(prev as *mut _, v_ptrs[remaining-1]); - } - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next_back(), None, "The final call to next_back() should return None"); - } - } - - // Make sure iterators and slice patterns yield consistent addresses for various types, - // including ZSTs. - test(0u32); - test(()); - test([0u32; 0]); // ZST with alignment > 0 - test_mut(0u32); - test_mut(()); - test_mut([0u32; 0]); // ZST with alignment > 0 -} - -fn main() { - slice_of_zst(); - test_iter_ref_consistency(); -} diff --git a/tests/run-pass/small_enum_size_bug.rs b/tests/run-pass/small_enum_size_bug.rs deleted file mode 100644 index 7576a97e36..0000000000 --- a/tests/run-pass/small_enum_size_bug.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![allow(dead_code)] - -enum E { - A = 1, - B = 2, - C = 3, -} - -fn main() { - let enone = None::; - if let Some(..) = enone { - panic!(); - } -} diff --git a/tests/run-pass/specialization.rs b/tests/run-pass/specialization.rs deleted file mode 100644 index 13894926d3..0000000000 --- a/tests/run-pass/specialization.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(specialization)] - -trait IsUnit { - fn is_unit() -> bool; -} - -impl IsUnit for T { - default fn is_unit() -> bool { false } -} - -impl IsUnit for () { - fn is_unit() -> bool { true } -} - -fn specialization() -> (bool, bool) { - (i32::is_unit(), <()>::is_unit()) -} - -fn main() { - assert_eq!(specialization(), (false, true)); -} diff --git a/tests/run-pass/stacked-borrows/2phase.rs b/tests/run-pass/stacked-borrows/2phase.rs deleted file mode 100644 index 97f435472e..0000000000 --- a/tests/run-pass/stacked-borrows/2phase.rs +++ /dev/null @@ -1,89 +0,0 @@ -#![allow(mutable_borrow_reservation_conflict)] - -trait S: Sized { - fn tpb(&mut self, _s: Self) {} -} - -impl S for i32 {} - -fn two_phase1() { - let mut x = 3; - x.tpb(x); -} - -fn two_phase2() { - let mut v = vec![]; - v.push(v.len()); -} - -fn two_phase3(b: bool) { - let mut x = &mut vec![]; - let mut y = vec![]; - x.push(( - { - if b { x = &mut y }; - 22 - }, - x.len(), - )); -} - -#[allow(unreachable_code)] -fn two_phase_raw() { - let x: &mut Vec = &mut vec![]; - x.push( - { - // Unfortunately this does not trigger the problem of creating a - // raw ponter from a pointer that had a two-phase borrow derived from - // it because of the implicit &mut reborrow. - let raw = x as *mut _; - unsafe { *raw = vec![1]; } - return - } - ); -} - -fn two_phase_overlapping1() { - let mut x = vec![]; - let p = &x; - x.push(p.len()); -} - -fn two_phase_overlapping2() { - use std::ops::AddAssign; - let mut x = 1; - let l = &x; - x.add_assign(x + *l); -} - -fn with_interior_mutability() { - use std::cell::Cell; - - trait Thing: Sized { - fn do_the_thing(&mut self, _s: i32) {} - } - - impl Thing for Cell {} - - let mut x = Cell::new(1); - let l = &x; - - x - .do_the_thing({ - x.set(3); - l.set(4); - x.get() + l.get() - }) - ; -} - -fn main() { - two_phase1(); - two_phase2(); - two_phase3(false); - two_phase3(true); - two_phase_raw(); - with_interior_mutability(); - two_phase_overlapping1(); - two_phase_overlapping2(); -} diff --git a/tests/run-pass/stacked-borrows/interior_mutability.rs b/tests/run-pass/stacked-borrows/interior_mutability.rs deleted file mode 100644 index 33f44d0093..0000000000 --- a/tests/run-pass/stacked-borrows/interior_mutability.rs +++ /dev/null @@ -1,59 +0,0 @@ -#![feature(maybe_uninit, maybe_uninit_ref)] -use std::mem::MaybeUninit; -use std::cell::Cell; -use std::cell::RefCell; - -fn main() { - aliasing_mut_and_shr(); - aliasing_frz_and_shr(); - into_interior_mutability(); -} - -fn aliasing_mut_and_shr() { - fn inner(rc: &RefCell, aliasing: &mut i32) { - *aliasing += 4; - let _escape_to_raw = rc as *const _; - *aliasing += 4; - let _shr = &*rc; - *aliasing += 4; - // also turning this into a frozen ref now must work - let aliasing = &*aliasing; - let _val = *aliasing; - let _escape_to_raw = rc as *const _; // this must NOT unfreeze - let _val = *aliasing; - let _shr = &*rc; // this must NOT unfreeze - let _val = *aliasing; - } - - let rc = RefCell::new(23); - let mut bmut = rc.borrow_mut(); - inner(&rc, &mut *bmut); - drop(bmut); - assert_eq!(*rc.borrow(), 23+12); -} - -fn aliasing_frz_and_shr() { - fn inner(rc: &RefCell, aliasing: &i32) { - let _val = *aliasing; - let _escape_to_raw = rc as *const _; // this must NOT unfreeze - let _val = *aliasing; - let _shr = &*rc; // this must NOT unfreeze - let _val = *aliasing; - } - - let rc = RefCell::new(23); - let bshr = rc.borrow(); - inner(&rc, &*bshr); - assert_eq!(*rc.borrow(), 23); -} - -// Getting a pointer into a union with interior mutability used to be tricky -// business (https://github.com/rust-lang/miri/issues/615), but it should work -// now. -fn into_interior_mutability() { - let mut x: MaybeUninit<(Cell, u32)> = MaybeUninit::uninit(); - x.as_ptr(); - x.write((Cell::new(0), 1)); - let ptr = unsafe { x.get_ref() }; - assert_eq!(ptr.1, 1); -} diff --git a/tests/run-pass/stacked-borrows/stacked-borrows.rs b/tests/run-pass/stacked-borrows/stacked-borrows.rs deleted file mode 100644 index 7d84e33b3d..0000000000 --- a/tests/run-pass/stacked-borrows/stacked-borrows.rs +++ /dev/null @@ -1,151 +0,0 @@ -// Test various stacked-borrows-related things. -fn main() { - deref_partially_dangling_raw(); - read_does_not_invalidate1(); - read_does_not_invalidate2(); - ref_raw_int_raw(); - mut_raw_then_mut_shr(); - mut_shr_then_mut_raw(); - mut_raw_mut(); - partially_invalidate_mut(); - drop_after_sharing(); - direct_mut_to_const_raw(); - two_raw(); - shr_and_raw(); -} - -// Deref a raw ptr to access a field of a large struct, where the field -// is allocated but not the entire struct is. -// For now, we want to allow this. -fn deref_partially_dangling_raw() { - let x = (1, 13); - let xptr = &x as *const _ as *const (i32, i32, i32); - let val = unsafe { (*xptr).1 }; - assert_eq!(val, 13); -} - -// Make sure that reading from an `&mut` does, like reborrowing to `&`, -// NOT invalidate other reborrows. -fn read_does_not_invalidate1() { - fn foo(x: &mut (i32, i32)) -> &i32 { - let xraw = x as *mut (i32, i32); - let ret = unsafe { &(*xraw).1 }; - let _val = x.1; // we just read, this does NOT invalidate the reborrows. - ret - } - assert_eq!(*foo(&mut (1, 2)), 2); -} -// Same as above, but this time we first create a raw, then read from `&mut` -// and then freeze from the raw. -fn read_does_not_invalidate2() { - fn foo(x: &mut (i32, i32)) -> &i32 { - let xraw = x as *mut (i32, i32); - let _val = x.1; // we just read, this does NOT invalidate the raw reborrow. - let ret = unsafe { &(*xraw).1 }; - ret - } - assert_eq!(*foo(&mut (1, 2)), 2); -} - -// Just to make sure that casting a ref to raw, to int and back to raw -// and only then using it works. This rules out ideas like "do escape-to-raw lazily"; -// after casting to int and back, we lost the tag that could have let us do that. -fn ref_raw_int_raw() { - let mut x = 3; - let xref = &mut x; - let xraw = xref as *mut i32 as usize as *mut i32; - assert_eq!(unsafe { *xraw }, 3); -} - -// Escape a mut to raw, then share the same mut and use the share, then the raw. -// That should work. -fn mut_raw_then_mut_shr() { - let mut x = 2; - let xref = &mut x; - let xraw = &mut *xref as *mut _; - let xshr = &*xref; - assert_eq!(*xshr, 2); - unsafe { *xraw = 4; } - assert_eq!(x, 4); -} - -// Create first a shared reference and then a raw pointer from a `&mut` -// should permit mutation through that raw pointer. -fn mut_shr_then_mut_raw() { - let xref = &mut 2; - let _xshr = &*xref; - let xraw = xref as *mut _; - unsafe { *xraw = 3; } - assert_eq!(*xref, 3); -} - -// Ensure that if we derive from a mut a raw, and then from that a mut, -// and then read through the original mut, that does not invalidate the raw. -// This shows that the read-exception for `&mut` applies even if the `Shr` item -// on the stack is not at the top. -fn mut_raw_mut() { - let mut x = 2; - { - let xref1 = &mut x; - let xraw = xref1 as *mut _; - let _xref2 = unsafe { &mut *xraw }; - let _val = *xref1; - unsafe { *xraw = 4; } - // we can now use both xraw and xref1, for reading - assert_eq!(*xref1, 4); - assert_eq!(unsafe { *xraw }, 4); - assert_eq!(*xref1, 4); - assert_eq!(unsafe { *xraw }, 4); - // we cannot use xref2; see `compile-fail/stacked-borows/illegal_read4.rs` - } - assert_eq!(x, 4); -} - -fn partially_invalidate_mut() { - let data = &mut (0u8, 0u8); - let reborrow = &mut *data as *mut (u8, u8); - let shard = unsafe { &mut (*reborrow).0 }; - data.1 += 1; // the deref overlaps with `shard`, but that is ok; the access does not overlap. - *shard += 1; // so we can still use `shard`. - assert_eq!(*data, (1, 1)); -} - -// Make sure that we can handle the situation where a loaction is frozen when being dropped. -fn drop_after_sharing() { - let x = String::from("hello!"); - let _len = x.len(); -} - -// Make sure that coercing &mut T to *const T produces a writeable pointer. -fn direct_mut_to_const_raw() { - // FIXME: This is currently disabled, waiting on a fix for - /*let x = &mut 0; - let y: *const i32 = x; - unsafe { *(y as *mut i32) = 1; } - assert_eq!(*x, 1); - */ -} - -// Make sure that we can create two raw pointers from a mutable reference and use them both. -fn two_raw() { unsafe { - let x = &mut 0; - // Given the implicit reborrows, the only reason this currently works is that we - // do not track raw pointers: The creation of `y2` reborrows `x` and thus pops - // `y1` off the stack. - let y1 = x as *mut _; - let y2 = x as *mut _; - *y1 += 2; - *y2 += 1; -} } - -// Make sure that creating a *mut does not invalidate existing shared references. -fn shr_and_raw() { /* unsafe { - use std::mem; - // FIXME: This is currently disabled because "as *mut _" incurs a reborrow. - let x = &mut 0; - let y1: &i32 = mem::transmute(&*x); // launder lifetimes - let y2 = x as *mut _; - let _val = *y1; - *y2 += 1; - // TODO: Once this works, add compile-fail test that tries to read from y1 again. -} */ } diff --git a/tests/run-pass/static_memory_modification.rs b/tests/run-pass/static_memory_modification.rs deleted file mode 100644 index 6a41078177..0000000000 --- a/tests/run-pass/static_memory_modification.rs +++ /dev/null @@ -1,14 +0,0 @@ -use std::sync::atomic::{Ordering, AtomicUsize}; - -static mut X: usize = 5; -static Y: AtomicUsize = AtomicUsize::new(5); - -fn main() { - unsafe { - X = 6; - assert_eq!(X, 6); - } - - Y.store(6, Ordering::Relaxed); - assert_eq!(Y.load(Ordering::Relaxed), 6); -} diff --git a/tests/run-pass/static_mut.rs b/tests/run-pass/static_mut.rs deleted file mode 100644 index be5830698b..0000000000 --- a/tests/run-pass/static_mut.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![allow(dead_code)] - -static mut FOO: i32 = 42; -static BAR: Foo = Foo(unsafe { &FOO as *const _} ); - -struct Foo(*const i32); - -unsafe impl Sync for Foo {} - -fn main() { - unsafe { - assert_eq!(*BAR.0, 42); - FOO = 5; - assert_eq!(FOO, 5); - assert_eq!(*BAR.0, 5); - } -} diff --git a/tests/run-pass/strings.rs b/tests/run-pass/strings.rs deleted file mode 100644 index fa692ba3de..0000000000 --- a/tests/run-pass/strings.rs +++ /dev/null @@ -1,34 +0,0 @@ -fn empty() -> &'static str { - "" -} - -fn hello() -> &'static str { - "Hello, world!" -} - -fn hello_bytes() -> &'static [u8; 13] { - b"Hello, world!" -} - -fn hello_bytes_fat() -> &'static [u8] { - b"Hello, world!" -} - -fn fat_pointer_on_32_bit() { - Some(5).expect("foo"); -} - -fn str_indexing() { - let mut x = "Hello".to_string(); - let _v = &mut x[..3]; // Test IndexMut on String. -} - -fn main() { - assert_eq!(empty(), ""); - assert_eq!(hello(), "Hello, world!"); - assert_eq!(hello_bytes(), b"Hello, world!"); - assert_eq!(hello_bytes_fat(), b"Hello, world!"); - - fat_pointer_on_32_bit(); // Should run without crashing. - str_indexing(); -} diff --git a/tests/run-pass/subslice_array.rs b/tests/run-pass/subslice_array.rs deleted file mode 100644 index 5bbbffe4e6..0000000000 --- a/tests/run-pass/subslice_array.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(slice_patterns)] - -fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { - [a, b, b, a] -} - -fn main() { - let out = bar("baz", "foo"); - let [a, xs.., d] = out; - assert_eq!(a, "baz"); - assert_eq!(xs, ["foo", "foo"]); - assert_eq!(d, "baz"); -} diff --git a/tests/run-pass/sums.rs b/tests/run-pass/sums.rs deleted file mode 100644 index daeba060a7..0000000000 --- a/tests/run-pass/sums.rs +++ /dev/null @@ -1,56 +0,0 @@ -#[derive(Debug, PartialEq)] -enum Unit { Unit(()) } // Force non-C-enum representation. - -fn return_unit() -> Unit { - Unit::Unit(()) -} - -#[derive(Debug, PartialEq)] -enum MyBool { False(()), True(()) } // Force non-C-enum representation. - -fn return_true() -> MyBool { - MyBool::True(()) -} - -fn return_false() -> MyBool { - MyBool::False(()) -} - -fn return_none() -> Option { - None -} - -fn return_some() -> Option { - Some(42) -} - -fn match_opt_none() -> i8 { - let x = None; - match x { - Some(data) => data, - None => 42, - } -} - -fn match_opt_some() -> i8 { - let x = Some(13); - match x { - Some(data) => data, - None => 20, - } -} - -fn two_nones() -> (Option, Option) { - (None, None) -} - -fn main() { - assert_eq!(two_nones(), (None, None)); - assert_eq!(match_opt_some(), 13); - assert_eq!(match_opt_none(), 42); - assert_eq!(return_some(), Some(42)); - assert_eq!(return_none(), None); - assert_eq!(return_false(), MyBool::False(())); - assert_eq!(return_true(), MyBool::True(())); - assert_eq!(return_unit(), Unit::Unit(())); -} diff --git a/tests/run-pass/tag-align-dyn-u64.rs b/tests/run-pass/tag-align-dyn-u64.rs deleted file mode 100644 index 81c19022ab..0000000000 --- a/tests/run-pass/tag-align-dyn-u64.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -use std::mem; - -enum Tag { - Tag2(A) -} - -struct Rec { - c8: u8, - t: Tag -} - -fn mk_rec() -> Rec { - return Rec { c8:0, t:Tag::Tag2(0) }; -} - -fn is_u64_aligned(u: &Tag) -> bool { - let p: usize = unsafe { mem::transmute(u) }; - let u64_align = std::mem::align_of::(); - return (p & (u64_align - 1)) == 0; -} - -pub fn main() { - let x = mk_rec(); - assert!(is_u64_aligned(&x.t)); -} diff --git a/tests/run-pass/thread-local.rs b/tests/run-pass/thread-local.rs deleted file mode 100644 index aeedb7034c..0000000000 --- a/tests/run-pass/thread-local.rs +++ /dev/null @@ -1,67 +0,0 @@ -//ignore-windows: Uses POSIX APIs - -#![feature(rustc_private)] -extern crate libc; - -use std::mem; - -pub type Key = libc::pthread_key_t; - -static mut RECORD : usize = 0; -static mut KEYS : [Key; 2] = [0; 2]; -static mut GLOBALS : [u64; 2] = [1, 0]; - -static mut CANNARY : *mut u64 = 0 as *mut _; // this serves as a cannary: if TLS dtors are not run properly, this will not get deallocated, making the test fail. - -pub unsafe fn create(dtor: Option) -> Key { - let mut key = 0; - assert_eq!(libc::pthread_key_create(&mut key, mem::transmute(dtor)), 0); - key -} - -pub unsafe fn set(key: Key, value: *mut u8) { - let r = libc::pthread_setspecific(key, value as *mut _); - assert_eq!(r, 0); -} - -pub fn record(r: usize) { - assert!(r < 10); - unsafe { RECORD = RECORD*10 + r }; -} - -unsafe extern fn dtor(ptr: *mut u64) { - assert!(CANNARY != 0 as *mut _); // make sure we do not get run too often - let val = *ptr; - - let which_key = GLOBALS.iter().position(|global| global as *const _ == ptr).expect("Should find my global"); - record(which_key); - - if val > 0 { - *ptr = val-1; - set(KEYS[which_key], ptr as *mut _); - } - - // Check if the records matches what we expect. If yes, clear the cannary. - // If the record is wrong, the cannary will never get cleared, leading to a leak -> test fails. - // If the record is incomplete (i.e., more dtor calls happen), the check at the beginning of this function will fail -> test fails. - // The correct sequence is: First key 0, then key 1, then key 0. - if RECORD == 0_1_0 { - drop(Box::from_raw(CANNARY)); - CANNARY = 0 as *mut _; - } -} - -fn main() { - unsafe { - create(None); // check that the no-dtor case works - - // Initialize the keys we use to check destructor ordering - for (key, global) in KEYS.iter_mut().zip(GLOBALS.iter()) { - *key = create(Some(mem::transmute(dtor as unsafe extern fn(*mut u64)))); - set(*key, global as *const _ as *mut _); - } - - // Initialize cannary - CANNARY = Box::into_raw(Box::new(0u64)); - } -} diff --git a/tests/run-pass/threads.rs b/tests/run-pass/threads.rs deleted file mode 100644 index dad47d85a2..0000000000 --- a/tests/run-pass/threads.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Just instantiate some data structures to make sure we got all their foreign items covered. -// Requires full MIR on Windows. - -use std::sync; - -fn main() { - let m = sync::Mutex::new(0); - drop(m.lock()); - drop(m); - - // We don't provide RwLock on Windows - #[cfg(not(target_os = "windows"))] - { - let rw = sync::RwLock::new(0); - drop(rw.read()); - drop(rw.write()); - drop(rw); - } -} diff --git a/tests/run-pass/too-large-primval-write-problem.rs b/tests/run-pass/too-large-primval-write-problem.rs deleted file mode 100644 index ebd6dbb61e..0000000000 --- a/tests/run-pass/too-large-primval-write-problem.rs +++ /dev/null @@ -1,23 +0,0 @@ -// `PrimVal`s in Miri are represented with 8 bytes (u64) and at the time of writing, the `-x` -// will sign extend into the entire 8 bytes. Then, if you tried to write the `-x` into -// something smaller than 8 bytes, like a 4 byte pointer, it would crash in byteorder crate -// code that assumed only the low 4 bytes would be set. Actually, we were masking properly for -// everything except pointers before I fixed it, so this was probably impossible to reproduce on -// 64-bit. -// -// This is just intended as a regression test to make sure we don't reintroduce this problem. - -#[cfg(target_pointer_width = "32")] -fn main() { - use std::mem::transmute; - - // Make the weird PrimVal. - let x = 1i32; - let bad = unsafe { transmute::(-x) }; - - // Force it through the Memory::write_primval code. - Box::new(bad); -} - -#[cfg(not(target_pointer_width = "32"))] -fn main() {} diff --git a/tests/run-pass/traits.rs b/tests/run-pass/traits.rs deleted file mode 100644 index b2eae5d04f..0000000000 --- a/tests/run-pass/traits.rs +++ /dev/null @@ -1,30 +0,0 @@ -struct Struct(i32); - -trait Trait { - fn method(&self); -} - -impl Trait for Struct { - fn method(&self) { - assert_eq!(self.0, 42); - } -} - -struct Foo(T); - -fn main() { - let y: &Trait = &Struct(42); - y.method(); - let x: Foo = Foo(Struct(42)); - let y: &Foo = &x; - y.0.method(); - - let x: Box i32> = Box::new(|x| x * 2); - assert_eq!(x(21), 42); - let mut i = 5; - { - let mut x: Box = Box::new(|| i *= 2); - x(); x(); - } - assert_eq!(i, 20); -} diff --git a/tests/run-pass/transmute_fat.rs b/tests/run-pass/transmute_fat.rs deleted file mode 100644 index ec887902d0..0000000000 --- a/tests/run-pass/transmute_fat.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn main() { - // If we are careful, we can exploit data layout... - let raw = unsafe { - std::mem::transmute::<&[u8], [usize; 2]>(&[42]) - }; - let ptr = raw[0] + raw[1]; - let ptr = ptr as *const u8; - // The pointer is one-past-the end, but we decrement it into bounds before using it - assert_eq!(unsafe { *ptr.offset(-1) }, 42); -} diff --git a/tests/run-pass/trivial.rs b/tests/run-pass/trivial.rs deleted file mode 100644 index 891d115206..0000000000 --- a/tests/run-pass/trivial.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn empty() {} - -fn unit_var() { - let x = (); - x -} - -fn main() { - empty(); - unit_var(); -} diff --git a/tests/run-pass/try-operator-custom.rs b/tests/run-pass/try-operator-custom.rs deleted file mode 100644 index ccbf63796a..0000000000 --- a/tests/run-pass/try-operator-custom.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - assert!(Ok::(42) == Ok(42)); -} diff --git a/tests/run-pass/tuple_like_enum_variant_constructor.rs b/tests/run-pass/tuple_like_enum_variant_constructor.rs deleted file mode 100644 index 5cf91b3f4d..0000000000 --- a/tests/run-pass/tuple_like_enum_variant_constructor.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - assert_eq!(Some(42).map(Some), Some(Some(42))); -} diff --git a/tests/run-pass/tuple_like_enum_variant_constructor_pointer_opt.rs b/tests/run-pass/tuple_like_enum_variant_constructor_pointer_opt.rs deleted file mode 100644 index fb57d4f4c1..0000000000 --- a/tests/run-pass/tuple_like_enum_variant_constructor_pointer_opt.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let x = 5; - assert_eq!(Some(&x).map(Some), Some(Some(&x))); -} diff --git a/tests/run-pass/tuple_like_enum_variant_constructor_struct_pointer_opt.rs b/tests/run-pass/tuple_like_enum_variant_constructor_struct_pointer_opt.rs deleted file mode 100644 index 44441ed1d3..0000000000 --- a/tests/run-pass/tuple_like_enum_variant_constructor_struct_pointer_opt.rs +++ /dev/null @@ -1,33 +0,0 @@ -#[derive(Copy, Clone, PartialEq, Debug)] -struct A<'a> { - x: i32, - y: &'a i32, -} - -#[derive(Copy, Clone, PartialEq, Debug)] -struct B<'a>(i32, &'a i32); - -#[derive(Copy, Clone, PartialEq, Debug)] -enum C<'a> { - Value(i32, &'a i32), - #[allow(dead_code)] - NoValue, -} - -fn main() { - let x = 5; - let a = A { x: 99, y: &x }; - assert_eq!(Some(a).map(Some), Some(Some(a))); - let f = B; - assert_eq!(Some(B(42, &x)), Some(f(42, &x))); - // the following doesn't compile :( - //let f: for<'a> fn(i32, &'a i32) -> B<'a> = B; - //assert_eq!(Some(B(42, &x)), Some(f(42, &x))); - assert_eq!(B(42, &x), foo(&x, B)); - let f = C::Value; - assert_eq!(C::Value(42, &x), f(42, &x)); -} - -fn foo<'a, F: Fn(i32, &'a i32) -> B<'a>>(i: &'a i32, f: F) -> B<'a> { - f(42, i) -} diff --git a/tests/run-pass/tuple_like_struct_constructor.rs b/tests/run-pass/tuple_like_struct_constructor.rs deleted file mode 100644 index 05e8893de1..0000000000 --- a/tests/run-pass/tuple_like_struct_constructor.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - #[derive(PartialEq, Eq, Debug)] - struct A(i32); - assert_eq!(Some(42).map(A), Some(A(42))); -} diff --git a/tests/run-pass/u128.rs b/tests/run-pass/u128.rs deleted file mode 100644 index 5a5d7c1f94..0000000000 --- a/tests/run-pass/u128.rs +++ /dev/null @@ -1,65 +0,0 @@ -fn b(t: T) -> T { t } - -fn main() { - let x: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFF; - assert_eq!(0, !x); - assert_eq!(0, !x); - let y: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFE; - assert_eq!(!1, y); - assert_eq!(x, y | 1); - assert_eq!(0xFAFF_0000_FF8F_0000__FFFF_0000_FFFF_FFFE, - y & - 0xFAFF_0000_FF8F_0000__FFFF_0000_FFFF_FFFF); - let z: u128 = 0xABCD_EF; - assert_eq!(z * z, 0x734C_C2F2_A521); - assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); - assert_eq!(z + z + z + z, 0x2AF3_7BC); - let k: u128 = 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; - assert_eq!(k + k, 0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); - assert_eq!(0, k - k); - assert_eq!(0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k - z); - assert_eq!(0x1000_0000_0000_0000_0000_0000_0000_000, - k - 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!(0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); - assert_eq!(0, k % 42); - assert_eq!(15, z % 42); - assert_eq!(0x169D_A8020_CEC18, k % 0x3ACB_FE49_FF24_AC); - assert_eq!(0x91A2_B3C4_D5E6_F7, k >> 65); - assert_eq!(0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); - assert!(k > z); - assert!(y > k); - assert!(y < x); - assert_eq!(x as u64, !0); - assert_eq!(z as u64, 0xABCD_EF); - assert_eq!(k as u64, 0xFEDC_BA98_7654_3210); - assert_eq!(k as i128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!((z as f64) as u128, z); - assert_eq!((z as f32) as u128, z); - assert_eq!((z as f64 * 16.0) as u128, z * 16); - assert_eq!((z as f32 * 16.0) as u128, z * 16); - let l :u128 = 432 << 100; - assert_eq!((l as f32) as u128, l); - assert_eq!((l as f64) as u128, l); - // formatting - let j: u128 = 1 << 67; - assert_eq!("147573952589676412928", format!("{}", j)); - assert_eq!("80000000000000000", format!("{:x}", j)); - assert_eq!("20000000000000000000000", format!("{:o}", j)); - assert_eq!("10000000000000000000000000000000000000000000000000000000000000000000", - format!("{:b}", j)); - assert_eq!("340282366920938463463374607431768211455", - format!("{}", u128::max_value())); - assert_eq!("147573952589676412928", format!("{:?}", j)); - // common traits - assert_eq!(x, b(x.clone())); - // overflow checks - assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521)); - assert_eq!((k).checked_mul(k), None); - let l: u128 = b(u128::max_value() - 10); - let o: u128 = b(17); - assert_eq!(l.checked_add(b(11)), None); - assert_eq!(l.checked_sub(l), Some(0)); - assert_eq!(o.checked_sub(b(18)), None); - assert_eq!(b(1u128).checked_shl(b(127)), Some(1 << 127)); - assert_eq!(o.checked_shl(b(128)), None); -} diff --git a/tests/run-pass/union-overwrite.rs b/tests/run-pass/union-overwrite.rs deleted file mode 100644 index 5c618763c0..0000000000 --- a/tests/run-pass/union-overwrite.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![feature(untagged_unions)] -#![allow(unions_with_drop_fields)] - -#[repr(C)] -struct Pair(T, U); -#[repr(C)] -struct Triple(T, T, T); - -#[repr(C)] -union U { - a: Pair, - b: B, -} - -#[repr(C)] -union W { - a: A, - b: B, -} - -#[cfg(target_endian = "little")] -unsafe fn check() { - let mut u = U:: { b: 0xDE_DE }; - u.a.0 = 0xBE; - assert_eq!(u.b, 0xDE_BE); - - let mut u = U:: { b: 0xDEAD_DEAD }; - u.a.0 = 0xBEEF; - assert_eq!(u.b, 0xDEAD_BEEF); - - let mut u = U:: { b: 0xDEADBEEF_DEADBEEF }; - u.a.0 = 0xBAADF00D; - assert_eq!(u.b, 0xDEADBEEF_BAADF00D); - - let mut w = W::, u8>, u32> { b: 0xDEAD_DEAD }; - w.a.0 = Triple(0, 0, 0); - assert_eq!(w.b, 0xDE00_0000); - - let mut w = W::>, u32> { b: 0xDEAD_DEAD }; - w.a.1 = Triple(0, 0, 0); - assert_eq!(w.b, 0x0000_00AD); -} - -#[cfg(target_endian = "big")] -unsafe fn check() { - let mut u = U:: { b: 0xDE_DE }; - u.a.0 = 0xBE; - assert_eq!(u.b, 0xBE_DE); - - let mut u = U:: { b: 0xDEAD_DEAD }; - u.a.0 = 0xBEEF; - assert_eq!(u.b, 0xBEEF_DEAD); - - let mut u = U:: { b: 0xDEADBEEF_DEADBEEF }; - u.a.0 = 0xBAADF00D; - assert_eq!(u.b, 0xBAADF00D_DEADBEEF); - - let mut w = W::, u8>, u32> { b: 0xDEAD_DEAD }; - w.a.0 = Triple(0, 0, 0); - assert_eq!(w.b, 0x0000_00AD); - - let mut w = W::>, u32> { b: 0xDEAD_DEAD }; - w.a.1 = Triple(0, 0, 0); - assert_eq!(w.b, 0xDE00_0000); -} - -fn main() { - unsafe { - check(); - } -} diff --git a/tests/run-pass/union.rs b/tests/run-pass/union.rs deleted file mode 100644 index 342c94f3d4..0000000000 --- a/tests/run-pass/union.rs +++ /dev/null @@ -1,88 +0,0 @@ -#![feature(untagged_unions)] -#![allow(dead_code, unused_variables)] - -fn main() { - a(); - b(); - c(); - d(); -} - -fn a() { - union U { - f1: u32, - f2: f32, - } - let mut u = U { f1: 1 }; - unsafe { - let b1 = &mut u.f1; - *b1 = 5; - } - assert_eq!(unsafe { u.f1 }, 5); -} - -fn b() { - struct S { - x: u32, - y: u32, - } - - union U { - s: S, - both: u64, - } - let mut u = U { s: S { x: 1, y: 2 } }; - unsafe { - let bx = &mut u.s.x; - let by = &mut u.s.y; - *bx = 5; - *by = 10; - } - assert_eq!(unsafe { u.s.x }, 5); - assert_eq!(unsafe { u.s.y }, 10); -} - -fn c() { - #[repr(u32)] - enum Tag { I, F } - - #[repr(C)] - union U { - i: i32, - f: f32, - } - - #[repr(C)] - struct Value { - tag: Tag, - u: U, - } - - fn is_zero(v: Value) -> bool { - unsafe { - match v { - Value { tag: Tag::I, u: U { i: 0 } } => true, - Value { tag: Tag::F, u: U { f } } => f == 0.0, - _ => false, - } - } - } - assert!(is_zero(Value { tag: Tag::I, u: U { i: 0 }})); - assert!(is_zero(Value { tag: Tag::F, u: U { f: 0.0 }})); - assert!(!is_zero(Value { tag: Tag::I, u: U { i: 1 }})); - assert!(!is_zero(Value { tag: Tag::F, u: U { f: 42.0 }})); -} - -fn d() { - union MyUnion { - f1: u32, - f2: f32, - } - let u = MyUnion { f1: 10 }; - unsafe { - match u { - MyUnion { f1: 10 } => { } - MyUnion { f2 } => { panic!("foo"); } - } - } -} diff --git a/tests/run-pass/unique-send.rs b/tests/run-pass/unique-send.rs deleted file mode 100644 index 04dbf495f8..0000000000 --- a/tests/run-pass/unique-send.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(box_syntax)] - -use std::sync::mpsc::channel; - -pub fn main() { - let (tx, rx) = channel::>(); - tx.send(box 100).unwrap(); - let v = rx.recv().unwrap(); - assert_eq!(v, box 100); -} diff --git a/tests/run-pass/unops.rs b/tests/run-pass/unops.rs deleted file mode 100644 index 650c51ba5d..0000000000 --- a/tests/run-pass/unops.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - assert_eq!(!true, false); - assert_eq!(!0xFFu16, 0xFF00); - assert_eq!(-{1i16}, -1i16); -} diff --git a/tests/run-pass/unsized-tuple-impls.rs b/tests/run-pass/unsized-tuple-impls.rs deleted file mode 100644 index 54bd6f5c34..0000000000 --- a/tests/run-pass/unsized-tuple-impls.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(unsized_tuple_coercion)] -use std::mem; - -fn main() { - let x : &(i32, i32, [i32]) = &(0, 1, [2, 3]); - let y : &(i32, i32, [i32]) = &(0, 1, [2, 3, 4]); - let mut a = [y, x]; - a.sort(); - assert_eq!(a, [x, y]); - - assert_eq!(&format!("{:?}", a), "[(0, 1, [2, 3]), (0, 1, [2, 3, 4])]"); - assert_eq!(mem::size_of_val(x), 16); -} diff --git a/tests/run-pass/validation_lifetime_resolution.rs b/tests/run-pass/validation_lifetime_resolution.rs deleted file mode 100644 index a0eea51709..0000000000 --- a/tests/run-pass/validation_lifetime_resolution.rs +++ /dev/null @@ -1,30 +0,0 @@ -trait Id { - type Out; - - fn id(self) -> Self::Out; -} - -impl<'a> Id for &'a mut i32 { - type Out = &'a mut i32; - - fn id(self) -> Self { self } -} - -impl<'a> Id for &'a mut u32 { - type Out = &'a mut u32; - - fn id(self) -> Self { self } -} - -fn foo(mut x: T) where for<'a> &'a mut T: Id -{ - let x = &mut x; - let _y = x.id(); - // Inspecting the trace should show that `_y` has a type involving a local lifetime, when it gets validated. - // Unfortunately, there doesn't seem to be a way to actually have a test fail if it does not have the right - // type. Currently, this is *not* working correctly; see . -} - -fn main() { - foo(3) -} diff --git a/tests/run-pass/vec-matching-fold.rs b/tests/run-pass/vec-matching-fold.rs deleted file mode 100644 index f953e04747..0000000000 --- a/tests/run-pass/vec-matching-fold.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![feature(slice_patterns)] - -use std::fmt::Debug; - -fn foldl(values: &[T], - initial: U, - mut function: F) - -> U where - U: Clone+Debug, T:Debug, - F: FnMut(U, &T) -> U, -{ match values { - &[ref head, ref tail..] => - foldl(tail, function(initial, head), function), - &[] => { - let res = initial.clone(); res - } - } -} - -fn foldr(values: &[T], - initial: U, - mut function: F) - -> U where - U: Clone, - F: FnMut(&T, U) -> U, -{ - match values { - &[ref head.., ref tail] => - foldr(head, function(tail, initial), function), - &[] => { - let res = initial.clone(); res - } - } -} - -pub fn main() { - let x = &[1, 2, 3, 4, 5]; - - let product = foldl(x, 1, |a, b| a * *b); - assert_eq!(product, 120); - - let sum = foldr(x, 0, |a, b| *a + b); - assert_eq!(sum, 15); -} diff --git a/tests/run-pass/vecdeque.rs b/tests/run-pass/vecdeque.rs deleted file mode 100644 index 9c9909802e..0000000000 --- a/tests/run-pass/vecdeque.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::collections::VecDeque; - -fn main() { - let mut dst = VecDeque::new(); - dst.push_front(Box::new(1)); - dst.push_front(Box::new(2)); - dst.pop_back(); - - let mut src = VecDeque::new(); - src.push_front(Box::new(2)); - dst.append(&mut src); - for a in dst.iter() { - assert_eq!(**a, 2); - } - - // Regression test for Debug and Diaplay impl's - println!("{:?} {:?}", dst, dst.iter()); - println!("{:?}", VecDeque::::new().iter()); - - for a in dst { - assert_eq!(*a, 2); - } -} diff --git a/tests/run-pass/vecdeque.stdout b/tests/run-pass/vecdeque.stdout deleted file mode 100644 index 63de960ee2..0000000000 --- a/tests/run-pass/vecdeque.stdout +++ /dev/null @@ -1,2 +0,0 @@ -[2, 2] Iter([2, 2], []) -Iter([], []) diff --git a/tests/run-pass/vecs.rs b/tests/run-pass/vecs.rs deleted file mode 100644 index 739def8049..0000000000 --- a/tests/run-pass/vecs.rs +++ /dev/null @@ -1,92 +0,0 @@ -fn make_vec() -> Vec { - let mut v = Vec::with_capacity(4); - v.push(1); - v.push(2); - v -} - -fn make_vec_macro() -> Vec { - vec![1, 2] -} - -fn make_vec_macro_repeat() -> Vec { - vec![42; 5] -} - -fn make_vec_macro_repeat_zeroed() -> Vec { - vec![0; 7] -} - -fn vec_into_iter() -> u8 { - vec![1, 2, 3, 4] - .into_iter() - .map(|x| x * x) - .fold(0, |x, y| x + y) -} - -fn vec_into_iter_rev() -> u8 { - vec![1, 2, 3, 4] - .into_iter() - .map(|x| x * x) - .fold(0, |x, y| x + y) -} - -fn vec_into_iter_zst() -> usize { - vec![[0u64; 0], [0u64; 0]] - .into_iter() - .rev() - .map(|x| x.len()) - .sum() -} - -fn vec_into_iter_rev_zst() -> usize { - vec![[0u64; 0], [0u64; 0]] - .into_iter() - .rev() - .map(|x| x.len()) - .sum() -} - -fn vec_iter_and_mut() { - let mut v = vec![1,2,3,4]; - for i in v.iter_mut() { - *i += 1; - } - assert_eq!(v.iter().sum::(), 2+3+4+5); -} - -fn vec_iter_and_mut_rev() { - let mut v = vec![1,2,3,4]; - for i in v.iter_mut().rev() { - *i += 1; - } - assert_eq!(v.iter().sum::(), 2+3+4+5); -} - -fn vec_reallocate() -> Vec { - let mut v = vec![1, 2]; - v.push(3); - v.push(4); - v.push(5); - v -} - -fn main() { - assert_eq!(vec_reallocate().len(), 5); - - assert_eq!(vec_into_iter(), 30); - assert_eq!(vec_into_iter_rev(), 30); - vec_iter_and_mut(); - assert_eq!(vec_into_iter_zst(), 0); - assert_eq!(vec_into_iter_rev_zst(), 0); - vec_iter_and_mut_rev(); - - assert_eq!(make_vec().capacity(), 4); - assert_eq!(make_vec_macro(), [1, 2]); - assert_eq!(make_vec_macro_repeat(), [42; 5]); - assert_eq!(make_vec_macro_repeat_zeroed(), [0; 7]); - - // Test interesting empty slice comparison - // (one is a real pointer, one an integer pointer). - assert_eq!((200..-5).step_by(1).collect::>(), []); -} diff --git a/tests/run-pass/volatile.rs b/tests/run-pass/volatile.rs deleted file mode 100644 index c979980145..0000000000 --- a/tests/run-pass/volatile.rs +++ /dev/null @@ -1,12 +0,0 @@ -// related: #58645 -#![feature(core_intrinsics)] -use std::intrinsics::{volatile_load, volatile_store}; - -pub fn main() { - unsafe { - let i: &mut (isize, isize) = &mut (0, 0); - volatile_store(i, (1, 2)); - assert_eq!(volatile_load(i), (1, 2)); - assert_eq!(i, &mut (1, 2)); - } -} diff --git a/tests/run-pass/write-bytes.rs b/tests/run-pass/write-bytes.rs deleted file mode 100644 index 7c9a38fca6..0000000000 --- a/tests/run-pass/write-bytes.rs +++ /dev/null @@ -1,45 +0,0 @@ -#[repr(C)] -#[derive(Copy, Clone)] -struct Foo { - a: u64, - b: u64, - c: u64, -} - -fn main() { - const LENGTH: usize = 10; - let mut v: [u64; LENGTH] = [0; LENGTH]; - - for idx in 0..LENGTH { - assert_eq!(v[idx], 0); - } - - unsafe { - let p = v.as_mut_ptr(); - ::std::ptr::write_bytes(p, 0xab, LENGTH); - } - - for idx in 0..LENGTH { - assert_eq!(v[idx], 0xabababababababab); - } - - // ----- - - let mut w: [Foo; LENGTH] = [Foo { a: 0, b: 0, c: 0 }; LENGTH]; - for idx in 0..LENGTH { - assert_eq!(w[idx].a, 0); - assert_eq!(w[idx].b, 0); - assert_eq!(w[idx].c, 0); - } - - unsafe { - let p = w.as_mut_ptr(); - ::std::ptr::write_bytes(p, 0xcd, LENGTH); - } - - for idx in 0..LENGTH { - assert_eq!(w[idx].a, 0xcdcdcdcdcdcdcdcd); - assert_eq!(w[idx].b, 0xcdcdcdcdcdcdcdcd); - assert_eq!(w[idx].c, 0xcdcdcdcdcdcdcdcd); - } -} diff --git a/tests/run-pass/zero-sized-binary-heap-push.rs b/tests/run-pass/zero-sized-binary-heap-push.rs deleted file mode 100644 index c9312d79bf..0000000000 --- a/tests/run-pass/zero-sized-binary-heap-push.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::collections::BinaryHeap; -use std::iter::Iterator; - -fn main() { - const N: usize = 8; - - for len in 0..N { - let mut tester = BinaryHeap::with_capacity(len); - assert_eq!(tester.len(), 0); - assert!(tester.capacity() >= len); - for _ in 0..len { - tester.push(()); - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } -} diff --git a/tests/run-pass/zst.rs b/tests/run-pass/zst.rs deleted file mode 100644 index 9d97210b73..0000000000 --- a/tests/run-pass/zst.rs +++ /dev/null @@ -1,33 +0,0 @@ -#[derive(PartialEq, Debug)] -struct A; - -fn zst_ret() -> A { - A -} - -fn use_zst() -> A { - let a = A; - a -} - -fn main() { - // Not using the () type here, as writes of that type do not even have MIR generated. - // Also not assigning directly as that's array initialization, not assignment. - let zst_val = [1u8; 0]; - - assert_eq!(zst_ret(), A); - assert_eq!(use_zst(), A); - let x = 42 as *mut [u8; 0]; - // Reading and writing is ok. - unsafe { *x = zst_val; } - unsafe { let _y = *x; } - - // We should even be able to use "true" pointers for ZST when the allocation has been - // removed already. The box is for a non-ZST to make sure there actually is an allocation. - let mut x_box = Box::new(((), 1u8)); - let x = &mut x_box.0 as *mut _ as *mut [u8; 0]; - drop(x_box); - // Reading and writing is ok. - unsafe { *x = zst_val; } - unsafe { let _y = *x; } -} diff --git a/tests/run-pass/zst_box.rs b/tests/run-pass/zst_box.rs deleted file mode 100644 index 12138be5af..0000000000 --- a/tests/run-pass/zst_box.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - let x = Box::new(()); - let y = Box::new(()); - drop(y); - let z = Box::new(()); - drop(x); - drop(z); -} diff --git a/tests/run-pass/zst_variant_drop.rs b/tests/run-pass/zst_variant_drop.rs deleted file mode 100644 index a76f64ce29..0000000000 --- a/tests/run-pass/zst_variant_drop.rs +++ /dev/null @@ -1,23 +0,0 @@ -struct Foo; -impl Drop for Foo { - fn drop(&mut self) { - unsafe { - FOO = true; - } - } -} - -static mut FOO: bool = false; - -enum Bar { - A(Box), - B(Foo), -} - -fn main() { - assert!(unsafe { !FOO }); - drop(Bar::A(Box::new(42))); - assert!(unsafe { !FOO }); - drop(Bar::B(Foo)); - assert!(unsafe { FOO }); -}