Auto merge of #107303 - compiler-errors:intern-canonical-var-values, r=lcnr
Intern `CanonicalVarValues`
So that they are copy ✨
This commit is contained in:
commit
1e225413a2
7 changed files with 70 additions and 99 deletions
|
@ -13,14 +13,12 @@
|
|||
// preserves universes and creates a unique var (in the highest universe) for each
|
||||
// appearance of a region.
|
||||
|
||||
// FIXME: `CanonicalVarValues` should be interned and `Copy`.
|
||||
|
||||
// FIXME: uses of `infcx.at` need to enable deferred projection equality once that's implemented.
|
||||
|
||||
use std::mem;
|
||||
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues};
|
||||
use rustc_infer::infer::canonical::{Canonical, CanonicalVarValues};
|
||||
use rustc_infer::infer::canonical::{OriginalQueryValues, QueryRegionConstraints, QueryResponse};
|
||||
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
|
@ -225,7 +223,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||
let external_constraints = take_external_constraints(self.infcx)?;
|
||||
|
||||
Ok(self.infcx.canonicalize_response(Response {
|
||||
var_values: self.var_values.clone(),
|
||||
var_values: self.var_values,
|
||||
external_constraints,
|
||||
certainty,
|
||||
}))
|
||||
|
@ -483,32 +481,11 @@ pub(super) fn response_no_constraints<'tcx>(
|
|||
goal: Canonical<'tcx, impl Sized>,
|
||||
certainty: Certainty,
|
||||
) -> QueryResult<'tcx> {
|
||||
let var_values = goal
|
||||
.variables
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, info)| match info.kind {
|
||||
CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => {
|
||||
tcx.mk_ty(ty::Bound(ty::INNERMOST, ty::BoundVar::from_usize(i).into())).into()
|
||||
}
|
||||
CanonicalVarKind::Region(_) | CanonicalVarKind::PlaceholderRegion(_) => {
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(i),
|
||||
kind: ty::BrAnon(i as u32, None),
|
||||
};
|
||||
tcx.mk_region(ty::ReLateBound(ty::INNERMOST, br)).into()
|
||||
}
|
||||
CanonicalVarKind::Const(_, ty) | CanonicalVarKind::PlaceholderConst(_, ty) => tcx
|
||||
.mk_const(ty::ConstKind::Bound(ty::INNERMOST, ty::BoundVar::from_usize(i)), ty)
|
||||
.into(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(Canonical {
|
||||
max_universe: goal.max_universe,
|
||||
variables: goal.variables,
|
||||
value: Response {
|
||||
var_values: CanonicalVarValues { var_values },
|
||||
var_values: CanonicalVarValues::make_identity(tcx, goal.variables),
|
||||
external_constraints: Default::default(),
|
||||
certainty,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue