introduce new fallback algorithm

We now fallback type variables using the following rules:

* Construct a coercion graph `A -> B` where `A` and `B` are unresolved
  type variables or the `!` type.
* Let D be those variables that are reachable from `!`.
* Let N be those variables that are reachable from a variable not in
D.
* All variables in (D \ N) fallback to `!`.
* All variables in (D & N) fallback to `()`.
This commit is contained in:
Niko Matsakis
2020-11-22 09:58:58 -05:00
committed by Mark Rousskov
parent e0c38af27c
commit 2ee89144e2
7 changed files with 347 additions and 55 deletions

View File

@@ -1672,6 +1672,14 @@ impl<'tcx> TyS<'tcx> {
matches!(self.kind(), Infer(TyVar(_)))
}
#[inline]
pub fn ty_vid(&self) -> Option<ty::TyVid> {
match self.kind() {
&Infer(TyVar(vid)) => Some(vid),
_ => None,
}
}
#[inline]
pub fn is_ty_infer(&self) -> bool {
matches!(self.kind(), Infer(_))