Forbid non-derefable types explicitly in unsizing casts
This commit is contained in:
parent
40857b9453
commit
cd7204ef39
3 changed files with 31 additions and 1 deletions
10
src/test/ui/consts/unsizing-cast-non-null.rs
Normal file
10
src/test/ui/consts/unsizing-cast-non-null.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Regression test for #75118.
|
||||
|
||||
use std::ptr::NonNull;
|
||||
|
||||
pub const fn dangling_slice<T>() -> NonNull<[T]> {
|
||||
NonNull::<[T; 0]>::dangling()
|
||||
//~^ ERROR: unsizing casts are only allowed for references right now
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
12
src/test/ui/consts/unsizing-cast-non-null.stderr
Normal file
12
src/test/ui/consts/unsizing-cast-non-null.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0723]: unsizing casts are only allowed for references right now
|
||||
--> $DIR/unsizing-cast-non-null.rs:6:5
|
||||
|
|
||||
LL | NonNull::<[T; 0]>::dangling()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0723`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue