Now you can run miri against the libstd compiled by xargo:
```sh
-MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass-fullmir/vecs.rs
+MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass-fullmir/hashmap.rs
```
Notice that you will have to re-run the last step of the preparations above when
+++ /dev/null
-// This should fail even without validation
-// compile-flags: -Zmir-emit-validate=0
-
-fn main() {
- let v: Vec<u8> = Vec::with_capacity(10);
- let undef = unsafe { *v.get_unchecked(5) };
- let x = undef + 1; //~ ERROR: error
- //~^ NOTE attempted to read undefined bytes
- panic!("this should never print: {}", x);
-}
--- /dev/null
+// This should fail even without validation
+// compile-flags: -Zmir-emit-validate=0
+
+fn main() {
+ let v: Vec<u8> = Vec::with_capacity(10);
+ let undef = unsafe { *v.get_unchecked(5) };
+ let x = undef + 1; //~ ERROR: error
+ //~^ NOTE attempted to read undefined bytes
+ panic!("this should never print: {}", x);
+}
// FIXME: run tests for other targets, too
compile_fail(&sysroot, "tests/compile-fail", &host, &host, true);
- compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true);
+ //compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true);
}
+++ /dev/null
-//ignore-msvc
-#![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();
-}
+++ /dev/null
-// Copyright 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//ignore-msvc
-
-#![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]);
-}
+++ /dev/null
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//ignore-msvc
-
-#![allow(unused_features, unused_variables)]
-#![feature(box_syntax)]
-
-fn test(foo: Box<Vec<isize>> ) { assert_eq!((*foo)[0], 10); }
-
-pub fn main() {
- let x = box vec![10];
- // Test forgetting a local by move-in
- test(x);
-}
+++ /dev/null
-// Copyright 2012 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// FIXME: We handle uninitialzied storage here, which currently makes validation fail.
-// compile-flags: -Zmir-emit-validate=0
-
-//ignore-msvc
-
-#![feature(libc)]
-
-#![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 Bcx<'a> {
- unsafe {
- mem::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
- as libc::size_t))
- }
-}
-
-fn h<'a>(bcx : &'a Bcx<'a>) -> &'a 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);
-}
+++ /dev/null
-//ignore-msvc
-
-fn make_vec() -> Vec<u8> {
- let mut v = Vec::with_capacity(4);
- v.push(1);
- v.push(2);
- v
-}
-
-fn make_vec_macro() -> Vec<u8> {
- vec![1, 2]
-}
-
-fn make_vec_macro_repeat() -> Vec<u8> {
- vec![42; 5]
-}
-
-fn make_vec_macro_repeat_zeroed() -> Vec<u8> {
- 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_zst() -> usize {
- vec![[0u64; 0], [0u64; 0]]
- .into_iter()
- .map(|x| x.len())
- .sum()
-}
-
-fn vec_reallocate() -> Vec<u8> {
- 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_zst(), 0);
- 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]);
-}
--- /dev/null
+//ignore-msvc
+#![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();
+}
--- /dev/null
+// Copyright 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//ignore-msvc
+
+#![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]);
+}
--- /dev/null
+// Copyright 2012 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//ignore-msvc
+
+#![allow(unused_features, unused_variables)]
+#![feature(box_syntax)]
+
+fn test(foo: Box<Vec<isize>> ) { assert_eq!((*foo)[0], 10); }
+
+pub fn main() {
+ let x = box vec![10];
+ // Test forgetting a local by move-in
+ test(x);
+}
--- /dev/null
+// Copyright 2012 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// FIXME: We handle uninitialzied storage here, which currently makes validation fail.
+// compile-flags: -Zmir-emit-validate=0
+
+//ignore-msvc
+
+#![feature(libc)]
+
+#![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 Bcx<'a> {
+ unsafe {
+ mem::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
+ as libc::size_t))
+ }
+}
+
+fn h<'a>(bcx : &'a Bcx<'a>) -> &'a 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);
+}
--- /dev/null
+//ignore-msvc
+
+fn make_vec() -> Vec<u8> {
+ let mut v = Vec::with_capacity(4);
+ v.push(1);
+ v.push(2);
+ v
+}
+
+fn make_vec_macro() -> Vec<u8> {
+ vec![1, 2]
+}
+
+fn make_vec_macro_repeat() -> Vec<u8> {
+ vec![42; 5]
+}
+
+fn make_vec_macro_repeat_zeroed() -> Vec<u8> {
+ 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_zst() -> usize {
+ vec![[0u64; 0], [0u64; 0]]
+ .into_iter()
+ .map(|x| x.len())
+ .sum()
+}
+
+fn vec_reallocate() -> Vec<u8> {
+ 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_zst(), 0);
+ 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]);
+}