Uh oh!
There was an error while loading. Please reload this page.
Continue parsing after parent type args and suggest using angle brackets - #57768
Conversation
| .emit(); | ||
| (hir::GenericArgs::none(), true) | ||
| let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg); | ||
| err.span_label(data.span, "only traits may use parentheses"); |
There was a problem hiding this comment.
No time to dig into it now, but I'm mildly curious about the history of this rule. Offhand, I don't seem to recall seeing traits use parentheses for type argum—oh, never mind, I just read --explain 214, and it points out that it's for Fn(T) types.
This does seem sufficiently remote from the crux of the error at hand that we might want to reword the top-line error message to emphasize "parameters use brackets, generally" rather than highlighting the unusual case of traits? I don't have a crisp alternative wording to propose at the moment, though.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
zackmdavis
commented
Jan 20, 2019
@estebank My only suggestion is, can we check if |
estebank
commented
Jan 20, 2019
It makes sense to do so and should be easy enough to add.
I feel this is already quite a rare case to begin with, we might as well do it right :) |
estebank
commented
Jan 20, 2019
@bors r=zackmdavis |
bors
commented
Jan 20, 2019
📌 Commit 2ab6cef has been approved by |
Continue parsing after parent type args and suggest using angle brackets ``` error[E0214]: parenthesized parameters may only be used with a trait --> $DIR/E0214.rs:2:15 | LL | let v: Vec(&str) = vec!["foo"]; | ^^^^^^ | | | only traits may use parentheses | help: use angle brackets instead: `<&str>` ``` r? @zackmdavis
Rollup of 5 pull requests Successful merges: - #56796 (Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`) - #57768 (Continue parsing after parent type args and suggest using angle brackets) - #57769 (Suggest correct cast for struct fields with shorthand syntax) - #57783 (Add "dereference boxed value" suggestion.) - #57784 (Add span for bad doc comment) Failed merges: r? @ghost
r? @zackmdavis