mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 00:56:14 +00:00
trans: monomorphize the cast destination type before using it.
This commit is contained in:
parent
50909f2d50
commit
9709dff7e3
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user