diff options
| author | bors <bors@rust-lang.org> | 2025-01-16 10:52:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-16 10:52:11 +0000 |
| commit | d8a64098c9d0fb25699f657c6efff0bb418f7e18 (patch) | |
| tree | bdac77b7db080d83e34592a5d311012439db5e54 /tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir | |
| parent | d61f55d8b9d4703207a5980f27b6c28973ba27ee (diff) | |
| parent | c18718c9c28cc4c700312775c2b7f87cd79d3063 (diff) | |
| download | rust-d8a64098c9d0fb25699f657c6efff0bb418f7e18.tar.gz rust-d8a64098c9d0fb25699f657c6efff0bb418f7e18.zip | |
Auto merge of #135344 - scottmcm:safe-dangling, r=joboet
Less unsafe in `dangling`/`without_provenance` This PR was inspired by the new `NonNull::without_provenance` (cc https://github.com/rust-lang/rust/issues/135243#issuecomment-2583913562) since it made me realize that we could write `NonNull::dangling` in completely-safe code using other existing things. Then doing that led me to a few more places that could be simplified, like now that GVN will optimize Transmute-then-PtrToPtr, we can just implement `ptr::without_provenance` by calling `ptr::without_provenance_mut` since the shipped rlib of `core` ends up with the same single statement as the implementation (thanks to GVN merging the steps) and thus there's no need to duplicate the `transmute` -- and more importantly, no need to repeat a long safety comment. There did end up being a couple of other changes needed to avoid exploding certain bits of MIR, though -- like `<Box<[i32]>>::default()`'s MIR originally got way worse as certain things didn't inline, or had a bunch of extraneous UbChecks -- so there's a couple of other changes to solve that.
Diffstat (limited to 'tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir')
| -rw-r--r-- | tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index e7ddacf3144..6ed8ef9715b 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -18,7 +18,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 2 { debug x => _17; } - scope 18 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { + scope 19 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { let mut _14: &mut std::slice::Iter<'_, T>; } } @@ -35,10 +35,12 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 7 { } scope 12 (inlined without_provenance::<T>) { + scope 13 (inlined without_provenance_mut::<T>) { + } } - scope 13 (inlined NonNull::<T>::as_ptr) { + scope 14 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 15 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { @@ -54,11 +56,11 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } } - scope 15 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - scope 16 (inlined Rev::<std::slice::Iter<'_, T>>::new) { + scope 16 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { + scope 17 (inlined Rev::<std::slice::Iter<'_, T>>::new) { } } - scope 17 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { + scope 18 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { } bb0: { |
