Trying to compile this code
pub fn bogus_ptr<U: ?Sized>() -> *const U {
0usize as *const U
}
produces this error message
error[E0606]: casting `usize` as `*const U` is invalid
--> <source>:2:5
|
2 | 0usize as *const U
| ^^^^^^^^^^^^^^^^^^
It would be better if the error message stated that usize cannot be cast to a pointer to a ?Sized type because it's potentially unsized.
Meta
Tried the code in these Rust versions and they all produced the same error message:
Trying to compile this code
produces this error message
It would be better if the error message stated that
usizecannot be cast to a pointer to a?Sizedtype because it's potentially unsized.Meta
Tried the code in these Rust versions and they all produced the same error message:
1.37.0 stable
1.45.0 stable
1.46.0-beta.1 (2020-07-15 e51b714)
1.47.0-nightly (2020-07-22 bbebe73)