-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from oli-obk/miri_run_no_more
don't use `#[miri_run]` anymore, but execute the `main` function
- Loading branch information
Showing
33 changed files
with
134 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
#![feature(custom_attribute)] | ||
#![allow(unused_attributes)] | ||
|
||
#[miri_run] | ||
#[inline(never)] | ||
pub fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
#![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 { | ||
let f = std::mem::transmute::<Box<i32>, fn()>(x); | ||
f() | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.