summaryrefslogtreecommitdiff
path: root/compiler/rustc_middle/src/infer
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-01-14 04:46:23 +0000
committerMichael Goulet <michael@errs.io>2023-01-17 17:40:38 +0000
commit148e4f73dcc4bab82d0ad1689d2900e908133614 (patch)
tree3d9b50726c548d0d78cef9d03cb3d7cd452b7c31 /compiler/rustc_middle/src/infer
parent38a76f33220c4b9d13dda1fa8f6c629c8a7bcc5d (diff)
downloadrust-148e4f73dcc4bab82d0ad1689d2900e908133614.tar.gz
new trait solver: only consider goal changed if response is not identity
Diffstat (limited to 'compiler/rustc_middle/src/infer')
-rw-r--r--compiler/rustc_middle/src/infer/canonical.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs
index 614cf1a0051..7f3567c08be 100644
--- a/compiler/rustc_middle/src/infer/canonical.rs
+++ b/compiler/rustc_middle/src/infer/canonical.rs
@@ -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