rustup
This commit is contained in:
parent
bcb87a70f8
commit
6f5a91f70a
@ -1 +1 @@
|
||||
0e190206e2ff0c13d64701d9b4145bf89a2d0cab
|
||||
9b3242982202707be2485b1e4cf5f3b34466a38d
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
#![feature(raw_ref_macros)]
|
||||
use std::ptr;
|
||||
|
||||
fn main() {
|
||||
@ -8,6 +7,6 @@ fn main() {
|
||||
let b = Box::new(42);
|
||||
&*b as *const i32
|
||||
};
|
||||
let x = unsafe { ptr::raw_const!(*p) }; //~ ERROR dereferenced after this allocation got freed
|
||||
let x = unsafe { ptr::addr_of!(*p) }; //~ ERROR dereferenced after this allocation got freed
|
||||
panic!("this should never print: {:?}", x);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(raw_ref_op)]
|
||||
//! Even referencing an unknown `extern static` already triggers an error.
|
||||
|
||||
extern "C" {
|
||||
@ -6,5 +5,5 @@ extern "C" {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _val = unsafe { &raw const FOO }; //~ ERROR is not supported by Miri
|
||||
let _val = unsafe { std::ptr::addr_of!(FOO) }; //~ ERROR is not supported by Miri
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// This should fail even without validation or Stacked Borrows.
|
||||
// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
|
||||
#![feature(raw_ref_macros)]
|
||||
use std::ptr;
|
||||
|
||||
fn main() {
|
||||
@ -9,6 +8,6 @@ fn main() {
|
||||
let x = &x[0] as *const _ as *const u32;
|
||||
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
|
||||
// The deref is UB even if we just put the result into a raw pointer.
|
||||
let _x = unsafe { ptr::raw_const!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required
|
||||
let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ fn main() {
|
||||
assert_eq!(state.rest(path), "some/more");
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
struct State {
|
||||
prev: Option<usize>,
|
||||
next: Option<usize>,
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Make sure validation can handle many overlapping shared borrows for different parts of a data structure
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[allow(unused)]
|
||||
struct Test {
|
||||
a: u32,
|
||||
b: u32,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(unsize, coerce_unsized, raw_ref_op, raw_ref_macros)]
|
||||
#![feature(unsize, coerce_unsized)]
|
||||
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::Hash;
|
||||
@ -45,10 +45,8 @@ fn test_basic() {
|
||||
assert_eq!({x.a}, 42);
|
||||
assert_eq!({x.b}, 99);
|
||||
// but we *can* take a raw pointer!
|
||||
assert_eq!(unsafe { (&raw const x.a).read_unaligned() }, 42);
|
||||
assert_eq!(unsafe { ptr::raw_const!(x.a).read_unaligned() }, 42);
|
||||
assert_eq!(unsafe { (&raw const x.b).read_unaligned() }, 99);
|
||||
assert_eq!(unsafe { ptr::raw_const!(x.b).read_unaligned() }, 99);
|
||||
assert_eq!(unsafe { ptr::addr_of!(x.a).read_unaligned() }, 42);
|
||||
assert_eq!(unsafe { ptr::addr_of!(x.b).read_unaligned() }, 99);
|
||||
|
||||
x.b = 77;
|
||||
assert_eq!({x.b}, 77);
|
||||
|
@ -1,5 +1,4 @@
|
||||
// compile-flags: -Zmiri-track-raw-pointers
|
||||
#![feature(raw_ref_macros)]
|
||||
use std::ptr;
|
||||
|
||||
// Test various stacked-borrows-related things.
|
||||
@ -169,8 +168,8 @@ fn raw_ref_to_part() {
|
||||
}
|
||||
|
||||
let it = Box::new(Whole { part: Part { _lame: 0 }, extra: 42 });
|
||||
let whole = ptr::raw_mut!(*Box::leak(it));
|
||||
let part = unsafe { ptr::raw_mut!((*whole).part) };
|
||||
let whole = ptr::addr_of_mut!(*Box::leak(it));
|
||||
let part = unsafe { ptr::addr_of_mut!((*whole).part) };
|
||||
let typed = unsafe { &mut *(part as *mut Whole) };
|
||||
assert!(typed.extra == 42);
|
||||
drop(unsafe { Box::from_raw(whole) });
|
||||
|
Loading…
x
Reference in New Issue
Block a user