Skip to content

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

Closed
@oli-obk

Description

@oli-obk

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.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions