|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -use check::{FnCtxt, structurally_resolved_type}; |
| 11 | +use check::{FnCtxt}; |
12 | 12 | use check::demand;
|
13 | 13 | use middle::traits::{self, ObjectSafetyViolation, MethodViolationCode};
|
14 | 14 | use middle::traits::{Obligation, ObligationCause};
|
@@ -66,20 +66,11 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
66 | 66 | demand::suptype(fcx, source_expr.span, source_expected_ty, source_ty);
|
67 | 67 |
|
68 | 68 | debug!("check_object_cast postunify source_ty={}", source_ty.repr(tcx));
|
69 |
| - let source_ty = structurally_resolved_type(fcx, source_expr.span, source_ty); |
70 |
| - debug!("check_object_cast resolveto source_ty={}", source_ty.repr(tcx)); |
71 | 69 |
|
72 | 70 | let object_trait = object_trait(&object_trait_ty);
|
73 | 71 |
|
74 |
| - let referent_ty = match source_ty.sty { |
75 |
| - ty::ty_uniq(ty) => ty, |
76 |
| - ty::ty_rptr(_, ty::mt { ty, mutbl: _ }) => ty, |
77 |
| - _ => fcx.tcx().sess.span_bug(source_expr.span, |
78 |
| - "expected appropriate reference type"), |
79 |
| - }; |
80 |
| - |
81 | 72 | // Ensure that if Ptr<T> is cast to Ptr<Trait>, then T : Trait.
|
82 |
| - push_cast_obligation(fcx, cast_expr, object_trait, referent_ty); |
| 73 | + push_cast_obligation(fcx, cast_expr, object_trait, fresh_ty); |
83 | 74 | check_object_safety(tcx, object_trait, source_expr.span);
|
84 | 75 |
|
85 | 76 | fn object_trait<'a, 'tcx>(t: &'a Ty<'tcx>) -> &'a ty::TyTrait<'tcx> {
|
|
0 commit comments