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

unused param error mentions incorrect param if there's a misplaced lt param #83556

Closed
lcnr opened this issue Mar 27, 2021 · 0 comments · Fixed by #116045
Closed

unused param error mentions incorrect param if there's a misplaced lt param #83556

lcnr opened this issue Mar 27, 2021 · 0 comments · Fixed by #116045
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Mar 27, 2021

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f6aaeef90ca703dffc311e3829186005

struct Foo<T, 'a>(&'a ());

causes the following error:

error: lifetime parameters must be declared prior to type parameters
 --> src/lib.rs:1:15
  |
1 | struct Foo<T, 'a>(&'a ());
  |           ----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T>`

error[E0392]: parameter `'a` is never used
 --> src/lib.rs:1:15
  |
1 | struct Foo<T, 'a>(&'a ());
  |               ^^ unused parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

it should be "parameter T is never used"

@lcnr lcnr added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Mar 27, 2021
@JohnTitor JohnTitor added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 29, 2021
notriddle added a commit to notriddle/rust that referenced this issue Sep 22, 2023
@notriddle notriddle self-assigned this Sep 23, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 23, 2023
…jgillot

diagnostics: avoid mismatch between variance index and hir generic

This happens because variances are constructed from ty generics, and ty generics are always constructed with lifetimes first.

https://github.com/rust-lang/rust/blob/b3aa8e7168a3d940122db3561289ffbf3f587262/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L248-L269

Fixes rust-lang#83556
@bors bors closed this as completed in 3799af3 Sep 23, 2023
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 C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. 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