Skip to content

Commit 871a1e1

Browse files
committed
typeck: rename mk_assignty to coercion::try.
1 parent 2b1bd80 commit 871a1e1

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/librustc_typeck/check/cast.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'tcx> CastCheck<'tcx> {
239239
(None, Some(t_cast)) => {
240240
if let ty::TyFnDef(_, _, f) = self.expr_ty.sty {
241241
// Attempt a coercion to a fn pointer type.
242-
let res = coercion::mk_assignty(fcx, &self.expr,
242+
let res = coercion::try(fcx, &self.expr,
243243
self.expr_ty, fcx.tcx().mk_ty(ty::TyFnPtr(f)));
244244
if !res.is_ok() {
245245
return Err(CastError::NonScalar);
@@ -390,14 +390,7 @@ impl<'tcx> CastCheck<'tcx> {
390390
}
391391

392392
fn try_coercion_cast<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> bool {
393-
if let Ok(()) = coercion::mk_assignty(fcx,
394-
&self.expr,
395-
self.expr_ty,
396-
self.cast_ty) {
397-
true
398-
} else {
399-
false
400-
}
393+
coercion::try(fcx, &self.expr, self.expr_ty, self.cast_ty).is_ok()
401394
}
402395

403396
}

src/librustc_typeck/check/coercion.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,12 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
435435
}
436436
}
437437

438-
pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
439-
expr: &hir::Expr,
440-
a: Ty<'tcx>,
441-
b: Ty<'tcx>)
442-
-> RelateResult<'tcx, ()> {
443-
debug!("mk_assignty({:?} -> {:?})", a, b);
438+
pub fn try<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
439+
expr: &hir::Expr,
440+
a: Ty<'tcx>,
441+
b: Ty<'tcx>)
442+
-> RelateResult<'tcx, ()> {
443+
debug!("coercion::try({:?} -> {:?})", a, b);
444444
let mut unsizing_obligations = vec![];
445445
let adjustment = try!(indent(|| {
446446
fcx.infcx().commit_if_ok(|_| {

0 commit comments

Comments
 (0)