Code
fn foo() -> impl Sized {
*""
}
Current output
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:1:13
|
1 | fn foo() -> impl Sized {
| ^^^^^^^^^^ doesn't have a size known at compile-time
2 | *""
| --- return type was inferred to be `str` here
|
= help: the trait `Sized` is not implemented for `str`
Desired output
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:1:13
|
1 | fn foo() -> impl Sized {
| ^^^^^^^^^^ doesn't have a size known at compile-time
2 | *""
| --- return type was inferred to be `str` here
|
= help: the trait `Sized` is not implemented for `str`
help: remove the `*` dereference so the expression is of type `&str`, which is `Sized`
|
2 - *""
2 + ""
|
Rationale and extra context
The change is obvious when presented in isolation, but with a lot of diagnostics (and Sized errors can cause multiple knock-down errors) the problem gets hidden.
Other cases
No response
Rust Version
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
The change is obvious when presented in isolation, but with a lot of diagnostics (and
Sizederrors can cause multiple knock-down errors) the problem gets hidden.Other cases
No response
Rust Version
Anything else?
No response