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

"type annotations needed" when duplicated where-clauses use different lifetime parameters #77052

Closed
jonas-schievink opened this issue Sep 22, 2020 · 1 comment
Labels
A-inference Area: Type inference A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jonas-schievink
Copy link
Contributor

The following code should compile, but it seems to confuse the compiler and results in a very poor error message:

fn f<'a, 'b, T>()
where
    &'a T: Copy,
    &'b T: Copy,
{
}
error[E0283]: type annotations needed
   --> src/lib.rs:3:12
    |
3   |       &'a T: Copy,
    |              ^^^^ cannot infer type for reference `&'a T`
    |
    = note: cannot satisfy `&'a T: std::marker::Copy`

There should not be any type inference happening in the where-clause, so getting this error is fairly absurd.

Same thing happens with other traits than Copy, and also with concrete types like () instead of a type parameter T.

@jonas-schievink jonas-schievink added A-lifetimes Area: Lifetimes / regions T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-inference Area: Type inference C-bug Category: This is a bug. labels Sep 22, 2020
@jonas-schievink
Copy link
Contributor Author

Duplicate of #34979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. 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

1 participant