Skip to content

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

Closed
@nikomatsakis

Description

@nikomatsakis

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.

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-traitsWorking group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions