diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index da74ed88eaf85..d723cf325718e 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -493,6 +493,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { } mir::Rvalue::Cast(mir::CastKind::ClosureFnPointer, ref operand, _) => { let source_ty = operand.ty(self.mir, self.scx.tcx()); + let source_ty = self.scx.tcx().trans_apply_param_substs(self.param_substs, + &source_ty); match source_ty.sty { ty::TyClosure(def_id, substs) => { let instance = monomorphize::resolve_closure( @@ -543,6 +545,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { block: mir::BasicBlock, kind: &mir::TerminatorKind<'tcx>, location: Location) { + debug!("visiting terminator {:?} @ {:?}", kind, location); + let tcx = self.scx.tcx(); match *kind { mir::TerminatorKind::Call { ref func, .. } => { diff --git a/src/test/run-pass/closure-to-fn-coercion.rs b/src/test/run-pass/closure-to-fn-coercion.rs index 7fb26bdc9360d..343209143cc2f 100644 --- a/src/test/run-pass/closure-to-fn-coercion.rs +++ b/src/test/run-pass/closure-to-fn-coercion.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::mem; + const FOO: fn(u8) -> u8 = |v: u8| { v }; const BAR: [fn(&mut u32); 5] = [ @@ -21,6 +23,10 @@ fn func_specific() -> (fn() -> u32) { || return 42 } +fn generic(_: T) -> fn() -> usize { + || mem::size_of::() +} + fn main() { // Items assert_eq!(func_specific()(), 42); @@ -34,4 +40,5 @@ fn main() { assert_eq!({ BAR[2](&mut a); a }, 3); assert_eq!({ BAR[3](&mut a); a }, 6); assert_eq!({ BAR[4](&mut a); a }, 10); + assert_eq!(generic(0i8)(), 1); }