about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_trans/mir/rvalue.rs2
-rw-r--r--src/test/run-pass/mir_coercions.rs11
2 files changed, 13 insertions, 0 deletions
diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs
index 1236100a4d5..45b6bcd920f 100644
--- a/src/librustc_trans/mir/rvalue.rs
+++ b/src/librustc_trans/mir/rvalue.rs
@@ -55,6 +55,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
            }
 
             mir::Rvalue::Cast(mir::CastKind::Unsize, ref source, cast_ty) => {
+                let cast_ty = bcx.monomorphize(&cast_ty);
+
                 if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
                     // into-coerce of a thin pointer to a fat pointer - just
                     // use the operand path.
diff --git a/src/test/run-pass/mir_coercions.rs b/src/test/run-pass/mir_coercions.rs
index c1897f79f22..09dd52e30be 100644
--- a/src/test/run-pass/mir_coercions.rs
+++ b/src/test/run-pass/mir_coercions.rs
@@ -55,6 +55,13 @@ fn coerce_fat_ptr_wrapper(p: PtrWrapper<Fn(u32) -> u32+Send>)
     p
 }
 
+#[rustc_mir]
+fn coerce_ptr_wrapper_poly<'a, T, Trait: ?Sized>(p: PtrWrapper<'a, T>)
+                                                 -> PtrWrapper<'a, Trait>
+    where PtrWrapper<'a, T>: CoerceUnsized<PtrWrapper<'a, Trait>>
+{
+    p
+}
 
 fn main() {
     let a = [0,1,2];
@@ -73,4 +80,8 @@ fn main() {
 
     let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local));
     assert_eq!((z.3)(6), 36);
+
+    let z: PtrWrapper<Fn(u32) -> u32> =
+        coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local));
+    assert_eq!((z.3)(6), 36);
 }