Skip to content

Commit ad9ed05

Browse files
committed
Auto merge of #3440 - rust-lang:rustup-2024-04-03, r=RalfJung
Automatic Rustup
2 parents bd75703 + e5c5a68 commit ad9ed05

18 files changed

+44
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ environment variable. We first document the most relevant and most commonly used
324324
number of available CPUs is `1`. Note that this flag does not affect how miri handles threads in
325325
any way.
326326
* `-Zmiri-permissive-provenance` disables the warning for integer-to-pointer casts and
327-
[`ptr::from_exposed_addr`](https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html).
327+
[`ptr::with_exposed_provenance`](https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html).
328328
This will necessarily miss some bugs as those operations are not efficiently and accurately
329329
implementable in a sanitizer, but it will only miss bugs that concern memory/pointers which is
330330
subject to these operations.

cargo-miri/src/phases.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
8989
let verbose = num_arg_flag("-v");
9090

9191
// Determine the involved architectures.
92-
let rustc_version = VersionMeta::for_command(miri_for_host())
93-
.expect("failed to determine underlying rustc version of Miri");
92+
let rustc_version = VersionMeta::for_command(miri_for_host()).unwrap_or_else(|err| {
93+
panic!(
94+
"failed to determine underlying rustc version of Miri ({:?}):\n{err:?}",
95+
miri_for_host()
96+
)
97+
});
9498
let host = &rustc_version.host;
9599
let target = get_arg_flag_value("--target");
96100
let target = target.as_ref().unwrap_or(host);
@@ -222,7 +226,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
222226
}
223227

224228
// Run cargo.
225-
debug_cmd("[cargo-miri miri]", verbose, &cmd);
229+
debug_cmd("[cargo-miri cargo]", verbose, &cmd);
226230
exec(cmd)
227231
}
228232

cargo-miri/src/setup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ pub fn setup(
9090
let cargo_cmd = {
9191
let mut command = cargo();
9292
// Use Miri as rustc to build a libstd compatible with us (and use the right flags).
93+
// We set ourselves (`cargo-miri`) instead of Miri directly to be able to patch the flags
94+
// for `libpanic_abort` (usually this is done by bootstrap but we have to do it ourselves).
95+
// The `MIRI_CALLED_FROM_SETUP` will mean we dispatch to `phase_setup_rustc`.
9396
// However, when we are running in bootstrap, we cannot just overwrite `RUSTC`,
9497
// because we still need bootstrap to distinguish between host and target crates.
9598
// In that case we overwrite `RUSTC_REAL` instead which determines the rustc used
9699
// for target crates.
97-
// We set ourselves (`cargo-miri`) instead of Miri directly to be able to patch the flags
98-
// for `libpanic_abort` (usually this is done by bootstrap but we have to do it ourselves).
99-
// The `MIRI_CALLED_FROM_SETUP` will mean we dispatch to `phase_setup_rustc`.
100100
let cargo_miri_path = std::env::current_exe().expect("current executable path invalid");
101101
if env::var_os("RUSTC_STAGE").is_some() {
102102
assert!(env::var_os("RUSTC").is_some());

rust-version

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

src/alloc_addresses/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ use reuse_pool::ReusePool;
1818

1919
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2020
pub enum ProvenanceMode {
21-
/// We support `expose_addr`/`from_exposed_addr` via "wildcard" provenance.
22-
/// However, we want on `from_exposed_addr` to alert the user of the precision loss.
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.
2323
Default,
2424
/// Like `Default`, but without the warning.
2525
Permissive,
26-
/// We error on `from_exposed_addr`, ensuring no precision loss.
26+
/// We error on `with_exposed_provenance`, ensuring no precision loss.
2727
Strict,
2828
}
2929

src/diagnostics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl fmt::Display for TerminationInfo {
6666
Int2PtrWithStrictProvenance =>
6767
write!(
6868
f,
69-
"integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`"
69+
"integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`"
7070
),
7171
StackedBorrowsUb { msg, .. } => write!(f, "{msg}"),
7272
TreeBorrowsUb { title, .. } => write!(f, "{title}"),
@@ -593,7 +593,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
593593
(
594594
None,
595595
format!(
596-
"This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,"
596+
"This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,"
597597
),
598598
),
599599
(
@@ -603,7 +603,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
603603
(
604604
None,
605605
format!(
606-
"See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation."
606+
"See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation."
607607
),
608608
),
609609
(
@@ -615,7 +615,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
615615
(
616616
None,
617617
format!(
618-
"You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics."
618+
"You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics."
619619
),
620620
),
621621
(

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" | "from_exposed_addr" => {
517+
"cast" | "as" | "cast_ptr" | "expose_addr" | "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)?;
@@ -525,7 +525,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
525525
let safe_cast = intrinsic_name == "as";
526526
let ptr_cast = intrinsic_name == "cast_ptr";
527527
let expose_cast = intrinsic_name == "expose_addr";
528-
let from_exposed_cast = intrinsic_name == "from_exposed_addr";
528+
let from_exposed_cast = intrinsic_name == "with_exposed_provenance";
529529

530530
for i in 0..dest_len {
531531
let op = this.read_immediate(&this.project_index(&op, i)?)?;
@@ -559,7 +559,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
559559
(ty::RawPtr(..), ty::Int(_) | ty::Uint(_)) if expose_cast =>
560560
this.pointer_expose_address_cast(&op, dest.layout)?,
561561
(ty::Int(_) | ty::Uint(_), ty::RawPtr(..)) if from_exposed_cast =>
562-
this.pointer_from_exposed_address_cast(&op, dest.layout)?,
562+
this.pointer_with_exposed_provenance_cast(&op, dest.layout)?,
563563
// Error otherwise
564564
_ =>
565565
throw_unsup_format!(

tests/fail/provenance/ptr_int_unexposed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn main() {
77

88
let x_usize: usize = x_ptr.addr();
99
// Cast back an address that did *not* get exposed.
10-
let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
10+
let ptr = std::ptr::with_exposed_provenance::<i32>(x_usize);
1111
assert_eq!(unsafe { *ptr }, 3); //~ ERROR: is a dangling pointer
1212
}

tests/fail/provenance/strict_provenance_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
fn main() {
55
let addr = &0 as *const i32 as usize;
6-
let _ptr = std::ptr::from_exposed_addr::<i32>(addr); //~ ERROR: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported
6+
let _ptr = std::ptr::with_exposed_provenance::<i32>(addr); //~ ERROR: integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported
77
}

tests/fail/provenance/strict_provenance_cast.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: unsupported operation: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
1+
error: unsupported operation: integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`
22
--> $DIR/strict_provenance_cast.rs:LL:CC
33
|
4-
LL | let _ptr = std::ptr::from_exposed_addr::<i32>(addr);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
4+
LL | let _ptr = std::ptr::with_exposed_provenance::<i32>(addr);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`
66
|
77
= help: use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
88
= note: BACKTRACE:

0 commit comments

Comments
 (0)