new trait solver: only consider goal changed if response is not identity

This commit is contained in:
Michael Goulet
2023-01-14 04:46:23 +00:00
parent 38a76f3322
commit 148e4f73dc
2 changed files with 17 additions and 1 deletions

View File

@@ -68,6 +68,22 @@ pub struct CanonicalVarValues<'tcx> {
pub var_values: IndexVec<BoundVar, GenericArg<'tcx>>,
}
impl CanonicalVarValues<'_> {
pub fn is_identity(&self) -> bool {
self.var_values.iter_enumerated().all(|(bv, arg)| match arg.unpack() {
ty::GenericArgKind::Lifetime(r) => {
matches!(*r, ty::ReLateBound(ty::INNERMOST, br) if br.var == bv)
}
ty::GenericArgKind::Type(ty) => {
matches!(*ty.kind(), ty::Bound(ty::INNERMOST, bt) if bt.var == bv)
}
ty::GenericArgKind::Const(ct) => {
matches!(ct.kind(), ty::ConstKind::Bound(ty::INNERMOST, bc) if bc == bv)
}
})
}
}
/// When we canonicalize a value to form a query, we wind up replacing
/// various parts of it with canonical variables. This struct stores
/// those replaced bits to remember for when we process the query