Skip to content

Commit b70362b

Browse files
committed
Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #121595 (Better reporting on generic argument mismatchs) - #122619 (Fix some unsoundness with PassMode::Cast ABI) - #122964 (Rename `expose_addr` to `expose_provenance`) - #123291 (Move some tests) - #123301 (pattern analysis: fix union handling) - #123395 (More postfix match fixes) - #123419 (rustc_index: Add a `ZERO` constant to index types) - #123421 (Fix target name in NetBSD platform-support doc) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 607cf8c + eceb0b4 commit b70362b

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

src/alloc_addresses/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use reuse_pool::ReusePool;
1818

1919
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2020
pub enum ProvenanceMode {
21-
/// We support `expose_addr`/`with_exposed_provenance` via "wildcard" provenance.
22-
/// However, we want on `with_exposed_provenance` to alert the user of the precision loss.
21+
/// We support `expose_provenance`/`with_exposed_provenance` via "wildcard" provenance.
22+
/// However, we warn on `with_exposed_provenance` to alert the user of the precision loss.
2323
Default,
2424
/// Like `Default`, but without the warning.
2525
Permissive,

src/shims/intrinsics/simd.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
514514
dest.transmute(this.machine.layouts.uint(dest.layout.size).unwrap(), this)?;
515515
this.write_int(res, &dest)?;
516516
}
517-
"cast" | "as" | "cast_ptr" | "expose_addr" | "with_exposed_provenance" => {
517+
"cast" | "as" | "cast_ptr" | "expose_provenance" | "with_exposed_provenance" => {
518518
let [op] = check_arg_count(args)?;
519519
let (op, op_len) = this.operand_to_simd(op)?;
520520
let (dest, dest_len) = this.mplace_to_simd(dest)?;
@@ -524,7 +524,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
524524
let unsafe_cast = intrinsic_name == "cast";
525525
let safe_cast = intrinsic_name == "as";
526526
let ptr_cast = intrinsic_name == "cast_ptr";
527-
let expose_cast = intrinsic_name == "expose_addr";
527+
let expose_cast = intrinsic_name == "expose_provenance";
528528
let from_exposed_cast = intrinsic_name == "with_exposed_provenance";
529529

530530
for i in 0..dest_len {
@@ -557,7 +557,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
557557
this.ptr_to_ptr(&op, dest.layout)?,
558558
// Ptr/Int casts
559559
(ty::RawPtr(..), ty::Int(_) | ty::Uint(_)) if expose_cast =>
560-
this.pointer_expose_address_cast(&op, dest.layout)?,
560+
this.pointer_expose_provenance_cast(&op, dest.layout)?,
561561
(ty::Int(_) | ty::Uint(_), ty::RawPtr(..)) if from_exposed_cast =>
562562
this.pointer_with_exposed_provenance_cast(&op, dest.layout)?,
563563
// Error otherwise

tests/fail/provenance/ptr_invalid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
fn main() {
55
let x = 42;
66
let xptr = &x as *const i32;
7-
let xptr_invalid = std::ptr::without_provenance::<i32>(xptr.expose_addr());
7+
let xptr_invalid = std::ptr::without_provenance::<i32>(xptr.expose_provenance());
88
let _val = unsafe { *xptr_invalid }; //~ ERROR: is a dangling pointer
99
}

tests/fail/stacked_borrows/exposed_only_ro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
fn main() {
77
let mut x = 0;
88
let _fool = &mut x as *mut i32; // this would have fooled the old untagged pointer logic
9-
let addr = (&x as *const i32).expose_addr();
9+
let addr = (&x as *const i32).expose_provenance();
1010
let ptr = std::ptr::with_exposed_provenance_mut::<i32>(addr);
1111
unsafe { *ptr = 0 }; //~ ERROR: /write access using <wildcard> .* no exposed tags have suitable permission in the borrow stack/
1212
}

tests/pass/portable-simd-ptrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ use std::simd::prelude::*;
77
fn main() {
88
// Pointer casts
99
let _val: Simd<*const u8, 4> = Simd::<*const i32, 4>::splat(ptr::null()).cast();
10-
let addrs = Simd::<*const i32, 4>::splat(ptr::null()).expose_addr();
10+
let addrs = Simd::<*const i32, 4>::splat(ptr::null()).expose_provenance();
1111
let _ptrs = Simd::<*const i32, 4>::with_exposed_provenance(addrs);
1212
}

tests/pass/ptr_int_from_exposed.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn ptr_roundtrip_out_of_bounds() {
1010
let x: i32 = 3;
1111
let x_ptr = &x as *const i32;
1212

13-
let x_usize = x_ptr.wrapping_offset(128).expose_addr();
13+
let x_usize = x_ptr.wrapping_offset(128).expose_provenance();
1414

1515
let ptr = ptr::with_exposed_provenance::<i32>(x_usize).wrapping_offset(-128);
1616
assert_eq!(unsafe { *ptr }, 3);
@@ -24,8 +24,8 @@ fn ptr_roundtrip_confusion() {
2424
let x_ptr = &x as *const i32;
2525
let y_ptr = &y as *const i32;
2626

27-
let x_usize = x_ptr.expose_addr();
28-
let y_usize = y_ptr.expose_addr();
27+
let x_usize = x_ptr.expose_provenance();
28+
let y_usize = y_ptr.expose_provenance();
2929

3030
let ptr = ptr::with_exposed_provenance::<i32>(y_usize);
3131
let ptr = ptr.with_addr(x_usize);
@@ -37,7 +37,7 @@ fn ptr_roundtrip_imperfect() {
3737
let x: u8 = 3;
3838
let x_ptr = &x as *const u8;
3939

40-
let x_usize = x_ptr.expose_addr() + 128;
40+
let x_usize = x_ptr.expose_provenance() + 128;
4141

4242
let ptr = ptr::with_exposed_provenance::<u8>(x_usize).wrapping_offset(-128);
4343
assert_eq!(unsafe { *ptr }, 3);
@@ -48,7 +48,7 @@ fn ptr_roundtrip_null() {
4848
let x = &42;
4949
let x_ptr = x as *const i32;
5050
let x_null_ptr = x_ptr.with_addr(0); // addr 0, but still the provenance of x
51-
let null = x_null_ptr.expose_addr();
51+
let null = x_null_ptr.expose_provenance();
5252
assert_eq!(null, 0);
5353

5454
let x_null_ptr_copy = ptr::with_exposed_provenance::<i32>(null); // just a roundtrip, so has provenance of x (angelically)

tests/pass/stacked-borrows/int-to-ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn example(variant: bool) {
1717
unsafe {
1818
fn not_so_innocent(x: &mut u32) -> usize {
1919
let x_raw4 = x as *mut u32;
20-
x_raw4.expose_addr()
20+
x_raw4.expose_provenance()
2121
}
2222

2323
let mut c = 42u32;
@@ -26,7 +26,7 @@ fn example(variant: bool) {
2626
// stack: [..., Unique(1)]
2727

2828
let x_raw2 = x_unique1 as *mut u32;
29-
let x_raw2_addr = x_raw2.expose_addr();
29+
let x_raw2_addr = x_raw2.expose_provenance();
3030
// stack: [..., Unique(1), SharedRW(2)]
3131

3232
let x_unique3 = &mut *x_raw2;

tests/pass/stacked-borrows/unknown-bottom-gc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99

1010
// Expose the allocation and use the exposed pointer, creating an unknown bottom
1111
unsafe {
12-
let p: *mut u8 = ptr::with_exposed_provenance::<u8>(ptr.expose_addr()) as *mut u8;
12+
let p: *mut u8 = ptr::with_exposed_provenance::<u8>(ptr.expose_provenance()) as *mut u8;
1313
*p = 1;
1414
}
1515

0 commit comments

Comments
 (0)