Skip to content

Commit dbab236

Browse files
committed
typeck: Remove Coerce::unpack_actual_value.
1 parent dc37664 commit dbab236

File tree

1 file changed

+20
-30
lines changed

1 file changed

+20
-30
lines changed

src/librustc_typeck/check/coercion.rs

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
9696
Ok(None) // No coercion required.
9797
}
9898

99-
fn unpack_actual_value<T, F>(&self, a: Ty<'tcx>, f: F) -> T where
100-
F: FnOnce(Ty<'tcx>) -> T,
101-
{
102-
f(self.fcx.infcx().shallow_resolve(a))
103-
}
104-
10599
fn coerce(&self,
106100
expr_a: &hir::Expr,
107101
a: Ty<'tcx>,
@@ -353,22 +347,20 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
353347
* into a closure or a `proc`.
354348
*/
355349

356-
self.unpack_actual_value(b, |b| {
357-
debug!("coerce_from_fn_pointer(a={:?}, b={:?})",
358-
a, b);
350+
let b = self.fcx.infcx().shallow_resolve(b);
351+
debug!("coerce_from_fn_pointer(a={:?}, b={:?})", a, b);
359352

360-
if let ty::TyFnPtr(fn_ty_b) = b.sty {
361-
match (fn_ty_a.unsafety, fn_ty_b.unsafety) {
362-
(hir::Unsafety::Normal, hir::Unsafety::Unsafe) => {
363-
let unsafe_a = self.tcx().safe_to_unsafe_fn_ty(fn_ty_a);
364-
try!(self.subtype(unsafe_a, b));
365-
return Ok(Some(AdjustUnsafeFnPointer));
366-
}
367-
_ => {}
353+
if let ty::TyFnPtr(fn_ty_b) = b.sty {
354+
match (fn_ty_a.unsafety, fn_ty_b.unsafety) {
355+
(hir::Unsafety::Normal, hir::Unsafety::Unsafe) => {
356+
let unsafe_a = self.tcx().safe_to_unsafe_fn_ty(fn_ty_a);
357+
try!(self.subtype(unsafe_a, b));
358+
return Ok(Some(AdjustUnsafeFnPointer));
368359
}
360+
_ => {}
369361
}
370-
self.subtype(a, b)
371-
})
362+
}
363+
self.subtype(a, b)
372364
}
373365

374366
fn coerce_from_fn_item(&self,
@@ -381,19 +373,17 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
381373
* into a closure or a `proc`.
382374
*/
383375

384-
self.unpack_actual_value(b, |b| {
385-
debug!("coerce_from_fn_item(a={:?}, b={:?})",
386-
a, b);
376+
let b = self.fcx.infcx().shallow_resolve(b);
377+
debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b);
387378

388-
match b.sty {
389-
ty::TyFnPtr(_) => {
390-
let a_fn_pointer = self.tcx().mk_ty(ty::TyFnPtr(fn_ty_a));
391-
try!(self.subtype(a_fn_pointer, b));
392-
Ok(Some(AdjustReifyFnPointer))
393-
}
394-
_ => self.subtype(a, b)
379+
match b.sty {
380+
ty::TyFnPtr(_) => {
381+
let a_fn_pointer = self.tcx().mk_ty(ty::TyFnPtr(fn_ty_a));
382+
try!(self.subtype(a_fn_pointer, b));
383+
Ok(Some(AdjustReifyFnPointer))
395384
}
396-
})
385+
_ => self.subtype(a, b)
386+
}
397387
}
398388

399389
fn coerce_unsafe_ptr(&self,

0 commit comments

Comments
 (0)