Skip to content

Commit 9899464

Browse files
Fast path for subtype and coercion goals
1 parent 3418d5d commit 9899464

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
@@ -125,6 +125,17 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
125125

126126
Some(Certainty::Yes)
127127
}
128+
ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, .. })
129+
| ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
130+
if self.shallow_resolve(a).is_ty_var() && self.shallow_resolve(b).is_ty_var() {
131+
// FIXME: We also need to register a subtype relation between these vars
132+
// when those are added, and if they aren't in the same sub root then
133+
// we should mark this goal as `has_changed`.
134+
Some(Certainty::AMBIGUOUS)
135+
} else {
136+
None
137+
}
138+
}
128139
_ => None,
129140
}
130141
}

0 commit comments

Comments
 (0)