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

implement "lifetime juggling" methods from chalk integration trait #55097

Closed
nikomatsakis opened this issue Oct 15, 2018 · 4 comments
Closed
Assignees
Labels
A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Oct 15, 2018

The chalk integration trait includes a few methods whose job is to do "lifetime juggling", in terms of converting values between the "type inference" arena lifetime ('tcx) and the "global arena" lifetime ('gcx) (see the rustc guide for more details about these lifetimes, if you are not familiar with them).

Case 1 is the LiftExClause trait:

impl ExClauseLift<'gcx> for ChalkArenas<'a> {
type LiftedExClause = ChalkExClause<'gcx>;
fn lift_ex_clause_to_tcx(
_ex_clause: &ChalkExClause<'a>,
_tcx: TyCtxt<'_, '_, 'tcx>,
) -> Option<Self::LiftedExClause> {
panic!()
}
}

This trait exists for coherence reasons -- on the one hand, the ExClause type is defined in chalk. The Lift trait is defined in rustc. Therefore, the impl of Lift for ExClause has to be in librustc -- but librustc doesn't know enough to do the implementation. So we add an auxiliary trait that is implemented over in librustc_traits. And this is the impl!

We need to implement the fn body here. It's probably just a matter of invoking tcx.lift_to_global, but I'm not sure.

For this case, we probably just need to invoke tcx.lift_to_global(value) -- but we may need to add some impls of Lift for the DelayedLiteral type.

Case 2 is the lift_delayed_literal method:

fn lift_delayed_literal(
&self,
_value: DelayedLiteral<ChalkArenas<'tcx>>,
) -> DelayedLiteral<ChalkArenas<'gcx>> {
panic!("lift")
}

This probably needs an "auxiliary" trait like LiftExClause above, for the same reason.

@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 chalk-integration A-traits Area: Trait system labels Oct 15, 2018
@nikomatsakis
Copy link
Contributor Author

Mentoring instructions

To start, it's a good idea to read the rustc guide chapter on the tcx and how it uses lifetimes.

I will try to write up some docs on the Lift impls.

@nikomatsakis
Copy link
Contributor Author

(@uberjay is interested in working on this)

@nikomatsakis
Copy link
Contributor Author

Created a Zulip topic

@nikomatsakis
Copy link
Contributor Author

Removing @uberjay since they mentioned they'll be pretty busy for the next little while.

@scalexm scalexm self-assigned this Nov 23, 2018
@bors bors closed this as completed in 69007bd Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804
Projects
None yet
Development

No branches or pull requests

3 participants