Skip to content

Commit e0eb3cc

Browse files
Ariel Ben-Yehudaarielb1
Ariel Ben-Yehuda
authored andcommitted
Kill TraitStore
1 parent 4032b85 commit e0eb3cc

File tree

14 files changed

+14
-566
lines changed

14 files changed

+14
-566
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,6 @@ fn parse_size(st: &mut PState) -> Option<uint> {
243243
}
244244
}
245245

246-
fn parse_trait_store_<F>(st: &mut PState, conv: &mut F) -> ty::TraitStore where
247-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
248-
{
249-
match next(st) {
250-
'~' => ty::UniqTraitStore,
251-
'&' => ty::RegionTraitStore(parse_region_(st, conv), parse_mutability(st)),
252-
c => {
253-
st.tcx.sess.bug(&format!("parse_trait_store(): bad input '{}'",
254-
c)[])
255-
}
256-
}
257-
}
258-
259246
fn parse_vec_per_param_space<'a, 'tcx, T, F>(st: &mut PState<'a, 'tcx>,
260247
mut f: F)
261248
-> VecPerParamSpace<T> where
@@ -662,14 +649,12 @@ fn parse_closure_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>,
662649
{
663650
let unsafety = parse_unsafety(next(st));
664651
let onceness = parse_onceness(next(st));
665-
let store = parse_trait_store_(st, conv);
666652
let bounds = parse_existential_bounds_(st, conv);
667653
let sig = parse_sig_(st, conv);
668654
let abi = parse_abi_set(st);
669655
ty::ClosureTy {
670656
unsafety: unsafety,
671657
onceness: onceness,
672-
store: store,
673658
bounds: bounds,
674659
sig: sig,
675660
abi: abi,

src/librustc/metadata/tyencode.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,6 @@ pub fn enc_trait_ref<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
305305
enc_substs(w, cx, s.substs);
306306
}
307307

308-
pub fn enc_trait_store(w: &mut SeekableMemWriter, cx: &ctxt, s: ty::TraitStore) {
309-
match s {
310-
ty::UniqTraitStore => mywrite!(w, "~"),
311-
ty::RegionTraitStore(re, m) => {
312-
mywrite!(w, "&");
313-
enc_region(w, cx, re);
314-
enc_mutability(w, m);
315-
}
316-
}
317-
}
318-
319308
fn enc_unsafety(w: &mut SeekableMemWriter, p: ast::Unsafety) {
320309
match p {
321310
ast::Unsafety::Normal => mywrite!(w, "n"),
@@ -347,7 +336,6 @@ pub fn enc_closure_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
347336
ft: &ty::ClosureTy<'tcx>) {
348337
enc_unsafety(w, ft.unsafety);
349338
enc_onceness(w, ft.onceness);
350-
enc_trait_store(w, cx, ft.store);
351339
enc_existential_bounds(w, cx, &ft.bounds);
352340
enc_fn_sig(w, cx, &ft.sig);
353341
enc_abi(w, ft.abi);

src/librustc/middle/astencode.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,6 @@ impl tr for ty::BoundRegion {
515515
}
516516
}
517517

518-
impl tr for ty::TraitStore {
519-
fn tr(&self, dcx: &DecodeContext) -> ty::TraitStore {
520-
match *self {
521-
ty::RegionTraitStore(r, m) => {
522-
ty::RegionTraitStore(r.tr(dcx), m)
523-
}
524-
ty::UniqTraitStore => ty::UniqTraitStore
525-
}
526-
}
527-
}
528-
529518
// ______________________________________________________________________
530519
// Encoding and decoding of freevar information
531520

src/librustc/middle/infer/combine.rs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -202,39 +202,6 @@ pub trait Combine<'tcx> : Sized {
202202
sig: sig})
203203
}
204204

