Skip to content

Commit 2895ef8

Browse files
committed
Auto merge of #3447 - rust-lang:rustup-2024-04-04, r=saethlin
Automatic Rustup
2 parents e38a828 + b245e2c commit 2895ef8

File tree

11 files changed

+118
-17
lines changed

11 files changed

+118
-17
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b688d53a1736c17e49328a706a90829a9937a91a
1+
0accf4ec4c07d23aa86f6a97aeb8797941abc30e

src/alloc_addresses/mod.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/async-closure-captures.rs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Same as rustc's `tests/ui/async-await/async-closures/captures.rs`, keep in sync
2+
3+
#![feature(async_closure, noop_waker)]
4+
5+
use std::future::Future;
6+
use std::pin::pin;
7+
use std::task::*;
8+
9+
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
10+
let mut fut = pin!(fut);
11+
let ctx = &mut Context::from_waker(Waker::noop());
12+
13+
loop {
14+
match fut.as_mut().poll(ctx) {
15+
Poll::Pending => {}
16+
Poll::Ready(t) => break t,
17+
}
18+
}
19+
}
20+
21+
fn main() {
22+
block_on(async_main());
23+
}
24+
25+
async fn call<T>(f: &impl async Fn() -> T) -> T {
26+
f().await
27+
}
28+
29+
async fn call_once<T>(f: impl async FnOnce() -> T) -> T {
30+
f().await
31+
}
32+
33+
#[derive(Debug)]
34+
#[allow(unused)]
35+
struct Hello(i32);
36+
37+
async fn async_main() {
38+
// Capture something by-ref
39+
{
40+
let x = Hello(0);
41+
let c = async || {
42+
println!("{x:?}");
43+
};
44+
call(&c).await;
45+
call_once(c).await;
46+
47+
let x = &Hello(1);
48+
let c = async || {
49+
println!("{x:?}");
50+
};
51+
call(&c).await;
52+
call_once(c).await;
53+
}
54+
55+
// Capture something and consume it (force to `AsyncFnOnce`)
56+
{
57+
let x = Hello(2);
58+
let c = async || {
59+
println!("{x:?}");
60+
drop(x);
61+
};
62+
call_once(c).await;
63+
}
64+
65+
// Capture something with `move`, don't consume it
66+
{
67+
let x = Hello(3);
68+
let c = async move || {
69+
println!("{x:?}");
70+
};
71+
call(&c).await;
72+
call_once(c).await;
73+
74+
let x = &Hello(4);
75+
let c = async move || {
76+
println!("{x:?}");
77+
};
78+
call(&c).await;
79+
call_once(c).await;
80+
}
81+
82+
// Capture something with `move`, also consume it (so `AsyncFnOnce`)
83+
{
84+
let x = Hello(5);
85+
let c = async move || {
86+
println!("{x:?}");
87+
drop(x);
88+
};
89+
call_once(c).await;
90+
}
91+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Hello(0)
2+
Hello(0)
3+
Hello(1)
4+
Hello(1)
5+
Hello(2)
6+
Hello(3)
7+
Hello(3)
8+
Hello(4)
9+
Hello(4)
10+
Hello(5)

tests/pass/portable-simd-ptrs.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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)