-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continue parsing after parent type args and suggest using angle brackets #57768
Conversation
src/librustc/hir/lowering.rs
Outdated
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.stderr
Outdated
Show resolved
Hide resolved
@estebank My only suggestion is, can we check if |
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 :) |
89e2825
to
2ab6cef
Compare
@bors r=zackmdavis |
📌 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