205-
fn closure_tys(&self, a: &ty::ClosureTy<'tcx>,
206-
b: &ty::ClosureTy<'tcx>) -> cres<'tcx, ty::ClosureTy<'tcx>> {
207-
208-
let store = match (a.store, b.store) {
209-
(ty::RegionTraitStore(a_r, a_m),
210-
ty::RegionTraitStore(b_r, b_m)) if a_m == b_m => {
211-
let r = try!(self.contraregions(a_r, b_r));
212-
ty::RegionTraitStore(r, a_m)
213-
}
214-
215-
_ if a.store == b.store => {
216-
a.store
217-
}
218-
219-
_ => {
220-
return Err(ty::terr_sigil_mismatch(expected_found(self, a.store, b.store)))
221-
}
222-
};
223-
let unsafety = try!(self.unsafeties(a.unsafety, b.unsafety));
224-
let onceness = try!(self.oncenesses(a.onceness, b.onceness));
225-
let bounds = try!(self.existential_bounds(&a.bounds, &b.bounds));
226-
let sig = try!(self.binders(&a.sig, &b.sig));
227-
let abi = try!(self.abi(a.abi, b.abi));
228-
Ok(ty::ClosureTy {
229-
unsafety: unsafety,
230-
onceness: onceness,
231-
store: store,
232-
bounds: bounds,
233-
sig: sig,
234-
abi: abi,
235-
})
236-
}
237-
238205
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::FnSig<'tcx>> {
239206
if a.variadic != b.variadic {
240207
return Err(ty::terr_variadic_mismatch(expected_found(self, a.variadic, b.variadic)));
@@ -356,31 +323,6 @@ pub trait Combine<'tcx> : Sized {
356323

357324
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region>;
358325

359-
fn trait_stores(&self,
360-
vk: ty::terr_vstore_kind,
361-
a: ty::TraitStore,
362-
b: ty::TraitStore)
363-
-> cres<'tcx, ty::TraitStore> {
364-
debug!("{}.trait_stores(a={:?}, b={:?})", self.tag(), a, b);
365-
366-
match (a, b) {
367-
(ty::RegionTraitStore(a_r, a_m),
368-
ty::RegionTraitStore(b_r, b_m)) if a_m == b_m => {
369-
self.contraregions(a_r, b_r).and_then(|r| {
370-
Ok(ty::RegionTraitStore(r, a_m))
371-
})
372-
}
373-
374-
_ if a == b => {
375-
Ok(a)
376-
}
377-
378-
_ => {
379-
Err(ty::terr_trait_stores_differ(vk, expected_found(self, a, b)))
380-
}
381-
}
382-
}
383-
384326
fn trait_refs(&self,
385327
a: &ty::TraitRef<'tcx>,
386328
b: &ty::TraitRef<'tcx>)

src/librustc/middle/ty.rs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub use self::InferTy::*;
1717
pub use self::InferRegion::*;
1818
pub use self::ImplOrTraitItemId::*;
1919
pub use self::UnboxedClosureKind::*;
20-
pub use self::TraitStore::*;
2120
pub use self::ast_ty_to_ty_cache_entry::*;
2221
pub use self::Variance::*;
2322
pub use self::AutoAdjustment::*;
@@ -61,7 +60,7 @@ use middle::ty;
6160
use middle::ty_fold::{self, TypeFoldable, TypeFolder};
6261
use middle::ty_walk::TypeWalker;
6362
use util::ppaux::{note_and_explain_region, bound_region_ptr_to_string};
64-
use util::ppaux::{trait_store_to_string, ty_to_string};
63+
use util::ppaux::ty_to_string;
6564
use util::ppaux::{Repr, UserString};
6665
use util::common::{memoized, ErrorReported};
6766
use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet};
@@ -247,14 +246,6 @@ pub struct mt<'tcx> {
247246
pub mutbl: ast::Mutability,
248247
}
249248

250-
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show)]
251-
pub enum TraitStore {
252-
/// Box<Trait>
253-
UniqTraitStore,
254-
/// &Trait and &mut Trait
255-
RegionTraitStore(Region, ast::Mutability),
256-
}
257-
258249
#[derive(Clone, Copy, Show)]
259250
pub struct field_ty {
260251
pub name: Name,
@@ -1042,7 +1033,6 @@ pub struct BareFnTy<'tcx> {
10421033
pub struct ClosureTy<'tcx> {
10431034
pub unsafety: ast::Unsafety,
10441035
pub onceness: ast::Onceness,
1045-
pub store: TraitStore,
10461036
pub bounds: ExistentialBounds<'tcx>,
10471037
pub sig: PolyFnSig<'tcx>,
10481038
pub abi: abi::Abi,
@@ -1545,7 +1535,6 @@ pub enum type_err<'tcx> {
15451535
terr_onceness_mismatch(expected_found<Onceness>),
15461536
terr_abi_mismatch(expected_found<abi::Abi>),
15471537
terr_mutability,
1548-
terr_sigil_mismatch(expected_found<TraitStore>),
15491538
terr_box_mutability,
15501539
terr_ptr_mutability,
15511540
terr_ref_mutability,
@@ -1559,7 +1548,6 @@ pub enum type_err<'tcx> {
15591548
terr_regions_no_overlap(Region, Region),
15601549
terr_regions_insufficiently_polymorphic(BoundRegion, Region),
15611550
terr_regions_overly_polymorphic(BoundRegion, Region),
1562-
terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>),
15631551
terr_sorts(expected_found<Ty<'tcx>>),
15641552
terr_integer_as_char,
15651553
terr_int_mismatch(expected_found<IntVarValue>),
@@ -4194,19 +4182,6 @@ pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> ty::Binder<Vec<Ty<'tcx>>> {
41944182
ty_fn_sig(fty).inputs()
41954183
}
41964184

