Skip to content

Commit

Permalink
Add comments for deref_steps()
Browse files Browse the repository at this point in the history
  • Loading branch information
ldm0 committed May 2, 2020
1 parent 60d62be commit 80d04cc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_typeck/check/coercion.rs
Expand Up @@ -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<usize> {
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
Expand Down

0 comments on commit 80d04cc

Please sign in to comment.