-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
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:
rust/src/librustc_traits/chalk_context.rs
Lines 473 to 482 in 4f9b581
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:
rust/src/librustc_traits/chalk_context.rs
Lines 445 to 450 in 4f9b581
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.