Closed
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.