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

Associated type not resolved based on lifetimes #87208

Open
programmerjake opened this issue Jul 17, 2021 · 2 comments
Open

Associated type not resolved based on lifetimes #87208

programmerjake opened this issue Jul 17, 2021 · 2 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) 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

@programmerjake
Copy link
Member

I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d9dd02dbc642c719d6a984f0e4dd91fb

pub trait Trait<'a> {
    type Type;
}

pub fn f<'a, 'b, T: Trait<'a> + Trait<'b>>(v: <T as Trait<'a>>::Type) {
    
}

I expected to see this happen: compile without errors.

Instead, this happened:

   Compiling playground v0.0.1 (/playground)
error[E0284]: type annotations needed: cannot satisfy `<T as Trait<'a>>::Type == _`
 --> src/lib.rs:5:1
  |
5 | / pub fn f<'a, 'b, T: Trait<'a> + Trait<'b>>(v: <T as Trait<'a>>::Type) {
6 | |     
7 | | }
  | |_^ cannot satisfy `<T as Trait<'a>>::Type == _`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0284`.
error: could not compile `playground`

To learn more, run the command again with --verbose.

related: https://users.rust-lang.org/t/compile-failing-even-though-it-seems-like-it-should-work/62409?u=programmerjake

@programmerjake programmerjake added the C-bug Category: This is a bug. label Jul 17, 2021
@jackh726
Copy link
Member

Possibly fixed by #85499 (but is the same cause)

@inquisitivecrystal inquisitivecrystal added A-associated-items Area: Associated items (types, constants & functions) A-lifetimes Area: Lifetimes / regions T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 17, 2021
@BGR360
Copy link
Contributor

BGR360 commented Dec 23, 2021

Could it be related to this old gem? #21974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) 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

4 participants