Skip to content

Commit 24e172d

Browse files
Fast path for subtype and coercion goals
1 parent b3a417a commit 24e172d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler/rustc_trait_selection/src/solve/delegate.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
109109
_ => None,
110110
}
111111
}
112+
ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, .. })
113+
| ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
114+
if self.shallow_resolve(a).is_ty_var() && self.shallow_resolve(b).is_ty_var() {
115+
// FIXME: We also need to register a subtype relation between these vars
116+
// when those are added, and if they aren't in the same sub root then
117+
// we should mark this goal as `has_changed`.
118+
Some(Certainty::AMBIGUOUS)
119+
} else {
120+
None
121+
}
122+
}
112123
_ => None,
113124
}
114125
}

0 commit comments

Comments
 (0)