diff options
| author | bors <bors@rust-lang.org> | 2015-02-12 03:53:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-12 03:53:08 +0000 |
| commit | 0fdca30fcb2303966ad2529b7a3b0599088c105d (patch) | |
| tree | f9a1129249bc1a3df4e02840a74aeb0c7e4ddc91 | |
| parent | 3ef8ff1f81107b42840a695725e1a0869c163355 (diff) | |
| parent | f27b3e251cc44464564cc02f7fd5b6d3176204cc (diff) | |
Auto merge of #22193 - pnkfelix:cleanup-pr22012, r=eddyb
PR #22012 followup: clean up vtable::check_object_cast by reusing `fresh_ty` (hat tip to nikomatsakis, who was the one who pointed out this simplification to the logic.)
| -rw-r--r-- | src/librustc_typeck/check/vtable.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/librustc_typeck/check/vtable.rs b/src/librustc_typeck/check/vtable.rs index 00f6c6109fa..2e7eff68bd5 100644 --- a/src/librustc_typeck/check/vtable.rs +++ b/src/librustc_typeck/check/vtable.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use check::{FnCtxt, structurally_resolved_type}; +use check::{FnCtxt}; use check::demand; use middle::traits::{self, ObjectSafetyViolation, MethodViolationCode}; use middle::traits::{Obligation, ObligationCause}; @@ -66,20 +66,11 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, demand::suptype(fcx, source_expr.span, source_expected_ty, source_ty); debug!("check_object_cast postunify source_ty={}", source_ty.repr(tcx)); - let source_ty = structurally_resolved_type(fcx, source_expr.span, source_ty); - debug!("check_object_cast resolveto source_ty={}", source_ty.repr(tcx)); let object_trait = object_trait(&object_trait_ty); - let referent_ty = match source_ty.sty { - ty::ty_uniq(ty) => ty, - ty::ty_rptr(_, ty::mt { ty, mutbl: _ }) => ty, - _ => fcx.tcx().sess.span_bug(source_expr.span, - "expected appropriate reference type"), - }; - // Ensure that if Ptr<T> is cast to Ptr<Trait>, then T : Trait. - push_cast_obligation(fcx, cast_expr, object_trait, referent_ty); + push_cast_obligation(fcx, cast_expr, object_trait, fresh_ty); check_object_safety(tcx, object_trait, source_expr.span); fn object_trait<'a, 'tcx>(t: &'a Ty<'tcx>) -> &'a ty::TyTrait<'tcx> { |
