From 0ec3183df8d0cdccc735fa6572d664b43dbb5e31 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 26 May 2015 02:28:04 +0300 Subject: [PATCH] Remove ObjectCastMap --- src/librustc/metadata/common.rs | 2 +- src/librustc/middle/astencode.rs | 12 ------------ src/librustc/middle/ty.rs | 13 +------------ src/librustc_lint/builtin.rs | 3 ++- src/librustc_typeck/check/mod.rs | 4 +--- src/librustc_typeck/check/writeback.rs | 23 ----------------------- src/librustc_typeck/coherence/mod.rs | 3 ++- 7 files changed, 7 insertions(+), 53 deletions(-) diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 901afc1d1904..5f785fefa124 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -146,7 +146,7 @@ enum_from_u32! { tag_table_closure_kinds = 0x65, tag_table_upvar_capture_map = 0x66, tag_table_capture_modes = 0x67, - tag_table_object_cast_map = 0x68, + // GAP 0x68 tag_table_const_qualif = 0x69, tag_table_cast_kinds = 0x6a, } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index bfc74ccc2437..fda57c9dc610 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1117,13 +1117,6 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext, }) } - if let Some(trait_ref) = tcx.object_cast_map.borrow().get(&id) { - rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| { - rbml_w.id(id); - rbml_w.emit_trait_ref(ecx, &trait_ref.0); - }) - } - if let Some(adjustment) = tcx.adjustments.borrow().get(&id) { match *adjustment { ty::AdjustDerefRef(ref adj) => { @@ -1708,11 +1701,6 @@ fn decode_side_tables(dcx: &DecodeContext, }; dcx.tcx.method_map.borrow_mut().insert(method_call, method); } - c::tag_table_object_cast_map => { - let trait_ref = val_dsr.read_poly_trait_ref(dcx); - dcx.tcx.object_cast_map.borrow_mut() - .insert(id, trait_ref); - } c::tag_table_adjustments => { let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(dcx); dcx.tcx.adjustments.borrow_mut().insert(id, adj); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 4a95320b3f7f..2ccbb0c5c103 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -503,10 +503,6 @@ impl MethodCall { // of the method to be invoked pub type MethodMap<'tcx> = RefCell>>; -// For every explicit cast into an object type, maps from the cast -// expr to the associated trait ref. -pub type ObjectCastMap<'tcx> = RefCell>>; - // Contains information needed to resolve types and (in the future) look up // the types of AST nodes. #[derive(Copy, Clone, PartialEq, Eq, Hash)] @@ -557,8 +553,7 @@ pub struct CtxtArenas<'tcx> { stability: TypedArena, // references - trait_defs: TypedArena> - + trait_defs: TypedArena>, } impl<'tcx> CtxtArenas<'tcx> { @@ -612,7 +607,6 @@ pub struct ctxt<'tcx> { region_interner: RefCell>, stability_interner: RefCell>, - /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, @@ -665,10 +659,6 @@ pub struct ctxt<'tcx> { /// additional acyclicity requirements). pub super_predicates: RefCell>>, - /// Maps from node-id of a trait object cast (like `foo as - /// Box`) to the trait reference. - pub object_cast_map: ObjectCastMap<'tcx>, - pub map: ast_map::Map<'tcx>, pub freevars: RefCell, pub tcache: RefCell>>, @@ -2742,7 +2732,6 @@ pub fn mk_ctxt<'tcx>(s: Session, trait_defs: RefCell::new(DefIdMap()), predicates: RefCell::new(DefIdMap()), super_predicates: RefCell::new(DefIdMap()), - object_cast_map: RefCell::new(NodeMap()), map: map, freevars: freevars, tcache: RefCell::new(DefIdMap()), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 247ed5bc0130..62726a3ae7b6 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1796,7 +1796,8 @@ declare_lint! { pub struct Stability; impl Stability { - fn lint(&self, cx: &Context, _id: ast::DefId, span: Span, stability: &Option<&attr::Stability>) { + fn lint(&self, cx: &Context, _id: ast::DefId, + span: Span, stability: &Option<&attr::Stability>) { // Deprecated attributes apply in-crate and cross-crate. let (lint, label) = match *stability { Some(&attr::Stability { deprecated_since: Some(_), .. }) => diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 24f429a9ca01..eb6e90414e3f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -98,7 +98,7 @@ use middle::ty::{FnSig, GenericPredicates, TypeScheme}; use middle::ty::{Disr, ParamTy, ParameterEnvironment}; use middle::ty::{self, HasProjectionTypes, RegionEscape, ToPolyTraitRef, Ty}; use middle::ty::liberate_late_bound_regions; -use middle::ty::{MethodCall, MethodCallee, MethodMap, ObjectCastMap}; +use middle::ty::{MethodCall, MethodCallee, MethodMap}; use middle::ty_fold::{TypeFolder, TypeFoldable}; use rscope::RegionScope; use session::Session; @@ -164,7 +164,6 @@ pub struct Inherited<'a, 'tcx: 'a> { upvar_capture_map: RefCell, closure_tys: RefCell>>, closure_kinds: RefCell>, - object_cast_map: ObjectCastMap<'tcx>, // A mapping from each fn's id to its signature, with all bound // regions replaced with free ones. Unlike the other tables, this @@ -383,7 +382,6 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> { item_substs: RefCell::new(NodeMap()), adjustments: RefCell::new(NodeMap()), method_map: RefCell::new(FnvHashMap()), - object_cast_map: RefCell::new(NodeMap()), upvar_capture_map: RefCell::new(FnvHashMap()), closure_tys: RefCell::new(DefIdMap()), closure_kinds: RefCell::new(DefIdMap()), diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 889975f0eb2f..7eba4c0375f9 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -41,7 +41,6 @@ pub fn resolve_type_vars_in_expr(fcx: &FnCtxt, e: &ast::Expr) { wbcx.visit_expr(e); wbcx.visit_upvar_borrow_map(); wbcx.visit_closures(); - wbcx.visit_object_cast_map(); } pub fn resolve_type_vars_in_fn(fcx: &FnCtxt, @@ -62,7 +61,6 @@ pub fn resolve_type_vars_in_fn(fcx: &FnCtxt, } wbcx.visit_upvar_borrow_map(); wbcx.visit_closures(); - wbcx.visit_object_cast_map(); } /////////////////////////////////////////////////////////////////////////// @@ -239,27 +237,6 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } } - fn visit_object_cast_map(&self) { - if self.fcx.writeback_errors.get() { - return - } - - for (&node_id, trait_ref) in self.fcx - .inh - .object_cast_map - .borrow() - .iter() - { - let span = ty::expr_span(self.tcx(), node_id); - let reason = ResolvingExpr(span); - let closure_ty = self.resolve(trait_ref, reason); - self.tcx() - .object_cast_map - .borrow_mut() - .insert(node_id, closure_ty); - } - } - fn visit_node_id(&self, reason: ResolveReason, id: ast::NodeId) { // Resolve any borrowings for the node with id `id` self.visit_adjustments(reason, id); diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 622c116cdb9b..212423d16d43 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -286,7 +286,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { } _ => { self.crate_context.tcx.sess.span_bug(item.span, - "can't convert a non-impl to an impl"); + "can't convert a non-impl \ + to an impl"); } } }