]> git.lizzy.rs Git - rust.git/commitdiff
don't use `#[miri_run]` anymore, but execute the `main` function
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 13 Jun 2016 12:27:05 +0000 (14:27 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 13 Jun 2016 13:33:05 +0000 (15:33 +0200)
30 files changed:
benches/fibonacci_helper.rs
benches/fibonacci_helper_iterative.rs
benches/smoke_helper.rs
src/bin/miri.rs
tests/compile-fail/dangling_pointer_deref.rs [new file with mode: 0644]
tests/compile-fail/deref_fn_ptr.rs
tests/compile-fail/errors.rs [deleted file]
tests/compile-fail/execute_memory.rs
tests/compile-fail/invalid_bool.rs [new file with mode: 0644]
tests/compile-fail/null_pointer_deref.rs [new file with mode: 0644]
tests/compile-fail/out_of_bounds_read.rs [new file with mode: 0644]
tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs [new file with mode: 0644]
tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs [new file with mode: 0644]
tests/compile-fail/undefined_byte_read.rs [new file with mode: 0644]
tests/compile-fail/unimplemented.rs
tests/compile-fail/wild_pointer_deref.rs [new file with mode: 0644]
tests/compiletest.rs
tests/run-pass/arrays.rs
tests/run-pass/bools.rs
tests/run-pass/bug.rs
tests/run-pass/c_enums.rs
tests/run-pass/calls.rs
tests/run-pass/function_pointers.rs
tests/run-pass/heap.rs
tests/run-pass/intrinsics.rs
tests/run-pass/loops.rs
tests/run-pass/pointers.rs
tests/run-pass/std.rs
tests/run-pass/sums.rs
tests/run-pass/vecs.rs

index cddfff9c2c92dc3ef8c9662633c3591a6a03fa61..004000e70ea73d84a8c2c84a24bc6cf59fbf1bd9 100644 (file)
@@ -1,7 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(unused_attributes)]
-
-#[miri_run]
 #[inline(never)]
 pub fn main() {
     assert_eq!(fib(10), 55);
index 486d8c2e8a8689f7645f49ff20ffe23333407329..59283be4820f718e0007d71b216a6ea1a3a1f4e5 100644 (file)
@@ -1,7 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(unused_attributes)]
-
-#[miri_run]
 #[inline(never)]
 pub fn main() {
     assert_eq!(fib(10), 55);
index e8691f244c02f02440f3795c2ef232d47e7bdb55..ef05b044cddded92cdb5182e2265fe513d1c175e 100644 (file)
@@ -1,7 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(unused_attributes)]
-
-#[miri_run]
 #[inline(never)]
 pub fn main() {
 }
index f14eb39439ef669e136ffd837db8946a9552c9b7..f1e9714ff39d13017c3283ee86f3bd12fb3850c7 100644 (file)
 use rustc_driver::{driver, CompilerCalls};
 use rustc::ty::{TyCtxt, subst};
 use rustc::mir::mir_map::MirMap;
+use rustc::mir::repr::Mir;
 use rustc::hir::def_id::DefId;
+use rustc::hir::{map, ItemFn, Item};
+use syntax::codemap::Span;
 
 struct MiriCompilerCalls;
 
@@ -34,58 +37,46 @@ fn build_controller(
 
         control.after_analysis.callback = Box::new(|state| {
             state.session.abort_if_errors();
-            interpret_start_points(state.tcx.unwrap(), state.mir_map.unwrap());
+
+            let tcx = state.tcx.unwrap();
+            let mir_map = state.mir_map.unwrap();
+            let (span, mir, def_id) = get_main(tcx, mir_map);
+            println!("found `main` function at: {:?}", span);
+
+            let mut ecx = EvalContext::new(tcx, mir_map);
+            let substs = tcx.mk_substs(subst::Substs::empty());
+            let return_ptr = ecx.alloc_ret_ptr(mir.return_ty, substs).expect("main function should not be diverging");
+
+            ecx.push_stack_frame(def_id, mir.span, CachedMir::Ref(mir), substs, Some(return_ptr));
+
+            loop {
+                match step(&mut ecx) {
+                    Ok(true) => {}
+                    Ok(false) => break,
+                    // FIXME: diverging functions can end up here in some future miri
+                    Err(e) => {
+                        report(tcx, &ecx, e);
+                        break;
+                    }
+                }
+            }
         });
 
         control
     }
 }
 