4197-
pub fn ty_closure_store(fty: Ty) -> TraitStore {
4198-
match fty.sty {
4199-
ty_unboxed_closure(..) => {
4200-
// Close enough for the purposes of all the callers of this
4201-
// function (which is soon to be deprecated anyhow).
4202-
UniqTraitStore
4203-
}
4204-
ref s => {
4205-
panic!("ty_closure_store() called on non-closure type: {:?}", s)
4206-
}
4207-
}
4208-
}
4209-
42104185
pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> Binder<FnOutput<'tcx>> {
42114186
match fty.sty {
42124187
ty_bare_fn(_, ref f) => f.sig.output(),
@@ -4751,13 +4726,6 @@ impl<'tcx> Repr<'tcx> for ty::type_err<'tcx> {
47514726
/// afterwards to present additional details, particularly when it comes to lifetime-related
47524727
/// errors.
47534728
pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
4754-
fn tstore_to_closure(s: &TraitStore) -> String {
4755-
match s {
4756-
&UniqTraitStore => "proc".to_string(),
4757-
&RegionTraitStore(..) => "closure".to_string()
4758-
}
4759-
}
4760-
47614729
match *err {
47624730
terr_cyclic_ty => "cyclic type of infinite size".to_string(),
47634731
terr_mismatch => "types differ".to_string(),
@@ -4776,11 +4744,6 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
47764744
values.expected,
47774745
values.found)
47784746
}
4779-
terr_sigil_mismatch(values) => {
4780-
format!("expected {}, found {}",
4781-
tstore_to_closure(&values.expected),
4782-
tstore_to_closure(&values.found))
4783-
}
47844747
terr_mutability => "values differ in mutability".to_string(),
47854748
terr_box_mutability => {
47864749
"boxed values differ in mutability".to_string()
@@ -4828,11 +4791,6 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String {
48284791
found bound lifetime parameter {}",
48294792
bound_region_ptr_to_string(cx, br))
48304793
}
4831-
terr_trait_stores_differ(_, ref values) => {
4832-
format!("trait storage differs: expected `{}`, found `{}`",
4833-
trait_store_to_string(cx, (*values).expected),
4834-
trait_store_to_string(cx, (*values).found))
4835-
}
48364794
terr_sorts(values) => {
48374795
// A naive approach to making sure that we're not reporting silly errors such as:
48384796
// (expected closure, found closure).
@@ -7338,10 +7296,9 @@ impl ReferencesError for Region
73387296

73397297
impl<'tcx> Repr<'tcx> for ClosureTy<'tcx> {
73407298
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
7341-
format!("ClosureTy({},{},{:?},{},{},{})",
7299+
format!("ClosureTy({},{},{},{},{})",
73427300
self.unsafety,
73437301
self.onceness,
7344-
self.store,
73457302
self.bounds.repr(tcx),
73467303
self.sig.repr(tcx),
73477304
self.abi)

src/librustc/middle/ty_fold.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ pub trait TypeFolder<'tcx> : Sized {
124124
r
125125
}
126126

127-
fn fold_trait_store(&mut self, s: ty::TraitStore) -> ty::TraitStore {
128-
super_fold_trait_store(self, s)
129-
}
130-
131127
fn fold_existential_bounds(&mut self, s: &ty::ExistentialBounds<'tcx>)
132128
-> ty::ExistentialBounds<'tcx> {
133129
super_fold_existential_bounds(self, s)
@@ -225,12 +221,6 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
225221
}
226222
}
227223

