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

implied bounds: lifetime equality lost after normalization #106569

Open
aliemjay opened this issue Jan 7, 2023 · 1 comment
Open

implied bounds: lifetime equality lost after normalization #106569

aliemjay opened this issue Jan 7, 2023 · 1 comment
Labels
A-implied-bounds Area: Related to implied bounds C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@aliemjay
Copy link
Member

aliemjay commented Jan 7, 2023

This doesn't compile although it should

struct Equal<'a, 'b>(&'a &'b (), &'b &'a ()); // implies 'a == 'b
trait Trait { type Ty; }
impl<'x> Trait for Equal<'x, 'x> { type Ty = (); }
fn test<'a, 'b>(_: (<Equal<'a, 'b> as Trait>::Ty, Equal<'a, 'b>)) {}
//~^ ERROR lifetime may not live long enough

It compiles with this trivial change:

- fn test<'a, 'b>(_: (<Equal<'a, 'b> as Trait>::Ty, Equal<'a, 'b>)) {}
+ fn test<'a, 'b>(_: <Equal<'a, 'b> as Trait>::Ty, _: Equal<'a, 'b>) {}

@rustbot label C-bug T-types A-implied-bounds

@rustbot rustbot added A-implied-bounds Area: Related to implied bounds C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. labels Jan 7, 2023
@Caellian
Copy link

Caellian commented Jan 5, 2024

I had a somewhat similar issue, though my use case is even simpler as it involves only a single lifetime. Just the fact that the trait is implemented for SomeType<'a> causes issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-implied-bounds Area: Related to implied bounds C-bug Category: This is a bug. T-types Relevant to the types 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