Skip to content

Commit ea54255

Browse files
committed
Auto merge of #111221 - compiler-errors:yeet-generalizer, r=lcnr
Combine three generalizer implementations Fixes #111092 Fixes #109505 This code is a bit delicate and there were subtle changes between them, so I'll leave inline comments where further inspection is needed. Regarding this comment from #109813 -- "add tests triggering all codepaths: at least the combine and the const generalizer", can't really do that now, and I don't really know how we'd get a higher-ranked const error since non-lifetime binders doesn't *really* support `for<const ..>` (it errors out when you try to use it). r? `@lcnr`
2 parents ce5919f + a2678e1 commit ea54255

File tree

13 files changed

+627
-831
lines changed

13 files changed

+627
-831
lines changed

compiler/rustc_infer/src/infer/combine.rs

+40-546
Large diffs are not rendered by default.

compiler/rustc_infer/src/infer/equate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::infer::DefineOpaqueTypes;
22
use crate::traits::PredicateObligations;
33

4-
use super::combine::{CombineFields, ObligationEmittingRelation, RelationDir};
4+
use super::combine::{CombineFields, ObligationEmittingRelation};
55
use super::Subtype;
66

77
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
@@ -88,11 +88,11 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
8888
}
8989

9090
(&ty::Infer(TyVar(a_id)), _) => {
91-
self.fields.instantiate(b, RelationDir::EqTo, a_id, self.a_is_expected)?;
91+
self.fields.instantiate(b, ty::Invariant, a_id, self.a_is_expected)?;
9292
}
9393

9494
(_, &ty::Infer(TyVar(b_id))) => {
95-
self.fields.instantiate(a, RelationDir::EqTo, b_id, self.a_is_expected)?;
95+
self.fields.instantiate(a, ty::Invariant, b_id, self.a_is_expected)?;
9696
}
9797

9898
(

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
27232723
| (ty::Infer(ty::InferTy::TyVar(_)), _)
27242724
| (_, ty::Infer(ty::InferTy::TyVar(_))) => Ok(a),
27252725
(ty::Infer(_), _) | (_, ty::Infer(_)) => Err(TypeError::Mismatch),
2726-
_ => relate::super_relate_tys(self, a, b),
2726+
_ => relate::structurally_relate_tys(self, a, b),
27272727
}
27282728
}
27292729

0 commit comments

Comments
 (0)