Skip to content

Commit e63eb4c

Browse files
author
The Miri Conjob Bot
committed
Merge from rustc
2 parents fb11682 + 985feeb commit e63eb4c

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

src/bin/miri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
6868
queries: &'tcx rustc_interface::Queries<'tcx>,
6969
) -> Compilation {
7070
queries.global_ctxt().unwrap().enter(|tcx| {
71-
if tcx.sess.compile_status().is_err() {
71+
if tcx.sess.dcx().has_errors().is_some() {
7272
tcx.dcx().fatal("miri cannot be run on programs that fail compilation");
7373
}
7474

tests/fail/dangling_pointers/deref_dangling_box.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::ptr::{self, addr_of_mut};
88
// (This test relies on the `deref_copy` pass that lowers `**ptr` to materialize the intermediate pointer.)
99

1010
fn main() {
11-
let mut inner = ptr::invalid::<i32>(24);
11+
let mut inner = ptr::without_provenance::<i32>(24);
1212
let outer = addr_of_mut!(inner).cast::<Box<i32>>();
1313
// Now `outer` is a pointer to a dangling reference.
1414
// Deref'ing that should be UB.

tests/fail/dangling_pointers/deref_dangling_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::ptr::{self, addr_of_mut};
88
// (This test relies on the `deref_copy` pass that lowers `**ptr` to materialize the intermediate pointer.)
99

1010
fn main() {
11-
let mut inner = ptr::invalid::<i32>(24);
11+
let mut inner = ptr::without_provenance::<i32>(24);
1212
let outer = addr_of_mut!(inner).cast::<&'static mut i32>();
1313
// Now `outer` is a pointer to a dangling reference.
1414
// Deref'ing that should be UB.

tests/fail/provenance/ptr_invalid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![feature(strict_provenance, exposed_provenance)]
22

3-
// Ensure that a `ptr::invalid` ptr is truly invalid.
3+
// Ensure that a `ptr::without_provenance` ptr is truly invalid.
44
fn main() {
55
let x = 42;
66
let xptr = &x as *const i32;
7-
let xptr_invalid = std::ptr::invalid::<i32>(xptr.expose_addr());
7+
let xptr_invalid = std::ptr::without_provenance::<i32>(xptr.expose_addr());
88
let _val = unsafe { *xptr_invalid }; //~ ERROR: is a dangling pointer
99
}

tests/fail/provenance/ptr_invalid_offset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
fn main() {
55
let x = 22;
66
let ptr = &x as *const _ as *const u8;
7-
let roundtrip = std::ptr::invalid::<u8>(ptr as usize);
7+
let roundtrip = std::ptr::without_provenance::<u8>(ptr as usize);
88
// Not even offsetting this is allowed.
99
let _ = unsafe { roundtrip.offset(1) }; //~ERROR: is a dangling pointer
1010
}

tests/pass-dep/shims/mmap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn test_mmap<Offset: Default>(
7171

7272
let ptr = unsafe {
7373
mmap(
74-
ptr::invalid_mut(page_size * 64),
74+
ptr::without_provenance_mut(page_size * 64),
7575
page_size,
7676
libc::PROT_READ | libc::PROT_WRITE,
7777
// We don't support MAP_FIXED
@@ -114,13 +114,13 @@ fn test_mmap<Offset: Default>(
114114
assert_eq!(ptr, libc::MAP_FAILED);
115115

116116
// We report an error when trying to munmap an address which is not a multiple of the page size
117-
let res = unsafe { libc::munmap(ptr::invalid_mut(1), page_size) };
117+
let res = unsafe { libc::munmap(ptr::without_provenance_mut(1), page_size) };
118118
assert_eq!(res, -1);
119119
assert_eq!(Error::last_os_error().raw_os_error().unwrap(), libc::EINVAL);
120120

121121
// We report an error when trying to munmap a length that cannot be rounded up to a multiple of
122122
// the page size.
123-
let res = unsafe { libc::munmap(ptr::invalid_mut(page_size), usize::MAX - 1) };
123+
let res = unsafe { libc::munmap(ptr::without_provenance_mut(page_size), usize::MAX - 1) };
124124
assert_eq!(res, -1);
125125
assert_eq!(Error::last_os_error().raw_os_error().unwrap(), libc::EINVAL);
126126
}
@@ -156,7 +156,7 @@ fn test_mremap() {
156156
// Test all of our error conditions
157157
// Not aligned
158158
let ptr =
159-
unsafe { libc::mremap(ptr::invalid_mut(1), page_size, page_size, libc::MREMAP_MAYMOVE) };
159+
unsafe { libc::mremap(ptr::without_provenance_mut(1), page_size, page_size, libc::MREMAP_MAYMOVE) };
160160
assert_eq!(ptr, libc::MAP_FAILED);
161161
assert_eq!(Error::last_os_error().raw_os_error().unwrap(), libc::EINVAL);
162162

tests/pass-dep/shims/posix_memalign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() {
5858

5959
// Non-power of 2 align
6060
unsafe {
61-
let mut ptr: *mut libc::c_void = ptr::invalid_mut(0x1234567);
61+
let mut ptr: *mut libc::c_void = ptr::without_provenance_mut(0x1234567);
6262
let align = 15;
6363
let size = 8;
6464
assert_eq!(libc::posix_memalign(&mut ptr, align, size), libc::EINVAL);
@@ -70,7 +70,7 @@ fn main() {
7070

7171
// Too small align (smaller than ptr)
7272
unsafe {
73-
let mut ptr: *mut libc::c_void = ptr::invalid_mut(0x1234567);
73+
let mut ptr: *mut libc::c_void = ptr::without_provenance_mut(0x1234567);
7474
let align = std::mem::size_of::<usize>() / 2;
7575
let size = 8;
7676
assert_eq!(libc::posix_memalign(&mut ptr, align, size), libc::EINVAL);

tests/pass/align_offset_symbolic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn huge_align() {
100100
#[cfg(target_pointer_width = "16")]
101101
const SIZE: usize = 1 << 13;
102102
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
103-
let _ = std::ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
103+
let _ = std::ptr::without_provenance::<HugeSize>(SIZE).align_offset(SIZE);
104104
}
105105

106106
// This shows that we cannot store the promised alignment info in `AllocExtra`,

tests/pass/atomic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ fn atomic_ptr() {
137137

138138
let ptr = AtomicPtr::<i32>::new(ptr::null_mut());
139139
assert!(ptr.load(Relaxed).addr() == 0);
140-
ptr.store(ptr::invalid_mut(13), SeqCst);
140+
ptr.store(ptr::without_provenance_mut(13), SeqCst);
141141
assert!(ptr.swap(x, Relaxed).addr() == 13);
142142
unsafe { assert!(*ptr.load(Acquire) == 0) };
143143

144144
// comparison ignores provenance
145145
assert_eq!(
146146
ptr.compare_exchange(
147147
(&mut 0 as *mut i32).with_addr(x.addr()),
148-
ptr::invalid_mut(0),
148+
ptr::without_provenance_mut(0),
149149
SeqCst,
150150
SeqCst
151151
)
@@ -156,7 +156,7 @@ fn atomic_ptr() {
156156
assert_eq!(
157157
ptr.compare_exchange(
158158
(&mut 0 as *mut i32).with_addr(x.addr()),
159-
ptr::invalid_mut(0),
159+
ptr::without_provenance_mut(0),
160160
SeqCst,
161161
SeqCst
162162
)

tests/pass/ptr_raw.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ fn assign_overlapping() {
3535
fn deref_invalid() {
3636
unsafe {
3737
// `addr_of!(*ptr)` is never UB.
38-
let _val = addr_of!(*ptr::invalid::<i32>(0));
39-
let _val = addr_of!(*ptr::invalid::<i32>(1)); // not aligned
38+
let _val = addr_of!(*ptr::without_provenance::<i32>(0));
39+
let _val = addr_of!(*ptr::without_provenance::<i32>(1)); // not aligned
4040

4141
// Similarly, just mentioning the place is fine.
42-
let _ = *ptr::invalid::<i32>(0);
43-
let _ = *ptr::invalid::<i32>(1);
42+
let _ = *ptr::without_provenance::<i32>(0);
43+
let _ = *ptr::without_provenance::<i32>(1);
4444
}
4545
}
4646

0 commit comments

Comments
 (0)