Open jplatte opened 3 years ago
It becomes useful as soon as the struct has a type parameter, so I'm not sure if we want to introduce special handling just for this case.
Special handling for when the type has type (or consts) generics should be easy though, no?
Also, that would still repeat the type name needlessly. A turbofish hint would be an interesting alternative, i.e.
// what the user wrote
let foobar = FooBar { field };
// current type hint
let foobar: FooBar<BazQux> = FooBar { field };
// turbofish hint
let foobar = FooBar::<BazQux> { field };
Since #10761 did the same thing for constructor functions, it seems like most of the infrastructure for detecting cases like this is already in place. Can this be labeled S-actionable
?
A type hint on a variable that is simply
let
-bound to a struct literal seems rather pointless:See also #3796, which was about chaining type hints for struct literals.