-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given
struct Foo(());
fn bar(x: Foo) -> Foo {
Foo(0: x.0 as _)
}
The output contains this suggestion, among others
error: casts cannot be followed by a field access
--> src/lib.rs:4:9
|
4 | Foo(0: x.0 as _)
| ^^^^
|
help: try surrounding the expression in parentheses
|
4 | Foo((0: x).0 as _)
| + +
help: alternatively, remove the type ascription
|
4 - Foo(0: x.0 as _)
4 + Foo(0.0 as _)
|
Both the initial error message and the recommendation are confusing. Ideally we should recommend removing 0:
since tuple structs do not use field initializers.
estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.