Skip to content
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

Improve and make missing dyn help suggestion more uniform #101689

Closed
Rageking8 opened this issue Sep 11, 2022 · 2 comments · Fixed by #101700
Closed

Improve and make missing dyn help suggestion more uniform #101689

Rageking8 opened this issue Sep 11, 2022 · 2 comments · Fixed by #101700
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Rageking8
Copy link
Contributor

Given the following code: link

trait A { }

impl A {

}

fn main() {

}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0782]](https://doc.rust-lang.org/nightly/error-index.html#E0782): trait objects must include the `dyn` keyword
 --> src/main.rs:3:6
  |
3 | impl A {
  |      ^
  |
help: add `dyn` keyword before this trait
  |
3 - impl A {
3 + impl dyn A {
  |

For more information about this error, try `rustc --explain E0782`.
error: could not compile `playground` due to previous error

Ideally the output should look like:

Compiling playground v0.0.1 (/playground)
error[[E0782]](https://doc.rust-lang.org/nightly/error-index.html#E0782): trait objects must include the `dyn` keyword
 --> src/main.rs:3:6
  |
3 | impl A {
  |      ^
  |
help: add `dyn` keyword before trait `A`
  |
3 | impl dyn A {
  |      +++

For more information about this error, try `rustc --explain E0782`.
error: could not compile `playground` due to previous error

Above changes: use a more common + convention for the help suggestion and make the target trait more explicit by mentioning it.


Since most of the other help suggestion that requires adding something uses the + convention, I think we should also change the above suggestion to use that convention to make things more uniform. On top of that the new proposed output is less verbose as it reduces 1 line of output.


Note: If the old "diff" convention for the help suggestion is intentional, please let me know the reason and I will gladly close this issue. Thanks.

@Rageking8 Rageking8 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 11, 2022
@compiler-errors
Copy link
Member

This is a bug in the rendering code!

@Rageking8
Copy link
Contributor Author

Rageking8 commented Sep 12, 2022

This is a bug in the rendering code!

Oh, I didn't know that, thought it was the old rendering convention. Haha.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2022
…avidtwco

A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing

Fixes rust-lang#101689
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2022
…avidtwco

A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing

Fixes rust-lang#101689
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 13, 2022
…avidtwco

A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing

Fixes rust-lang#101689
@bors bors closed this as completed in adcd1fb Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
2 participants