Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make const tests independent of std debug assertions #118358

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading