Skip to content

Commit

Permalink
Auto merge of #97742 - matthiaskrgr:rollup-fr3j0t8, r=matthiaskrgr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 4, 2022
2 parents 98a6ad7 + 3e43ac5 commit 9b5ebba
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#![feature(const_option)]
#![feature(const_option_ext)]
#![feature(const_result)]
#![feature(const_intrinsic_copy)]
#![feature(integer_atomics)]
#![feature(int_roundings)]
#![feature(slice_group_by)]
Expand Down
40 changes: 40 additions & 0 deletions core/tests/ptr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::cell::RefCell;
use core::mem::{self, MaybeUninit};
use core::num::NonZeroUsize;
use core::ptr;
use core::ptr::*;
Expand Down Expand Up @@ -781,3 +782,42 @@ fn nonnull_tagged_pointer_with_provenance() {
}
}
}

#[test]
fn test_const_copy() {
const {
let ptr1 = &1;
let mut ptr2 = &666;

// Copy ptr1 to ptr2, bytewise.
unsafe {
ptr::copy(
&ptr1 as *const _ as *const MaybeUninit<u8>,
&mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
mem::size_of::<&i32>(),
);
}

// Make sure they still work.
assert!(*ptr1 == 1);
assert!(*ptr2 == 1);
};

const {
let ptr1 = &1;
let mut ptr2 = &666;

// Copy ptr1 to ptr2, bytewise.
unsafe {
ptr::copy_nonoverlapping(
&ptr1 as *const _ as *const MaybeUninit<u8>,
&mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
mem::size_of::<&i32>(),
);
}

// Make sure they still work.
assert!(*ptr1 == 1);
assert!(*ptr2 == 1);
};
}

0 comments on commit 9b5ebba

Please sign in to comment.