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

Suggestion diagnostic for new generic argument is placed at beginning of file #74264

Closed
oli-obk opened this issue Jul 12, 2020 · 0 comments · Fixed by #75372
Closed

Suggestion diagnostic for new generic argument is placed at beginning of file #74264

oli-obk opened this issue Jul 12, 2020 · 0 comments · Fixed by #75372
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jul 12, 2020

The suggestion to change &str to &'a str and give ZstAssert a <'a> generic argument places the <'a> at the beginning of the file. If you add any items before the trait decl, the suggestion will be before those unrelated items.

trait ZstAssert: Sized {
    const TYPE_NAME: &str = "";
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0106]: missing lifetime specifier
 --> src/lib.rs:2:22
  |
2 |     const TYPE_NAME: &str = "";
  |                      ^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
1 | <'a>trait ZstAssert: Sized {
2 |     const TYPE_NAME: &'a str = "";
  |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0106`.
error: could not compile `playground`.

To learn more, run the command again with --verbose.

@oli-obk oli-obk added C-bug Category: This is a bug. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Jul 12, 2020
@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 12, 2020
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Jul 13, 2020
@estebank estebank self-assigned this Aug 10, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Aug 13, 2020
Fix suggestion to use lifetime in type and in assoc const

_Do not merge until rust-lang#75363 has landed, as it has the test case for this._

* Account for associated types
* Associated `const`s can't have generics (fix rust-lang#74264)
* Do not suggest duplicate lifetimes and suggest `for<'a>` more (fix rust-lang#72404)
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 13, 2020
Fix suggestion to use lifetime in type and in assoc const

_Do not merge until rust-lang#75363 has landed, as it has the test case for this._

* Account for associated types
* Associated `const`s can't have generics (fix rust-lang#74264)
* Do not suggest duplicate lifetimes and suggest `for<'a>` more (fix rust-lang#72404)
@bors bors closed this as completed in 7956b1c Aug 13, 2020
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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants