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
|
@ -26,7 +26,7 @@ use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVari
|
|||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::subst::GenericArg;
|
||||
use rustc_middle::ty::{self, BoundVar, List};
|
||||
use rustc_middle::ty::{self, List};
|
||||
use rustc_span::source_map::Span;
|
||||
|
||||
pub use rustc_middle::infer::canonical::*;
|
||||
|
@ -87,12 +87,13 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
variables: &List<CanonicalVarInfo<'tcx>>,
|
||||
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
|
||||
) -> CanonicalVarValues<'tcx> {
|
||||
let var_values: IndexVec<BoundVar, GenericArg<'tcx>> = variables
|
||||
.iter()
|
||||
.map(|info| self.instantiate_canonical_var(span, info, &universe_map))
|
||||
.collect();
|
||||
|
||||
CanonicalVarValues { var_values }
|
||||
CanonicalVarValues {
|
||||
var_values: self.tcx.mk_substs(
|
||||
variables
|
||||
.iter()
|
||||
.map(|info| self.instantiate_canonical_var(span, info, &universe_map)),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Given the "info" about a canonical variable, creates a fresh
|
||||
|
|
|
@ -482,11 +482,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
// given variable in the loop above, use that. Otherwise, use
|
||||
// a fresh inference variable.
|
||||
let result_subst = CanonicalVarValues {
|
||||
var_values: query_response
|
||||
.variables
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, info)| {
|
||||
var_values: self.tcx.mk_substs(query_response.variables.iter().enumerate().map(
|
||||
|(index, info)| {
|
||||
if info.is_existential() {
|
||||
match opt_values[BoundVar::new(index)] {
|
||||
Some(k) => k,
|
||||
|
@ -499,8 +496,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
universe_map[u.as_usize()]
|
||||
})
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
)),
|
||||
};
|
||||
|
||||
let mut obligations = vec![];
|
||||
|
|
|
@ -72,16 +72,15 @@ where
|
|||
value
|
||||
} else {
|
||||
let delegate = FnMutDelegate {
|
||||
regions: &mut |br: ty::BoundRegion| match var_values.var_values[br.var].unpack() {
|
||||
regions: &mut |br: ty::BoundRegion| match var_values[br.var].unpack() {
|
||||
GenericArgKind::Lifetime(l) => l,
|
||||
r => bug!("{:?} is a region but value is {:?}", br, r),
|
||||
},
|
||||
types: &mut |bound_ty: ty::BoundTy| match var_values.var_values[bound_ty.var].unpack() {
|
||||
types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].unpack() {
|
||||
GenericArgKind::Type(ty) => ty,
|
||||
r => bug!("{:?} is a type but value is {:?}", bound_ty, r),
|
||||
},
|
||||
consts: &mut |bound_ct: ty::BoundVar, _| match var_values.var_values[bound_ct].unpack()
|
||||
{
|
||||
consts: &mut |bound_ct: ty::BoundVar, _| match var_values[bound_ct].unpack() {
|
||||
GenericArgKind::Const(ct) => ct,
|
||||
c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue