pub(in solve) fn instantiate_canonical_state<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
    infcx: &InferCtxt<'tcx>,
    span: Span,
    param_env: ParamEnv<'tcx>,
    orig_values: &mut Vec<GenericArg<'tcx>>,
    state: CanonicalState<TyCtxt<'tcx>, T>,
) -> T
Expand description

Instantiate a CanonicalState.

Unlike for query responses, CanonicalState also track fresh inference variables created while evaluating a goal. When creating two separate CanonicalState during a single evaluation both may reference this fresh inference variable. When instantiating them we now create separate inference variables for it and have to unify them somehow. We do this by extending the var_values while building the proof tree.

This currently assumes that unifying the var values trivially succeeds. Adding any inference constraints which weren’t present when originally computing the canonical query can result in bugs.