Closed
Description
The following code
fn main() {
let x = *"";
println!("{}", x);
println!("{}", x);
}
Produces the following output:
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:2:9
|
2 | let 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/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:3:5
|
3 | println!("{}", 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/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required by `std::fmt::ArgumentV1::new`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:4:5
|
4 | println!("{}", 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/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required by `std::fmt::ArgumentV1::new`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 3 previous errors
The later two messages are not strictly necessary, since the unsized element being complained about is the same as the first one. Because of this, it should be unnecessary to complain about these as fixing the first problem fixes all three of them.