Skip to content

Commit 9b5ebba

Browse files
committed
Auto merge of #97742 - matthiaskrgr:rollup-fr3j0t8, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #97609 (Iterate over `maybe_unused_trait_imports` when checking dead trait imports) - #97688 (test const_copy to make sure bytewise pointer copies are working) - #97707 (Improve soundness of rustc_data_structures) - #97731 (Add regresion test for #87142) - #97735 (Don't generate "Impls on Foreign Types" for std) - #97737 (Fix pretty printing named bound regions under -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 98a6ad7 + 3e43ac5 commit 9b5ebba

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

core/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#![feature(const_option)]
8585
#![feature(const_option_ext)]
8686
#![feature(const_result)]
87+
#![feature(const_intrinsic_copy)]
8788
#![feature(integer_atomics)]
8889
#![feature(int_roundings)]
8990
#![feature(slice_group_by)]

core/tests/ptr.rs

+40
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use core::cell::RefCell;
2+
use core::mem::{self, MaybeUninit};
23
use core::num::NonZeroUsize;
34
use core::ptr;
45
use core::ptr::*;
@@ -781,3 +782,42 @@ fn nonnull_tagged_pointer_with_provenance() {
781782
}
782783
}
783784
}
785+
786+
#[test]
787+
fn test_const_copy() {
788+
const {
789+
let ptr1 = &1;
790+
let mut ptr2 = &666;
791+
792+
// Copy ptr1 to ptr2, bytewise.
793+
unsafe {
794+
ptr::copy(
795+
&ptr1 as *const _ as *const MaybeUninit<u8>,
796+
&mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
797+
mem::size_of::<&i32>(),
798+
);
799+
}
800+
801+
// Make sure they still work.
802+
assert!(*ptr1 == 1);
803+
assert!(*ptr2 == 1);
804+
};
805+
806+
const {
807+
let ptr1 = &1;
808+
let mut ptr2 = &666;
809+
810+
// Copy ptr1 to ptr2, bytewise.
811+
unsafe {
812+
ptr::copy_nonoverlapping(
813+
&ptr1 as *const _ as *const MaybeUninit<u8>,
814+
&mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
815+
mem::size_of::<&i32>(),
816+
);
817+
}
818+
819+
// Make sure they still work.
820+
assert!(*ptr1 == 1);
821+
assert!(*ptr2 == 1);
822+
};
823+
}

0 commit comments

Comments
 (0)