From 871a1e1cf8e58c51416954d3afac5d681a3d27eb Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sun, 21 Feb 2016 18:56:35 +0200 Subject: [PATCH] typeck: rename mk_assignty to coercion::try. --- src/librustc_typeck/check/cast.rs | 11 ++--------- src/librustc_typeck/check/coercion.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 7168873c1b8..08766566323 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -239,7 +239,7 @@ impl<'tcx> CastCheck<'tcx> { (None, Some(t_cast)) => { if let ty::TyFnDef(_, _, f) = self.expr_ty.sty { // Attempt a coercion to a fn pointer type. - let res = coercion::mk_assignty(fcx, &self.expr, + let res = coercion::try(fcx, &self.expr, self.expr_ty, fcx.tcx().mk_ty(ty::TyFnPtr(f))); if !res.is_ok() { return Err(CastError::NonScalar); @@ -390,14 +390,7 @@ impl<'tcx> CastCheck<'tcx> { } fn try_coercion_cast<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> bool { - if let Ok(()) = coercion::mk_assignty(fcx, - &self.expr, - self.expr_ty, - self.cast_ty) { - true - } else { - false - } + coercion::try(fcx, &self.expr, self.expr_ty, self.cast_ty).is_ok() } } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index f9bffa7391d..65ef2113214 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -435,12 +435,12 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { } } -pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, - expr: &hir::Expr, - a: Ty<'tcx>, - b: Ty<'tcx>) - -> RelateResult<'tcx, ()> { - debug!("mk_assignty({:?} -> {:?})", a, b); +pub fn try<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, + expr: &hir::Expr, + a: Ty<'tcx>, + b: Ty<'tcx>) + -> RelateResult<'tcx, ()> { + debug!("coercion::try({:?} -> {:?})", a, b); let mut unsizing_obligations = vec![]; let adjustment = try!(indent(|| { fcx.infcx().commit_if_ok(|_| {