228-
impl<'tcx> TypeFoldable<'tcx> for ty::TraitStore {
229-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitStore {
230-
folder.fold_trait_store(*self)
231-
}
232-
}
233-
234224
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
235225
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Ty<'tcx> {
236226
folder.fold_ty(*self)
@@ -699,7 +689,6 @@ pub fn super_fold_closure_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
699689
-> ty::ClosureTy<'tcx>
700690
{
701691
ty::ClosureTy {
702-
store: fty.store.fold_with(this),
703692
sig: fty.sig.fold_with(this),
704693
unsafety: fty.unsafety,
705694
onceness: fty.onceness,
@@ -726,17 +715,6 @@ pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
726715
mutbl: mt.mutbl}
727716
}
728717

729-
pub fn super_fold_trait_store<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
730-
trait_store: ty::TraitStore)
731-
-> ty::TraitStore {
732-
match trait_store {
733-
ty::UniqTraitStore => ty::UniqTraitStore,
734-
ty::RegionTraitStore(r, m) => {
735-
ty::RegionTraitStore(r.fold_with(this), m)
736-
}
737-
}
738-
}
739-
740718
pub fn super_fold_existential_bounds<'tcx, T: TypeFolder<'tcx>>(
741719
this: &mut T,
742720
bounds: &ty::ExistentialBounds<'tcx>)

src/librustc/util/ppaux.rs

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,6 @@ pub fn mt_to_string<'tcx>(cx: &ctxt<'tcx>, m: &mt<'tcx>) -> String {
237237
ty_to_string(cx, m.ty))
238238
}
239239

240-
pub fn trait_store_to_string(cx: &ctxt, s: ty::TraitStore) -> String {
241-
match s {
242-
ty::UniqTraitStore => "Box ".to_string(),
243-
ty::RegionTraitStore(r, m) => {
244-
format!("{}{}", region_ptr_to_string(cx, r), mutability_to_string(m))
245-
}
246-
}
247-
}
248-
249240
pub fn vec_map_to_string<T, F>(ts: &[T], f: F) -> String where
250241
F: FnMut(&T) -> String,
251242
{
@@ -303,13 +294,6 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
303294
fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String {
304295
let mut s = String::new();
305296

306-
match cty.store {
307-
ty::UniqTraitStore => {}
308-
ty::RegionTraitStore(region, _) => {
309-
s.push_str(&region_to_string(cx, "", true, region)[]);
310-
}
311-
}
312-
313297
match cty.unsafety {
314298
ast::Unsafety::Normal => {}
315299
ast::Unsafety::Unsafe => {
@@ -320,22 +304,12 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
320304

321305
let bounds_str = cty.bounds.user_string(cx);
322306

323-
match cty.store {
324-
ty::UniqTraitStore => {
325-
assert_eq!(cty.onceness, ast::Once);
326-
s.push_str("proc");
327-
push_sig_to_string(cx, &mut s, '(', ')', &cty.sig,
328-
&bounds_str[]);
329-
}
330-
ty::RegionTraitStore(..) => {
331-
match cty.onceness {
332-
ast::Many => {}
333-
ast::Once => s.push_str("once ")
334-
}
335-
push_sig_to_string(cx, &mut s, '|', '|', &cty.sig,
336-
&bounds_str[]);
337-
}
307+
match cty.onceness {
308+
ast::Many => {}
309+
ast::Once => s.push_str("once ")
338310
}
311+
push_sig_to_string(cx, &mut s, '|', '|', &cty.sig,
312+
&bounds_str[]);
339313

340314
s
341315
}
@@ -1090,12 +1064,6 @@ impl<'tcx> Repr<'tcx> for ty::MethodObject<'tcx> {
10901064
}
10911065
}
10921066

1093-
impl<'tcx> Repr<'tcx> for ty::TraitStore {
1094-
fn repr(&self, tcx: &ctxt) -> String {
1095-
trait_store_to_string(tcx, *self)
1096-
}
1097-
}
1098-
10991067
impl<'tcx> Repr<'tcx> for ty::BuiltinBound {
11001068
fn repr(&self, _tcx: &ctxt) -> String {
11011069
format!("{:?}", *self)

0 commit comments

Comments
 (0)