-
-
-fn interpret_start_points<'a, 'tcx>(
-    tcx: TyCtxt<'a, 'tcx, 'tcx>,
-    mir_map: &MirMap<'tcx>,
-) {
-    let initial_indentation = ::log_settings::settings().indentation;
+fn get_main<'a, 'b, 'tcx: 'b>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir_map: &'b MirMap<'tcx>) -> (Span, &'b Mir<'tcx>, DefId) {
     for (&id, mir) in &mir_map.map {
-        for attr in tcx.map.attrs(id) {
-            use syntax::attr::AttrMetaMethods;
-            if attr.check_name("miri_run") {
-                let item = tcx.map.expect_item(id);
-
-                ::log_settings::settings().indentation = initial_indentation;
-
-                debug!("Interpreting: {}", item.name);
-
-                let mut ecx = EvalContext::new(tcx, mir_map);
-                let substs = tcx.mk_substs(subst::Substs::empty());
-                let return_ptr = ecx.alloc_ret_ptr(mir.return_ty, substs);
-
-                ecx.push_stack_frame(tcx.map.local_def_id(id), mir.span, CachedMir::Ref(mir), substs, return_ptr);
-
-                loop {
-                    match step(&mut ecx) {
-                        Ok(true) => {}
-                        Ok(false) => {
-                            match return_ptr {
-                                Some(ptr) => if log_enabled!(::log::LogLevel::Debug) {
-                                    ecx.memory().dump(ptr.alloc_id);
-                                },
-                                None => warn!("diverging function returned"),
-                            }
-                            break;
-                        }
-                        // FIXME: diverging functions can end up here in some future miri
-                        Err(e) => {
-                            report(tcx, &ecx, e);
-                            break;
-                        }
-                    }
+        if let map::Node::NodeItem(&Item { name, span, ref node, .. }) = tcx.map.get(id) {
+            if let ItemFn(..) = *node {
+                if name.as_str() == "main" {
+                    return (span, mir, tcx.map.local_def_id(id));
                 }
             }
         }
     }
+    panic!("no main function found");
 }
 
 fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
diff --git a/tests/compile-fail/dangling_pointer_deref.rs b/tests/compile-fail/dangling_pointer_deref.rs
new file mode 100644 (file)
index 0000000..0ede7c9
--- /dev/null
@@ -0,0 +1,8 @@
+fn main() {
+    let p = {
+        let b = Box::new(42);
+        &*b as *const i32
+    };
+    let x = unsafe { *p }; //~ ERROR: dangling pointer was dereferenced
+    panic!("this should never print: {}", x);
+}
index 52c7c2b8f9d5541e67e96dd8eee64e24e526d359..c1eaf7eaa61d284c1ddb463375b389b752e5f513 100644 (file)
@@ -1,13 +1,8 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
 fn f() {}
 
-#[miri_run]
-fn deref_fn_ptr() -> i32 {
-    unsafe {
+fn main() {
+    let x: i32 = unsafe {
         *std::mem::transmute::<fn(), *const i32>(f) //~ ERROR: tried to dereference a function pointer
-    }
+    };
+    panic!("this should never print: {}", x);
 }
-
-fn main() {}
diff --git a/tests/compile-fail/errors.rs b/tests/compile-fail/errors.rs
deleted file mode 100644 (file)
index 0cadd76..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-#[miri_run]
-fn overwriting_part_of_relocation_makes_the_rest_undefined() -> i32 {
-    let mut p = &42;
-    unsafe {
-        let ptr: *mut _ = &mut p;
-        *(ptr as *mut u8) = 123; // if we ever support 8 bit pointers, this is gonna cause
-        // "attempted to interpret some raw bytes as a pointer address" instead of
-        // "attempted to read undefined bytes"
-    }
-    *p //~ ERROR: attempted to read undefined bytes
-}
-
-#[miri_run]
-fn pointers_to_different_allocations_are_unorderable() -> bool {
-    let x: *const u8 = &1;
-    let y: *const u8 = &2;
-    x < y //~ ERROR: attempted to do math or a comparison on pointers into different allocations
-}
-
-#[miri_run]
-fn invalid_bool() -> u8 {
-    let b = unsafe { std::mem::transmute::<u8, bool>(2) };
-    if b { 1 } else { 2 } //~ ERROR: invalid boolean value read
-}
-
-#[miri_run]
-fn undefined_byte_read() -> u8 {
-    let v: Vec<u8> = Vec::with_capacity(10);
-    let undef = unsafe { *v.get_unchecked(5) };
-    undef + 1 //~ ERROR: attempted to read undefined bytes
-}
-
-#[miri_run]
-fn out_of_bounds_read() -> u8 {
-    let v: Vec<u8> = vec![1, 2];
-    unsafe { *v.get_unchecked(5) } //~ ERROR: memory access of 5..6 outside bounds of allocation 11 which has size 2
-}
-
-#[miri_run]
-fn dangling_pointer_deref() -> i32 {
-    let p = {
-        let b = Box::new(42);
-        &*b as *const i32
-    };
-    unsafe { *p } //~ ERROR: dangling pointer was dereferenced
-}
-
-#[miri_run]
-fn wild_pointer_deref() -> i32 {
-    let p = 42 as *const i32;
-    unsafe { *p } //~ ERROR: attempted to interpret some raw bytes as a pointer address
-}
-
-#[miri_run]
-fn null_pointer_deref() -> i32 {
-    unsafe { *std::ptr::null() } //~ ERROR: attempted to interpret some raw bytes as a pointer address
-}
-
-fn main() {}
index 4e06fd8db8ded6ecd8d4049a690715c148473182..413c6602114ba37ef6f39fd2cde84c211d838519 100644 (file)
@@ -1,8 +1,6 @@
-#![feature(custom_attribute, box_syntax)]
-#![allow(dead_code, unused_attributes)]
+#![feature(box_syntax)]
 
-#[miri_run]
-fn deref_fn_ptr() {
+fn main() {
     //FIXME: this span is wrong
     let x = box 42; //~ ERROR: tried to treat a memory pointer as a function pointer
     unsafe {
@@ -10,5 +8,3 @@ fn deref_fn_ptr() {
         f()
     }
 }
-
-fn main() {}
diff --git a/tests/compile-fail/invalid_bool.rs b/tests/compile-fail/invalid_bool.rs
new file mode 100644 (file)
index 0000000..9de2630
--- /dev/null
@@ -0,0 +1,4 @@
+fn main() {
+    let b = unsafe { std::mem::transmute::<u8, bool>(2) };
+    if b { unreachable!() } else { unreachable!() } //~ ERROR: invalid boolean value read
+}
diff --git a/tests/compile-fail/null_pointer_deref.rs b/tests/compile-fail/null_pointer_deref.rs
new file mode 100644 (file)
index 0000000..3d1afe9
--- /dev/null
@@ -0,0 +1,4 @@
+fn main() {
+    let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: attempted to interpret some raw bytes as a pointer address
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/out_of_bounds_read.rs b/tests/compile-fail/out_of_bounds_read.rs
new file mode 100644 (file)
index 0000000..3e9e87c
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    let v: Vec<u8> = vec![1, 2];
+    let x = unsafe { *v.get_unchecked(5) }; //~ ERROR: memory access of 5..6 outside bounds of allocation 29 which has size 2
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs
new file mode 100644 (file)
index 0000000..50f51d0
--- /dev/null
@@ -0,0 +1,11 @@
+fn main() {
+    let mut p = &42;
+    unsafe {
+        let ptr: *mut _ = &mut p;
+        *(ptr as *mut u8) = 123; // if we ever support 8 bit pointers, this is gonna cause
+        // "attempted to interpret some raw bytes as a pointer address" instead of
+        // "attempted to read undefined bytes"
+    }
+    let x = *p; //~ ERROR: attempted to read undefined bytes
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs b/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs
new file mode 100644 (file)
index 0000000..be478c8
--- /dev/null
@@ -0,0 +1,7 @@
+fn main() {
+    let x: *const u8 = &1;
+    let y: *const u8 = &2;
+    if x < y { //~ ERROR: attempted to do math or a comparison on pointers into different allocations
+        unreachable!()
+    }
+}
diff --git a/tests/compile-fail/undefined_byte_read.rs b/tests/compile-fail/undefined_byte_read.rs
new file mode 100644 (file)
index 0000000..f8b6f7f
--- /dev/null
@@ -0,0 +1,6 @@
+fn main() {
+    let v: Vec<u8> = Vec::with_capacity(10);
+    let undef = unsafe { *v.get_unchecked(5) };
+    let x = undef + 1; //~ ERROR: attempted to read undefined bytes
+    panic!("this should never print: {}", x);
+}
index 7752650ade8873f3dcf1c103ff5dfe5e18985c94..9611631a47a3bc0f4fff5103e347f07ea0568b5f 100644 (file)
@@ -1,12 +1,5 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
 //error-pattern:begin_panic_fmt
 
-
-#[miri_run]
-fn failed_assertions() {
+fn main() {
     assert_eq!(5, 6);
 }
-
-fn main() {}
diff --git a/tests/compile-fail/wild_pointer_deref.rs b/tests/compile-fail/wild_pointer_deref.rs
new file mode 100644 (file)
index 0000000..1f47248
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    let p = 42 as *const i32;
+    let x = unsafe { *p }; //~ ERROR: attempted to interpret some raw bytes as a pointer address
+    panic!("this should never print: {}", x);
+}
index 76b5b5f6e9638efe8628730e5b1574d3704002a7..0619c5a76561754d10e141bba37d3c6f029a486f 100644 (file)
@@ -15,7 +15,7 @@ fn run_mode(mode: &'static str) {
             .expect("need to specify RUST_SYSROOT env var or use rustup or multirust")
             .to_owned(),
     };
-    let sysroot_flag = format!("--sysroot {}", sysroot);
+    let sysroot_flag = format!("--sysroot {} -Dwarnings", sysroot);
 
     // FIXME: read directories in sysroot/lib/rustlib and generate the test targets from that
     let targets = &["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"];
index db4f999a8b043f327712bdab597a398cc13d0eb6..469dde3091eb25993c7b4d69bc5f4fb12f437444 100644 (file)
@@ -1,50 +1,38 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-#[miri_run]
 fn empty_array() -> [u16; 0] {
     []
 }
 
-#[miri_run]
 fn mini_array() -> [u16; 1] {
     [42]
 }
 
-#[miri_run]
 fn big_array() -> [u16; 5] {
     [5, 4, 3, 2, 1]
 }
 
-#[miri_run]
 fn array_array() -> [[u8; 2]; 3] {
     [[5, 4], [3, 2], [1, 0]]
 }
 
-#[miri_run]
 fn index_unsafe() -> i32 {
     let a = [0, 10, 20, 30];
     unsafe { *a.get_unchecked(2) }
 }
 
-#[miri_run]
 fn index() -> i32 {
     let a = [0, 10, 20, 30];
     a[2]
 }
 
-#[miri_run]
 fn array_repeat() -> [u8; 8] {
     [42; 8]
 }
 
-#[miri_run]
 fn slice_index() -> u8 {
     let arr: &[_] = &[101, 102, 103, 104, 105, 106];
     arr[5]
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(empty_array(), []);
     assert_eq!(index_unsafe(), 20);
@@ -53,4 +41,5 @@ fn main() {
     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]);
 }
index 953670fef9b275258f558d5911d448dafcde860a..103d7eac27cde9971a0b8dd22ca5beee487db430 100644 (file)
@@ -1,24 +1,17 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-#[miri_run]
 fn boolean() -> bool {
     true
 }
 
-#[miri_run]
 fn if_false() -> i64 {
     let c = false;
     if c { 1 } else { 0 }
 }
 
-#[miri_run]
 fn if_true() -> i64 {
     let c = true;
     if c { 1 } else { 0 }
 }
 
-#[miri_run]
 fn match_bool() -> i16 {
     let b = true;
     match b {
@@ -27,7 +20,6 @@ fn match_bool() -> i16 {
     }
 }
 
-#[miri_run]
 fn main() {
     assert!(boolean());
     assert_eq!(if_false(), 0);
index 3006da2c163de0ade3939e0827fbcaf464bc67bd..a68f727322e29910d4b72f01939dbcb02058189c 100644 (file)
@@ -1,14 +1,8 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
 static mut X: usize = 5;
 
-#[miri_run]
-fn static_mut() {
+fn main() {
     unsafe {
         X = 6;
         assert_eq!(X, 6);
     }
 }
-
-fn main() {}
index 60790fef439fc47e762467e624bf01a06455d806..11897b73eb2ada620f0066518bdb78c471875c16 100644 (file)
@@ -1,6 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
 enum Foo {
     Bar = 42,
     Baz,
@@ -13,17 +10,14 @@ enum Signed {
     Quux = 100,
 }
 
-#[miri_run]
 fn foo() -> [u8; 3] {
     [Foo::Bar as u8, Foo::Baz as u8, Foo::Quux as u8]
 }
 
-#[miri_run]
 fn signed() -> [i8; 3] {
     [Signed::Bar as i8, Signed::Baz as i8, Signed::Quux as i8]
 }
 
-#[miri_run]
 fn unsafe_match() -> bool {
     match unsafe { std::mem::transmute::<u8, Foo>(43) } {
         Foo::Baz => true,
@@ -31,7 +25,6 @@ fn unsafe_match() -> bool {
     }
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(foo(), [42, 43, 100]);
     assert_eq!(signed(), [-42, -41, 100]);
index ba68fb44a6c39469a0dca81685a894b163b6b02f..c4ba4a9b701ff08ede7e8052aa4733bed92b3b08 100644 (file)
@@ -1,7 +1,5 @@
-#![feature(custom_attribute, const_fn)]
-#![allow(dead_code, unused_attributes)]
+#![feature(const_fn)]
 
-#[miri_run]
 fn call() -> i32 {
     fn increment(x: i32) -> i32 {
         x + 1
@@ -9,7 +7,6 @@ fn increment(x: i32) -> i32 {
     increment(1)
 }
 
-#[miri_run]
 fn factorial_recursive() -> i64 {
     fn fact(n: i64) -> i64 {
         if n == 0 {
@@ -21,31 +18,28 @@ fn fact(n: i64) -> i64 {
     fact(10)
 }
 
-#[miri_run]
 fn call_generic() -> (i16, bool) {
     fn id<T>(t: T) -> T { t }
     (id(42), id(true))
 }
 
 // Test calling a very simple function from the standard library.
-#[miri_run]
 fn cross_crate_fn_call() -> i64 {
     if 1i32.is_positive() { 1 } else { 0 }
 }
 
 const fn foo(i: i64) -> i64 { *&i + 1 }
 
-#[miri_run]
 fn const_fn_call() -> i64 {
     let x = 5 + foo(5);
     assert_eq!(x, 11);
     x
 }
 
-#[miri_run]
 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);
 }
index 55a6f9fbeac46266a9f24cfefb36fce7d428c324..8361a58ea4302082bb19cdae7c5cb6a240582e01 100644 (file)
@@ -1,6 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
 fn f() -> i32 {
     42
 }
@@ -9,9 +6,10 @@ fn return_fn_ptr() -> fn() -> i32 {
     f
 }
 
-#[miri_run]
 fn call_fn_ptr() -> i32 {
     return_fn_ptr()()
 }
 
-fn main() {}
+fn main() {
+    assert_eq!(call_fn_ptr(), 42);
+}
index a7175969efac52e8a6f26c75ff8d8a9813bf1ec9..b533f916469881a96c23657ea33f4d65f6e2d218 100644 (file)
@@ -1,17 +1,13 @@
-#![feature(custom_attribute, box_syntax)]
-#![allow(dead_code, unused_attributes)]
+#![feature(box_syntax)]
 
-#[miri_run]
 fn make_box() -> Box<(i16, i16)> {
     Box::new((1, 2))
 }
 
-#[miri_run]
 fn make_box_syntax() -> Box<(i16, i16)> {
     box (1, 2)
 }
 
-#[miri_run]
 fn allocate_reallocate() {
     let mut s = String::new();
 
@@ -31,8 +27,8 @@ fn allocate_reallocate() {
     assert_eq!(s.capacity(), 9);
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(*make_box(), (1, 2));
     assert_eq!(*make_box_syntax(), (1, 2));
+    allocate_reallocate();
 }
index ef7fa0d986135e016c2c0ab5f3ca070fa9cb7cc5..3152737a601ca01648e553d93d6a2c8fecc7feae 100755 (executable)
@@ -1,9 +1,5 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
 use std::mem::{size_of, size_of_val};
 
-#[miri_run]
 fn main() {
     assert_eq!(size_of::<Option<i32>>(), 8);
     assert_eq!(size_of_val(&()), 0);
index 57a2f7c4357bee61697258ecc9b2a77dc0a060c8..222287cbe09adcf4ad2936ca28ff72baebdbf82f 100644 (file)
@@ -1,7 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-#[miri_run]
 fn factorial_loop() -> i64 {
     let mut product = 1;
     let mut i = 1;
@@ -14,7 +10,6 @@ fn factorial_loop() -> i64 {
     product
 }
 
-#[miri_run]
 fn index_for_loop() -> usize {
     let mut sum = 0;
     let a = [0, 10, 20, 30];
@@ -24,7 +19,6 @@ fn index_for_loop() -> usize {
     sum
 }
 
-#[miri_run]
 fn for_loop() -> usize {
     let mut sum = 0;
     let a = [0, 10, 20, 30];
@@ -34,7 +28,6 @@ fn for_loop() -> usize {
     sum
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(factorial_loop(), 3628800);
     assert_eq!(index_for_loop(), 60);
index 9f28b982b4eeef6160d2df4c8ab53a98a2d69874..2ef7eb0102f1950cf4438cc2c1ab2a1f28be6f43 100644 (file)
@@ -1,25 +1,18 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-#[miri_run]
 fn one_line_ref() -> i16 {
     *&1
 }
 
-#[miri_run]
 fn basic_ref() -> i16 {
     let x = &1;
     *x
 }
 
-#[miri_run]
 fn basic_ref_mut() -> i16 {
     let x = &mut 1;
     *x += 2;
     *x
 }
 
-#[miri_run]
 fn basic_ref_mut_var() -> i16 {
     let mut a = 1;
     {
@@ -29,7 +22,6 @@ fn basic_ref_mut_var() -> i16 {
     a
 }
 
-#[miri_run]
 fn tuple_ref_mut() -> (i8, i8) {
     let mut t = (10, 20);
     {
@@ -39,7 +31,6 @@ fn tuple_ref_mut() -> (i8, i8) {
     t
 }
 
-#[miri_run]
 fn match_ref_mut() -> i8 {
     let mut t = (20, 22);
     {
@@ -52,13 +43,11 @@ fn match_ref_mut() -> i8 {
     t.0
 }
 
-#[miri_run]
 fn dangling_pointer() -> *const i32 {
     let b = Box::new(42);
     &*b as *const i32
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(one_line_ref(), 1);
     assert_eq!(basic_ref(), 1);
index 1ec3c5e0bb98ae26729c7ae87c030d500f9e6c4a..2e65550b07bf893f24c21d3a1676f93b4f9b9fdc 100644 (file)
@@ -1,11 +1,7 @@
-#![feature(custom_attribute, box_syntax)]
-#![allow(dead_code, unused_attributes)]
-
-use std::cell::{Cell, RefCell};
+use std::cell::Cell;
 use std::rc::Rc;
 use std::sync::Arc;
 
-#[miri_run]
 fn rc_cell() -> Rc<Cell<i32>> {
     let r = Rc::new(Cell::new(42));
     let x = r.get();
@@ -15,7 +11,6 @@ fn rc_cell() -> Rc<Cell<i32>> {
 
 // TODO(solson): also requires destructors to run for the second borrow to work
 // TODO(solson): needs StructWrappedNullablePointer support
-// #[miri_run]
 // fn rc_refcell() -> i32 {
 //     let r = Rc::new(RefCell::new(42));
 //     *r.borrow_mut() += 10;
@@ -23,19 +18,17 @@ fn rc_cell() -> Rc<Cell<i32>> {
 //     x
 // }
 
-#[miri_run]
 fn arc() -> Arc<i32> {
     let a = Arc::new(42);
     a
 }
 
-#[miri_run]
 fn true_assert() {
     assert_eq!(1, 1);
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(*arc(), 42);
     assert_eq!(rc_cell().get(), 84);
+    true_assert();
 }
index 120c196abe9759ec63e5b78d2de8d9cdf4be136b..adf4e8f987d32e0291c2752effd3682e4569ce51 100644 (file)
@@ -4,7 +4,6 @@
 #[derive(Debug, PartialEq)]
 enum Unit { Unit(()) } // Force non-C-enum representation.
 
-#[miri_run]
 fn return_unit() -> Unit {
     Unit::Unit(())
 }
@@ -12,27 +11,22 @@ fn return_unit() -> Unit {
 #[derive(Debug, PartialEq)]
 enum MyBool { False(()), True(()) } // Force non-C-enum representation.
 
-#[miri_run]
 fn return_true() -> MyBool {
     MyBool::True(())
 }
 
-#[miri_run]
 fn return_false() -> MyBool {
     MyBool::False(())
 }
 
-#[miri_run]
 fn return_none() -> Option<i64> {
     None
 }
 
-#[miri_run]
 fn return_some() -> Option<i64> {
     Some(42)
 }
 
-#[miri_run]
 fn match_opt_none() -> i8 {
     let x = None;
     match x {
@@ -41,7 +35,6 @@ fn match_opt_none() -> i8 {
     }
 }
 
-#[miri_run]
 fn match_opt_some() -> i8 {
     let x = Some(13);
     match x {
@@ -50,13 +43,12 @@ fn match_opt_some() -> i8 {
     }
 }
 
-#[miri_run]
 fn two_nones() -> (Option<i16>, Option<i16>) {
     (None, None)
 }
 
 // FIXME(solson): Casts inside PartialEq fails on 32-bit.
-#[cfg_attr(target_pointer_width = "64", miri_run)]
+#[cfg(target_pointer_width = "64")]
 fn main() {
     assert_eq!(two_nones(), (None, None));
     assert_eq!(match_opt_some(), 13);
@@ -67,3 +59,6 @@ fn main() {
     assert_eq!(return_true(), MyBool::True(()));
     assert_eq!(return_unit(), Unit::Unit(()));
 }
+
+#[cfg(not(target_pointer_width = "64"))]
+fn main() {}
index 2a4cc6128843bc1fc3546f597562e61d0914dd83..b3a88014e6f9a08f72383b650f3b6970e33d74e9 100644 (file)
@@ -1,7 +1,3 @@
-#![feature(custom_attribute)]
-#![allow(dead_code, unused_attributes)]
-
-#[miri_run]
 fn make_vec() -> Vec<u8> {
     let mut v = Vec::with_capacity(4);
     v.push(1);
@@ -9,17 +5,14 @@ fn make_vec() -> Vec<u8> {
     v
 }
 
-#[miri_run]
 fn make_vec_macro() -> Vec<u8> {
     vec![1, 2]
 }
 
-#[miri_run]
 fn make_vec_macro_repeat() -> Vec<u8> {
     vec![42; 5]
 }
 
-#[miri_run]
 fn vec_into_iter() -> u8 {
     vec![1, 2, 3, 4]
         .into_iter()
@@ -27,7 +20,6 @@ fn vec_into_iter() -> u8 {
         .fold(0, |x, y| x + y)
 }
 
-#[miri_run]
 fn vec_reallocate() -> Vec<u8> {
     let mut v = vec![1, 2];
     v.push(3);
@@ -36,9 +28,10 @@ fn vec_reallocate() -> Vec<u8> {
     v
 }
 
-#[miri_run]
 fn main() {
     assert_eq!(vec_reallocate().len(), 5);
     assert_eq!(vec_into_iter(), 30);
     assert_eq!(make_vec().capacity(), 4);
+    assert_eq!(make_vec_macro(), [1, 2]);
+    assert_eq!(make_vec_macro_repeat(), [42; 5]);
 }