Skip to content

Ignore big-endian targets in UI tests with raw bytes #102379

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

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
_4 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
// mir::Constant
// + span: $DIR/mutable_variable_no_prop.rs:10:13: 10:19
// + span: $DIR/mutable_variable_no_prop.rs:11:13: 11:19
// + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) }
_3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
_1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19
Expand Down
1 change: 1 addition & 0 deletions src/test/mir-opt/const_prop/mutable_variable_no_prop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// unit-test
// compile-flags: -O
// ignore-endian-big

static mut STATIC: u32 = 42;

Expand Down
1 change: 1 addition & 0 deletions src/test/mir-opt/issues/issue-75439.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff
// ignore-endian-big

use std::mem::transmute;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
_3 = _1; // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:+2:37: +2:53
// mir::Constant
// + span: $DIR/issue-75439.rs:7:37: 7:46
// + span: $DIR/issue-75439.rs:8:37: 8:46
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {transmute::<[u8; 16], [u32; 4]>}, val: Value(<ZST>) }
}

Expand All @@ -49,7 +49,7 @@
_6 = _4; // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb7; // scope 4 at $DIR/issue-75439.rs:+5:23: +5:36
// mir::Constant
// + span: $DIR/issue-75439.rs:10:23: 10:32
// + span: $DIR/issue-75439.rs:11:23: 11:32
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {transmute::<u32, [u8; 4]>}, val: Value(<ZST>) }
}

Expand Down
56 changes: 28 additions & 28 deletions src/test/ui/const-ptr/forbidden_slices.32bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LL | &*ptr::slice_from_raw_parts(data, len)
| dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
| inside `std::slice::from_raw_parts::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:18:34
::: $DIR/forbidden_slices.rs:19:34
|
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:18:34
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:19:34

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
Expand All @@ -21,10 +21,10 @@ LL | &*ptr::slice_from_raw_parts(data, len)
| dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
| inside `std::slice::from_raw_parts::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:19:33
::: $DIR/forbidden_slices.rs:20:33
|
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
| ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:19:33
| ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:20:33

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
Expand All @@ -35,13 +35,13 @@ LL | &*ptr::slice_from_raw_parts(data, len)
| dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
| inside `std::slice::from_raw_parts::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:22:34
::: $DIR/forbidden_slices.rs:23:34
|
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:22:34
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:23:34

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:25:1
--> $DIR/forbidden_slices.rs:26:1
|
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
Expand All @@ -52,7 +52,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:27:1
--> $DIR/forbidden_slices.rs:28:1
|
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
Expand All @@ -64,7 +64,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:29:1
--> $DIR/forbidden_slices.rs:30:1
|
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
Expand All @@ -75,7 +75,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4)
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:32:1
--> $DIR/forbidden_slices.rs:33:1
|
LL | pub static S7: &[u16] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
Expand All @@ -94,10 +94,10 @@ LL | &*ptr::slice_from_raw_parts(data, len)
| dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
| inside `std::slice::from_raw_parts::<'_, u64>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:43:5
::: $DIR/forbidden_slices.rs:44:5
|
LL | from_raw_parts(ptr, 1)
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:43:5
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:44:5

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
Expand All @@ -113,10 +113,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
| ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:46:34
::: $DIR/forbidden_slices.rs:47:34
|
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:46:34
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:47:34

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
Expand All @@ -132,10 +132,10 @@ LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
| ------------------------------ inside `from_ptr_range::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:47:33
::: $DIR/forbidden_slices.rs:48:33
|
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
| ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:47:33
| ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:48:33
|
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

Expand All @@ -151,13 +151,13 @@ LL | unsafe { intrinsics::offset(self, count) }
LL | unsafe { self.offset(count as isize) }
| --------------------------- inside `ptr::const_ptr::<impl *const u32>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:50:25
::: $DIR/forbidden_slices.rs:51:25
|
LL | from_ptr_range(ptr..ptr.add(2))
| ---------- inside `R2` at $DIR/forbidden_slices.rs:50:25
| ---------- inside `R2` at $DIR/forbidden_slices.rs:51:25

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:52:1
--> $DIR/forbidden_slices.rs:53:1
|
LL | pub static R4: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
Expand All @@ -168,7 +168,7 @@ LL | pub static R4: &[u8] = unsafe {
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:57:1
--> $DIR/forbidden_slices.rs:58:1
|
LL | pub static R5: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
Expand All @@ -180,7 +180,7 @@ LL | pub static R5: &[u8] = unsafe {
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:62:1
--> $DIR/forbidden_slices.rs:63:1
|
LL | pub static R6: &[bool] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
Expand All @@ -191,7 +191,7 @@ LL | pub static R6: &[bool] = unsafe {
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:67:1
--> $DIR/forbidden_slices.rs:68:1
|
LL | pub static R7: &[u16] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
Expand All @@ -213,10 +213,10 @@ LL | unsafe { intrinsics::offset(self, count) }
LL | unsafe { self.offset(count as isize) }
| --------------------------- inside `ptr::const_ptr::<impl *const u64>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:74:25
::: $DIR/forbidden_slices.rs:75:25
|
LL | from_ptr_range(ptr..ptr.add(1))
| ---------- inside `R8` at $DIR/forbidden_slices.rs:74:25
| ---------- inside `R8` at $DIR/forbidden_slices.rs:75:25

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
Expand All @@ -232,10 +232,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
| ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:79:34
::: $DIR/forbidden_slices.rs:80:34
|
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:79:34
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:80:34

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
Expand All @@ -251,10 +251,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
| ------------------------------ inside `from_ptr_range::<'_, u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:80:35
::: $DIR/forbidden_slices.rs:81:35
|
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:80:35
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:81:35

error: aborting due to 18 previous errors

Expand Down
Loading