-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. See compiler/rustc_hir_analysis/src/collect/generics_of.rs:248-269 Fixes #83556
- Loading branch information
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
struct Foo<T, 'a>(&'a ()); | ||
//~^ ERROR lifetime parameters must be declared prior to | ||
//~| ERROR parameter `T` is never used | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error: lifetime parameters must be declared prior to type and const parameters | ||
--> $DIR/issue-83556.rs:1:15 | ||
| | ||
LL | struct Foo<T, 'a>(&'a ()); | ||
| ----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T>` | ||
|
||
error[E0392]: parameter `T` is never used | ||
--> $DIR/issue-83556.rs:1:12 | ||
| | ||
LL | struct Foo<T, 'a>(&'a ()); | ||
| ^ unused parameter | ||
| | ||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` | ||
= help: if you intended `T` to be a const parameter, use `const T: usize` instead | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0392`. |