If I do ...
fn main() {
let x = "hello";
let y = Box::new(*x);
}
I get the following error ...
--> src/main.rs:3:13
|
3 | let y = Box::new(*x);
| ^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required by `std::boxed::Box::<T>::new`
I think the right error should be ...
--> src/main.rs:3:13
|
3 | let y = Box::new(*x);
| ^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required by `std::boxed::Box::<T>::new`
Is not that Box is not Sized, the problem is that the parameter of the Box's new function is not Sized. So the last note in the error is important and also kind of lost in a lot of noise.
Possibly related to #61860.
If I do ...
I get the following error ...
I think the right error should be ...
Is not that
Boxis notSized, the problem is that the parameter of theBox'snewfunction is notSized. So the last note in the error is important and also kind of lost in a lot of noise.Possibly related to #61860.