Closed
Description
openedon Jul 25, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.