Skip to content

Commit 0e535dc

Browse files
arielb1Ariel Ben-Yehuda
authored and
Ariel Ben-Yehuda
committed
Remove ObjectCastMap
1 parent 777c93c commit 0e535dc

File tree

7 files changed

+7
-53
lines changed

7 files changed

+7
-53
lines changed

src/librustc/metadata/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ enum_from_u32! {
146146
tag_table_closure_kinds = 0x65,
147147
tag_table_upvar_capture_map = 0x66,
148148
tag_table_capture_modes = 0x67,
149-
tag_table_object_cast_map = 0x68,
149+
// GAP 0x68
150150
tag_table_const_qualif = 0x69,
151151
tag_table_cast_kinds = 0x6a,
152152
}

src/librustc/middle/astencode.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1117,13 +1117,6 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
11171117
})
11181118
}
11191119

1120-
if let Some(trait_ref) = tcx.object_cast_map.borrow().get(&id) {
1121-
rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| {
1122-
rbml_w.id(id);
1123-
rbml_w.emit_trait_ref(ecx, &trait_ref.0);
1124-
})
1125-
}
1126-
11271120
if let Some(adjustment) = tcx.adjustments.borrow().get(&id) {
11281121
match *adjustment {
11291122
ty::AdjustDerefRef(ref adj) => {
@@ -1708,11 +1701,6 @@ fn decode_side_tables(dcx: &DecodeContext,
17081701
};
17091702
dcx.tcx.method_map.borrow_mut().insert(method_call, method);
17101703
}
1711-
c::tag_table_object_cast_map => {
1712-
let trait_ref = val_dsr.read_poly_trait_ref(dcx);
1713-
dcx.tcx.object_cast_map.borrow_mut()
1714-
.insert(id, trait_ref);
1715-
}
17161704
c::tag_table_adjustments => {
17171705
let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(dcx);
17181706
dcx.tcx.adjustments.borrow_mut().insert(id, adj);

src/librustc/middle/ty.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,6 @@ impl MethodCall {
503503
// of the method to be invoked
504504
pub type MethodMap<'tcx> = RefCell<FnvHashMap<MethodCall, MethodCallee<'tcx>>>;
505505

506-
// For every explicit cast into an object type, maps from the cast
507-
// expr to the associated trait ref.
508-
pub type ObjectCastMap<'tcx> = RefCell<NodeMap<ty::PolyTraitRef<'tcx>>>;
509-
510506
// Contains information needed to resolve types and (in the future) look up
511507
// the types of AST nodes.
512508
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
@@ -557,8 +553,7 @@ pub struct CtxtArenas<'tcx> {
557553
stability: TypedArena<attr::Stability>,
558554

559555
// references
560-
trait_defs: TypedArena<TraitDef<'tcx>>
561-
556+
trait_defs: TypedArena<TraitDef<'tcx>>,
562557
}
563558

564559
impl<'tcx> CtxtArenas<'tcx> {
@@ -612,7 +607,6 @@ pub struct ctxt<'tcx> {
612607
region_interner: RefCell<FnvHashMap<&'tcx Region, &'tcx Region>>,
613608
stability_interner: RefCell<FnvHashMap<&'tcx attr::Stability, &'tcx attr::Stability>>,
614609

615-
616610
/// Common types, pre-interned for your convenience.
617611
pub types: CommonTypes<'tcx>,
618612

@@ -665,10 +659,6 @@ pub struct ctxt<'tcx> {
665659
/// additional acyclicity requirements).
666660
pub super_predicates: RefCell<DefIdMap<GenericPredicates<'tcx>>>,
667661

668-
/// Maps from node-id of a trait object cast (like `foo as
669-
/// Box<Trait>`) to the trait reference.
670-
pub object_cast_map: ObjectCastMap<'tcx>,
671-
672662
pub map: ast_map::Map<'tcx>,
673663
pub freevars: RefCell<FreevarMap>,
674664
pub tcache: RefCell<DefIdMap<TypeScheme<'tcx>>>,
@@ -2742,7 +2732,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
27422732
trait_defs: RefCell::new(DefIdMap()),
27432733
predicates: RefCell::new(DefIdMap()),
27442734
super_predicates: RefCell::new(DefIdMap()),
2745-
object_cast_map: RefCell::new(NodeMap()),
27462735
map: map,
27472736
freevars: freevars,
27482737
tcache: RefCell::new(DefIdMap()),

src/librustc_lint/builtin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,8 @@ declare_lint! {
17961796
pub struct Stability;
17971797

17981798
impl Stability {
1799-
fn lint(&self, cx: &Context, _id: ast::DefId, span: Span, stability: &Option<&attr::Stability>) {
1799+
fn lint(&self, cx: &Context, _id: ast::DefId,
1800+
span: Span, stability: &Option<&attr::Stability>) {
18001801
// Deprecated attributes apply in-crate and cross-crate.
18011802
let (lint, label) = match *stability {
18021803
Some(&attr::Stability { deprecated_since: Some(_), .. }) =>

src/librustc_typeck/check/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ use middle::ty::{FnSig, GenericPredicates, TypeScheme};
9898
use middle::ty::{Disr, ParamTy, ParameterEnvironment};
9999
use middle::ty::{self, HasProjectionTypes, RegionEscape, ToPolyTraitRef, Ty};
100100
use middle::ty::liberate_late_bound_regions;
101-
use middle::ty::{MethodCall, MethodCallee, MethodMap, ObjectCastMap};
101+
use middle::ty::{MethodCall, MethodCallee, MethodMap};
102102
use middle::ty_fold::{TypeFolder, TypeFoldable};
103103
use rscope::RegionScope;
104104
use session::Session;
@@ -164,7 +164,6 @@ pub struct Inherited<'a, 'tcx: 'a> {
164164
upvar_capture_map: RefCell<ty::UpvarCaptureMap>,
165165
closure_tys: RefCell<DefIdMap<ty::ClosureTy<'tcx>>>,
166166
closure_kinds: RefCell<DefIdMap<ty::ClosureKind>>,
167-
object_cast_map: ObjectCastMap<'tcx>,
168167

169168
// A mapping from each fn's id to its signature, with all bound
170169
// regions replaced with free ones. Unlike the other tables, this
@@ -383,7 +382,6 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
383382
item_substs: RefCell::new(NodeMap()),
384383
adjustments: RefCell::new(NodeMap()),
385384
method_map: RefCell::new(FnvHashMap()),
386-
object_cast_map: RefCell::new(NodeMap()),
387385
upvar_capture_map: RefCell::new(FnvHashMap()),
388386
closure_tys: RefCell::new(DefIdMap()),
389387
closure_kinds: RefCell::new(DefIdMap()),

src/librustc_typeck/check/writeback.rs

-23
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub fn resolve_type_vars_in_expr(fcx: &FnCtxt, e: &ast::Expr) {
4141
wbcx.visit_expr(e);
4242
wbcx.visit_upvar_borrow_map();
4343
wbcx.visit_closures();
44-
wbcx.visit_object_cast_map();
4544
}
4645

4746
pub fn resolve_type_vars_in_fn(fcx: &FnCtxt,
@@ -62,7 +61,6 @@ pub fn resolve_type_vars_in_fn(fcx: &FnCtxt,
6261
}
6362
wbcx.visit_upvar_borrow_map();
6463
wbcx.visit_closures();
65-
wbcx.visit_object_cast_map();
6664
}
6765

6866
///////////////////////////////////////////////////////////////////////////
@@ -239,27 +237,6 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
239237
}
240238
}
241239

242-
fn visit_object_cast_map(&self) {
243-
if self.fcx.writeback_errors.get() {
244-
return
245-
}
246-
247-
for (&node_id, trait_ref) in self.fcx
248-
.inh
249-
.object_cast_map
250-
.borrow()
251-
.iter()
252-
{
253-
let span = ty::expr_span(self.tcx(), node_id);
254-
let reason = ResolvingExpr(span);
255-
let closure_ty = self.resolve(trait_ref, reason);
256-
self.tcx()
257-
.object_cast_map
258-
.borrow_mut()
259-
.insert(node_id, closure_ty);
260-
}
261-
}
262-
263240
fn visit_node_id(&self, reason: ResolveReason, id: ast::NodeId) {
264241
// Resolve any borrowings for the node with id `id`
265242
self.visit_adjustments(reason, id);

src/librustc_typeck/coherence/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
285285
}
286286
_ => {
287287
self.crate_context.tcx.sess.span_bug(item.span,
288-
"can't convert a non-impl to an impl");
288+
"can't convert a non-impl \
289+
to an impl");
289290
}
290291
}
291292
}

0 commit comments

Comments
 (0)