Skip to content

Commit

Permalink
make const tests independent of std debug assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 27, 2023
1 parent 601a427 commit 8892d29
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 232 deletions.
130 changes: 54 additions & 76 deletions tests/ui/consts/const-eval/raw-bytes.32bit.stderr

Large diffs are not rendered by default.

130 changes: 54 additions & 76 deletions tests/ui/consts/const-eval/raw-bytes.64bit.stderr

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions tests/ui/consts/const-eval/raw-bytes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// stderr-per-bitwidth
// ignore-endian-big
// ignore-tidy-linelength
// ignore-debug debug assertions catch some UB too early
// normalize-stderr-test "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼" -> "╾ALLOC_ID$1╼"

#![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)]
Expand All @@ -13,6 +12,8 @@ use std::ptr::NonNull;
use std::num::{NonZeroU8, NonZeroUsize};
use std::slice::{from_ptr_range, from_raw_parts};

// # Bad enums and chars

#[repr(usize)]
#[derive(Copy, Clone)]
enum Enum {
Expand Down Expand Up @@ -51,6 +52,7 @@ const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8)
const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
//~^ ERROR is undefined behavior

// # Bad pointers and references

const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
//~^ ERROR it is undefined behavior to use this value
Expand Down Expand Up @@ -197,16 +199,7 @@ const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
//~^ ERROR it is undefined behavior to use this value


// not ok, since alignment needs to be non-zero.
const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
//~^ ERROR it is undefined behavior to use this value

// not ok, since alignment needs to be a power of two.
const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
//~^ ERROR it is undefined behavior to use this value


// Uninhabited types
const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior
const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior
const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior
Expand Down
25 changes: 0 additions & 25 deletions tests/ui/consts/std/alloc.32bit.stderr

This file was deleted.

25 changes: 0 additions & 25 deletions tests/ui/consts/std/alloc.64bit.stderr

This file was deleted.

19 changes: 0 additions & 19 deletions tests/ui/consts/std/alloc.rs

This file was deleted.

0 comments on commit 8892d29

Please sign in to comment.