-
Notifications
You must be signed in to change notification settings - Fork 385
don't use #[miri_run]
anymore, but execute the main
function
#23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
55fd060
don't use `#[miri_run]` anymore, but execute the `main` function
oli-obk 1bd00e8
run `start` and `main` language item if provided
oli-obk 8abd293
sysroot_flag is now used for more flags
oli-obk a55ac1f
pass arguments to `start`
oli-obk d82a792
use the logging framework instead of println!
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, so this returns either the
#[main]
or#[start]
function? That's a bit weird - we need to call them differently. Currently we're calling a#[start]
without its two arguments, which I believe means they are left as undefined bytes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed