diff options
| author | bors <bors@rust-lang.org> | 2020-03-20 19:02:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-03-20 19:02:32 +0000 |
| commit | 1057dc97afce39ff6a224966ece3ed438af4c1f5 (patch) | |
| tree | 3ae6e64d6e60e9aeac52df17f5a1cb4ba37688af /src | |
| parent | 2835ca65845c5fac8da2a2612a06b12ad2f4c77c (diff) | |
| parent | c95f08affac33aa86c9c39110e7d717d2a5e3d33 (diff) | |
| download | rust-1057dc97afce39ff6a224966ece3ed438af4c1f5.tar.gz rust-1057dc97afce39ff6a224966ece3ed438af4c1f5.zip | |
Auto merge of #69509 - RalfJung:debug-assert-write, r=eddyb
debug-assert ptr sanity in ptr::write This is a re-submission of the parts that we removed from https://github.com/rust-lang/rust/pull/69208 due to ["interesting" test failures](https://github.com/rust-lang/rust/pull/69208#issuecomment-591310437). Fixes https://github.com/rust-lang/rust/issues/53871 r? @Mark-Simulacrum @eddyb
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/ptr/mod.rs | 4 | ||||
| -rw-r--r-- | src/test/codegen/repeat-trusted-len.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-40883.rs | 7 |
3 files changed, 6 insertions, 12 deletions
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 72c46f58fcc..4913cd73a2a 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -810,9 +810,7 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn write<T>(dst: *mut T, src: T) { - // FIXME: the debug assertion here causes codegen test failures on some architectures. - // See <https://github.com/rust-lang/rust/pull/69208#issuecomment-591326757>. - // debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); intrinsics::move_val_init(&mut *dst, src) } diff --git a/src/test/codegen/repeat-trusted-len.rs b/src/test/codegen/repeat-trusted-len.rs index 8fbe712065b..8e08b78ad1e 100644 --- a/src/test/codegen/repeat-trusted-len.rs +++ b/src/test/codegen/repeat-trusted-len.rs @@ -5,14 +5,9 @@ use std::iter; -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) -#[no_mangle] -pub fn helper(_: usize) { -} - // CHECK-LABEL: @repeat_take_collect #[no_mangle] pub fn repeat_take_collect() -> Vec<u8> { -// CHECK: call void @llvm.memset.p0i8.[[USIZE]](i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, [[USIZE]] 100000, i1 false) +// CHECK: call void @llvm.memset.p0i8.i{{[0-9]+}}(i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, i{{[0-9]+}} 100000, i1 false) iter::repeat(42).take(100000).collect() } diff --git a/src/test/ui/issues/issue-40883.rs b/src/test/ui/issues/issue-40883.rs index 37e61b1b0e6..8a4aef46dd5 100644 --- a/src/test/ui/issues/issue-40883.rs +++ b/src/test/ui/issues/issue-40883.rs @@ -71,15 +71,16 @@ pub fn supersize_me(out: &mut Vec<Big>) { #[inline(never)] fn verify_stack_usage(before_ptr: *mut Vec<Big>) { - // to check stack usage, create locals before and after + // To check stack usage, create locals before and after // and check the difference in addresses between them. let mut stack_var: Vec<Big> = vec![]; test::black_box(&mut stack_var); let stack_usage = isize::abs( (&mut stack_var as *mut _ as isize) - (before_ptr as isize)) as usize; - // give space for 2 copies of `Big` + 128 "misc" bytes. - if stack_usage > mem::size_of::<Big>() * 2 + 128 { + // Give space for 2 copies of `Big` + 272 "misc" bytes + // (value observed on x86_64-pc-windows-gnu). + if stack_usage > mem::size_of::<Big>() * 2 + 272 { panic!("used {} bytes of stack, but `struct Big` is only {} bytes", stack_usage, mem::size_of::<Big>()); } |
