Skip to content

Commit f2bb429

Browse files
committed
Auto merge of #123396 - jhpratt:rollup-oa54mh1, r=jhpratt
Rollup of 5 pull requests Successful merges: - #122865 (Split hir ty lowerer's error reporting code in check functions to mod errors.) - #122935 (rename ptr::from_exposed_addr -> ptr::with_exposed_provenance) - #123182 (Avoid expanding to unstable internal method) - #123203 (Add `Context::ext`) - #123380 (Improve bootstrap comments) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 11e17ca + f431b38 commit f2bb429

File tree

15 files changed

+33
-33
lines changed

15 files changed

+33
-33
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.

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:

tests/fail/stacked_borrows/exposed_only_ro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn main() {
77
let mut x = 0;
88
let _fool = &mut x as *mut i32; // this would have fooled the old untagged pointer logic
99
let addr = (&x as *const i32).expose_addr();
10-
let ptr = std::ptr::from_exposed_addr_mut::<i32>(addr);
10+
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/box.stack.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ warning: integer-to-pointer cast
44
LL | let r2 = ((r as usize) + 0) as *mut i32;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
66
|
7-
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
7+
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,
88
= help: which means that Miri might miss pointer bugs in this program.
9-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
9+
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
1010
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
11-
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
11+
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics.
1212
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
1313
= note: BACKTRACE:
1414
= note: inside `into_raw` at $DIR/box.rs:LL:CC

tests/pass/extern_types.stack.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ warning: integer-to-pointer cast
44
LL | let x: &Foo = unsafe { &*(16 as *const Foo) };
55
| ^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
66
|
7-
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
7+
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,
88
= help: which means that Miri might miss pointer bugs in this program.
9-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
9+
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
1010
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
11-
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
11+
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics.
1212
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
1313
= note: BACKTRACE:
1414
= note: inside `main` at $DIR/extern_types.rs:LL:CC

0 commit comments

Comments
 (0)