-
Notifications
You must be signed in to change notification settings - Fork 13.4k
More helpful output for slightly-wrong dyn with multiple traits. #84772
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The lexing & parsing of Rust source code to an AST
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
P-low
Low priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this issue
May 5, 2021
Handle incorrect placement of parentheses in trait bounds more gracefully Fix rust-lang#84772. CC `@jonhoo`
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this issue
May 5, 2021
Handle incorrect placement of parentheses in trait bounds more gracefully Fix rust-lang#84772. CC ``@jonhoo``
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
May 6, 2021
Handle incorrect placement of parentheses in trait bounds more gracefully Fix rust-lang#84772. CC ```@jonhoo```
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
May 6, 2021
Handle incorrect placement of parentheses in trait bounds more gracefully Fix rust-lang#84772. CC ````@jonhoo````
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
May 6, 2021
Handle incorrect placement of parentheses in trait bounds more gracefully Fix rust-lang#84772. CC `````@jonhoo`````
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
May 6, 2021
Handle incorrect placement of parentheses in trait bounds more gracefully Fix rust-lang#84772. CC ``````@jonhoo``````
Reopening and keeping around for a single unhandled case left: |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The lexing & parsing of Rust source code to an AST
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
P-low
Low priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I recently tried to demonstrate why
dyn Trait1 + Trait2
doesn't work. I ended up writing (all examples below on playground):and because I was in my editor, I only saw the first part of the error: "ambiguous
+
in a type". As a result, rather than follow the helpful compiler errorI went ahead and tried to fix the syntax myself. Unfortunately, those only gave me worse error messages. I tried:
which gives
I tried:
Which gives
This one is particularly egregious as it suggests there's a missing
,
.I tried:
Which gives
I tried:
Which gives
This one is even more problematic as it not only suggests there's a missing
,
, but also suggests thatdyn Drop
is the problem.Ideally, all of these cases should point out that I probably meant
&(dyn Drop + AsRef<str>)
, and also give the friendly "only auto traits can be used as additional traits in a trait object" message.The error messages are (currently) all the same on nightly.
See also discussion on Twitter.
The text was updated successfully, but these errors were encountered: