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

loss of implied bounds after normalization #106567

Closed
aliemjay opened this issue Jan 7, 2023 · 1 comment · Fixed by #107376 or #109629
Closed

loss of implied bounds after normalization #106567

aliemjay opened this issue Jan 7, 2023 · 1 comment · Fixed by #107376 or #109629
Labels
A-implied-bounds Area: Implied bounds / inferred outlives-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:

trait Identity { type Ty; }
impl<'a, 'b> Identity for &'a &'b () { type Ty = &'a &'b (); }
fn test<'a, 'b>(_: <&'a &'b () as Identity>::Ty) {}
//~^ ERROR lifetime mismatch

It does pass if the impl is changed to

impl<T> Identity for T { type Ty = T; }

The issue here is that when we try to normalize <&'a &'b () as Identity>::Ty, the result is &'?1 &'?2 (), where ['?1, '?2] are new region variables that are unified with ['a, 'b], respectively. However, when we try to compute the implied bounds after normalization, we get '?2: '?1 instead of the desired bound 'b: 'a.

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

@rustbot rustbot added A-implied-bounds Area: Implied bounds / inferred outlives-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
@bors bors closed this as completed in e84e5ff Mar 15, 2023
@aliemjay
Copy link
Member Author

The PR was reverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-implied-bounds Area: Implied bounds / inferred outlives-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
2 participants