coerce documentation

This commit is contained in:
Bastian Kauschke 2020-04-11 10:23:33 +02:00
parent eece58a8e3
commit 01b3637f6e
2 changed files with 3 additions and 1 deletions

View File

@ -186,7 +186,6 @@ impl<'a, 'tcx> At<'a, 'tcx> {
impl<'a, 'tcx> Trace<'a, 'tcx> {
/// Makes `a <: b` where `a` may or may not be expected (if
/// `a_is_expected` is true, then `a` is expected).
/// Makes `expected <: actual`.
pub fn sub<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
where
T: Relate<'tcx>,

View File

@ -107,6 +107,7 @@ fn coerce_mutbls<'tcx>(
}
}
/// Do not require any adjustments, i.e. coerce `x -> x`.
fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> {
vec![]
}
@ -115,6 +116,7 @@ fn simple(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>
move |target| vec![Adjustment { kind, target }]
}
/// This always returns `Ok(...)`.
fn success<'tcx>(
adj: Vec<Adjustment<'tcx>>,
target: Ty<'tcx>,
@ -133,6 +135,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
}
pub fn unify(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
debug!("unify(a: {:?}, b: {:?}, use_lub: {})", a, b, self.use_lub);
self.commit_if_ok(|_| {
if self.use_lub {
self.at(&self.cause, self.fcx.param_env).lub(b, a)