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

Invalid suggestion for missing lifetime specifier #75040

Closed
yvt opened this issue Aug 2, 2020 · 1 comment
Closed

Invalid suggestion for missing lifetime specifier #75040

yvt opened this issue Aug 2, 2020 · 1 comment
Labels
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

@yvt
Copy link
Contributor

yvt commented Aug 2, 2020

I tried this code:

trait Tr {
    const A: &u32;
}

I expected to see this happen: Compilation failure with reasonable diagnosis

Instead, this happened: The compiler suggested adding <'a> before trait, which is syntactically invalid.

error[E0106]: missing lifetime specifier
 --> src/lib.rs:2:14
  |
2 |     const A: &u32;
  |              ^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
1 | <'a>trait Tr {
2 |     const A: &'a u32;
  |

error: aborting due to previous error

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (0c03aee8b 2020-07-05)
binary: rustc
commit-hash: 0c03aee8b81185d65b5821518661c30ecdb42de5
commit-date: 2020-07-05
host: x86_64-apple-darwin
release: 1.46.0-nightly
LLVM version: 10.0
@yvt yvt added the C-bug Category: This is a bug. label Aug 2, 2020
@jonas-schievink jonas-schievink added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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. labels Aug 2, 2020
@SNCPlay42
Copy link
Contributor

Duplicate of #74264

@yvt yvt closed this as completed Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

No branches or pull requests

3 participants