Skip to content

Rollup of 7 pull requests #97561

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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cf30ac8
refactor: VecDeques Iter fields to private
DeveloperC286 Oct 8, 2021
d7a2d9a
Miri call ABI check: ensure type size+align stay the same
RalfJung May 25, 2022
0be2ca9
Optimize the diagnostic generation for `extern unsafe`
SparrowLii May 30, 2022
19caa8c
Make `from{,_mut}_ptr_range` const
WaffleLapkin May 26, 2022
ff9efd8
Add reexport of slice::from{,_mut}_ptr_range to alloc & std
WaffleLapkin May 27, 2022
a63a83a
Add ui tests for `slice::from_{ptr_range,raw_parts}`
WaffleLapkin May 27, 2022
10ee6f8
Rename slice_from_ptr_range_const -> const_slice_from_ptr_range
WaffleLapkin May 27, 2022
0cca47e
Use `// error-pattern:` header in `forbidden_slices.rs` test
WaffleLapkin May 29, 2022
6d10217
--bless
WaffleLapkin May 29, 2022
1f8a641
test forbidden slices on all two usizesizes
WaffleLapkin May 29, 2022
f669b78
errors: simplify referring to fluent attributes
davidtwco May 24, 2022
1e0747f
normalize forbidden slices
WaffleLapkin May 30, 2022
f3eae89
Fix invalid line number computation when clicking on something else t…
GuillaumeGomez May 30, 2022
16d5cdc
Improve source-code-page.goml GUI test code
GuillaumeGomez May 30, 2022
d286df1
Add line number click GUI test
GuillaumeGomez May 30, 2022
56662bc
Fix typos in comment
stoeckmann May 30, 2022
bac701a
Rollup merge of #89685 - DeveloperC286:iter_fields_to_private, r=oli-obk
compiler-errors May 30, 2022
0cf8c57
Rollup merge of #97172 - SparrowLii:unsafe_extern, r=compiler-errors
compiler-errors May 30, 2022
bb33f99
Rollup merge of #97357 - davidtwco:diagnostic-translation-typed-subdi…
compiler-errors May 30, 2022
6b51f7c
Rollup merge of #97395 - RalfJung:call-abi, r=oli-obk
compiler-errors May 30, 2022
64aef24
Rollup merge of #97419 - WaffleLapkin:const_from_ptr_range, r=oli-obk
compiler-errors May 30, 2022
26da780
Rollup merge of #97555 - GuillaumeGomez:line-number-click, r=notriddle
compiler-errors May 30, 2022
fd24358
Rollup merge of #97558 - stoeckmann:typos, r=compiler-errors
compiler-errors May 30, 2022
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
Prev Previous commit
Next Next commit
test forbidden slices on all two usizesizes
  • Loading branch information
WaffleLapkin committed May 30, 2022
commit 1f8a6410bf1f19a427429568e474d5f75c0ba1eb
280 changes: 280 additions & 0 deletions src/test/ui/const-ptr/forbidden_slices.32bit.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: null pointer is not a valid pointer
| inside `std::slice::from_raw_parts::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:17:34
|
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:17:34

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: null pointer is not a valid pointer
| inside `std::slice::from_raw_parts::<()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:18:33
|
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
| ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:18:33

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: alloc26 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:21:34
|
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:21:34

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:24:1
|
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>[0]: encountered uninitialized bytes
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾─alloc42─╼ 01 00 00 00 │ ╾──╼....
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:26:1
|
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>: encountered a pointer, but expected plain (non-pointer) bytes
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾─alloc55─╼ 04 00 00 00 │ ╾──╼....
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:28:1
|
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>[0]: encountered 0x11, but expected a boolean
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾─alloc65─╼ 04 00 00 00 │ ╾──╼....
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:31:1
|
LL | / pub static S7: &[u16] = unsafe {
LL | |
LL | | let ptr = (&D2 as *const Struct as *const u16).byte_add(1);
LL | |
LL | | from_raw_parts(ptr, 4)
LL | | };
| |__^ type validation failed: encountered an unaligned reference (required 2 byte alignment but found 1)
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾─a79+0x1─╼ 04 00 00 00 │ ╾──╼....
}

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: alloc96 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:42:5
|
LL | from_raw_parts(ptr, 1)
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:42:5

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| out-of-bounds offset_from: null pointer is not a valid pointer
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
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:45:34
|
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:45:34

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
| inside `ptr::const_ptr::<impl *const ()>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
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:46:33
|
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
| ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:46:33
|
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| pointer arithmetic failed: alloc154 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u32>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
...
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:49:25
|
LL | from_ptr_range(ptr..ptr.add(2))
| ---------- inside `R2` at $DIR/forbidden_slices.rs:49:25

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:51:1
|
LL | / pub static R4: &[u8] = unsafe {
LL | |
LL | | let ptr = (&D1) as *const MaybeUninit<&u32> as *const u8;
LL | | from_ptr_range(ptr..ptr.add(1))
LL | | };
| |__^ type validation failed at .<deref>[0]: encountered uninitialized bytes
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾alloc159─╼ 01 00 00 00 │ ╾──╼....
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:56:1
|
LL | / pub static R5: &[u8] = unsafe {
LL | |
LL | | let ptr = &D3 as *const &u32;
LL | | from_ptr_range(ptr.cast()..ptr.add(1).cast())
LL | | };
| |__^ type validation failed at .<deref>: encountered a pointer, but expected plain (non-pointer) bytes
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾alloc175─╼ 04 00 00 00 │ ╾──╼....
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:61:1
|
LL | / pub static R6: &[bool] = unsafe {
LL | |
LL | | let ptr = &D0 as *const u32 as *const bool;
LL | | from_ptr_range(ptr..ptr.add(4))
LL | | };
| |__^ type validation failed at .<deref>[0]: encountered 0x11, but expected a boolean
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾alloc191─╼ 04 00 00 00 │ ╾──╼....
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/forbidden_slices.rs:66:1
|
LL | / pub static R7: &[u16] = unsafe {
LL | |
LL | | let ptr = (&D2 as *const Struct as *const u16).byte_add(1);
LL | | from_ptr_range(ptr..ptr.add(4))
LL | | };
| |__^ type validation failed: encountered an unaligned reference (required 2 byte alignment but found 1)
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
╾a209+0x1─╼ 04 00 00 00 │ ╾──╼....
}

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| pointer arithmetic failed: alloc230 has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u64>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
...
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:73:25
|
LL | from_ptr_range(ptr..ptr.add(1))
| ---------- inside `R8` at $DIR/forbidden_slices.rs:73:25

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
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:78:34
|
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:78:34

error[E0080]: could not evaluate static initializer
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations.
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
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:35
|
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:79:35

error: aborting due to 18 previous errors

For more information about this error, try `rustc --explain E0080`.
Loading