From 80d04cc1ba610d796c84427622ce17eb2ca9c771 Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Fri, 1 May 2020 21:56:10 +0800 Subject: [PATCH] Add comments for deref_steps() --- src/librustc_typeck/check/coercion.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index c336ec134794..7437c87a2576 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -831,6 +831,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.probe(|_| coerce.coerce(source, target)).is_ok() } + /// Given a type and a target type, this function will calculate and return + /// how many dereference steps needed to achieve `expr_ty <: target`. If + /// it's not possible, return `None`. pub fn deref_steps(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> Option { let cause = self.cause(rustc_span::DUMMY_SP, ObligationCauseCode::ExprAssignable); // We don't ever need two-phase here since we throw out the result of the coercion