Skip to content

Commit 64e4753

Browse files
committed
Clean-up some junk
1 parent 38c943f commit 64e4753

File tree

5 files changed

+2
-255
lines changed

5 files changed

+2
-255
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,6 @@ pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
297297
decoder::get_impl_trait(&*cdata, def.node, tcx)
298298
}
299299

300-
// Given a def_id for an impl, return information about its vtables
301-
pub fn get_impl_vtables<'tcx>(tcx: &ty::ctxt<'tcx>,
302-
def: ast::DefId)
303-
-> ty::vtable_res<'tcx> {
304-
let cstore = &tcx.sess.cstore;
305-
let cdata = cstore.get_crate_data(def.krate);
306-
decoder::get_impl_vtables(&*cdata, def.node, tcx)
307-
}
308-
309300
pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
310301
-> Vec<(cstore::NativeLibraryKind, String)> {
311302
let cdata = cstore.get_crate_data(crate_num);
@@ -414,11 +405,6 @@ pub fn get_repr_attrs(cstore: &cstore::CStore, def: ast::DefId)
414405
decoder::get_repr_attrs(&*cdata, def.node)
415406
}
416407

417-
pub fn is_associated_type(cstore: &cstore::CStore, def: ast::DefId) -> bool {
418-
let cdata = cstore.get_crate_data(def.krate);
419-
decoder::is_associated_type(&*cdata, def.node)
420-
}
421-
422408
pub fn is_defaulted_trait(cstore: &cstore::CStore, trait_def_id: ast::DefId) -> bool {
423409
let cdata = cstore.get_crate_data(trait_def_id.krate);
424410
decoder::is_defaulted_trait(&*cdata, trait_def_id.node)

src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use middle::lang_items;
3030
use middle::subst;
3131
use middle::ty::{ImplContainer, TraitContainer};
3232
use middle::ty::{self, Ty};
33-
use middle::astencode::vtable_decoder_helpers;
3433
use util::nodemap::FnvHashMap;
3534

3635
use std::cell::{Cell, RefCell};
@@ -522,18 +521,6 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
522521
}
523522
}
524523

525-
pub fn get_impl_vtables<'tcx>(cdata: Cmd,
526-
id: ast::NodeId,
527-
tcx: &ty::ctxt<'tcx>)
528-
-> ty::vtable_res<'tcx>
529-
{
530-
let item_doc = lookup_item(id, cdata.data());
531-
let vtables_doc = reader::get_doc(item_doc, tag_item_impl_vtables);
532-
let mut decoder = reader::Decoder::new(vtables_doc);
533-
decoder.read_vtable_res(tcx, cdata)
534-
}
535-
536-
537524
pub fn get_symbol(data: &[u8], id: ast::NodeId) -> String {
538525
return item_symbol(lookup_item(id, data));
539526
}
@@ -1623,14 +1610,6 @@ fn doc_predicates<'tcx>(base_doc: rbml::Doc,
16231610
ty::GenericPredicates { predicates: predicates }
16241611
}
16251612

1626-
pub fn is_associated_type(cdata: Cmd, id: ast::NodeId) -> bool {
1627-
let items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
1628-
match maybe_find_item(id, items) {
1629-
None => false,
1630-
Some(item) => item_sort(item) == Some('t'),
1631-
}
1632-
}
1633-
16341613
pub fn is_defaulted_trait(cdata: Cmd, trait_id: ast::NodeId) -> bool {
16351614
let trait_doc = lookup_item(trait_id, cdata.data());
16361615
assert!(item_family(trait_doc) == Family::Trait);

src/librustc/middle/astencode.rs

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -696,19 +696,6 @@ pub fn encode_cast_kind(ebml_w: &mut Encoder, kind: cast::CastKind) {
696696
pub trait vtable_decoder_helpers<'tcx> {
697697
fn read_vec_per_param_space<T, F>(&mut self, f: F) -> VecPerParamSpace<T> where
698698
F: FnMut(&mut Self) -> T;
699-
fn read_vtable_res_with_key(&mut self,
700-
tcx: &ty::ctxt<'tcx>,
701-
cdata: &cstore::crate_metadata)
702-
-> (u32, ty::vtable_res<'tcx>);
703-
fn read_vtable_res(&mut self,
704-
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
705-
-> ty::vtable_res<'tcx>;
706-
fn read_vtable_param_res(&mut self,
707-
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
708-
-> ty::vtable_param_res<'tcx>;
709-
fn read_vtable_origin(&mut self,
710-
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
711-
-> ty::vtable_origin<'tcx>;
712699
}
713700

714701
impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
@@ -720,85 +707,6 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
720707
let fns = self.read_to_vec(|this| Ok(f(this))).unwrap();
721708
VecPerParamSpace::new(types, selfs, fns)
722709
}
723-
724-
fn read_vtable_res_with_key(&mut self,
725-
tcx: &ty::ctxt<'tcx>,
726-
cdata: &cstore::crate_metadata)
727-
-> (u32, ty::vtable_res<'tcx>) {
728-
self.read_struct("VtableWithKey", 2, |this| {
729-
let autoderef = this.read_struct_field("autoderef", 0, |this| {
730-
Decodable::decode(this)
731-
}).unwrap();
732-
Ok((autoderef, this.read_struct_field("vtable_res", 1, |this| {
733-
Ok(this.read_vtable_res(tcx, cdata))
734-
}).unwrap()))
735-
}).unwrap()
736-
}
737-
738-
fn read_vtable_res(&mut self,
739-
tcx: &ty::ctxt<'tcx>,
740-
cdata: &cstore::crate_metadata)
741-
-> ty::vtable_res<'tcx>
742-
{
743-
self.read_vec_per_param_space(
744-
|this| this.read_vtable_param_res(tcx, cdata))
745-
}
746-
747-
fn read_vtable_param_res(&mut self,
748-
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
749-
-> ty::vtable_param_res<'tcx> {
750-
self.read_to_vec(|this| Ok(this.read_vtable_origin(tcx, cdata)))
751-
.unwrap().into_iter().collect()
752-
}
753-
754-
fn read_vtable_origin(&mut self,
755-
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
756-
-> ty::vtable_origin<'tcx> {
757-
self.read_enum("vtable_origin", |this| {
758-
this.read_enum_variant(&["vtable_static",
759-
"vtable_param",
760-
"vtable_error",
761-
"vtable_closure"],
762-
|this, i| {
763-
Ok(match i {
764-
0 => {
765-
ty::vtable_static(
766-
this.read_enum_variant_arg(0, |this| {
767-
Ok(this.read_def_id_nodcx(cdata))
768-
}).unwrap(),
769-
this.read_enum_variant_arg(1, |this| {
770-
Ok(this.read_substs_nodcx(tcx, cdata))
771-
}).unwrap(),
772-
this.read_enum_variant_arg(2, |this| {
773-
Ok(this.read_vtable_res(tcx, cdata))
774-
}).unwrap()
775-
)
776-
}
777-
1 => {
778-
ty::vtable_param(
779-
this.read_enum_variant_arg(0, |this| {
780-
Decodable::decode(this)
781-
}).unwrap(),
782-
this.read_enum_variant_arg(1, |this| {
783-
this.read_uint()
784-
}).unwrap()
785-
)
786-
}
787-
2 => {
788-
ty::vtable_closure(
789-
this.read_enum_variant_arg(0, |this| {
790-
Ok(this.read_def_id_nodcx(cdata))
791-
}).unwrap()
792-
)
793-
}
794-
3 => {
795-
ty::vtable_error
796-
}
797-
_ => panic!("bad enum variant")
798-
})
799-
})
800-
}).unwrap()
801-
}
802710
}
803711

804712
// ___________________________________________________________________________

src/librustc/middle/ty.rs

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub use self::ImplOrTraitItem::*;
3232
pub use self::BoundRegion::*;
3333
pub use self::sty::*;
3434
pub use self::IntVarValue::*;
35-
pub use self::vtable_origin::*;
3635
pub use self::MethodOrigin::*;
3736
pub use self::CopyImplementationError::*;
3837

@@ -402,12 +401,6 @@ pub enum CustomCoerceUnsized {
402401
Struct(usize)
403402
}
404403

405-
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Debug)]
406-
pub struct param_index {
407-
pub space: subst::ParamSpace,
408-
pub index: usize
409-
}
410-
411404
#[derive(Clone, Debug)]
412405
pub enum MethodOrigin<'tcx> {
413406
// fully statically resolved method
@@ -510,46 +503,6 @@ impl MethodCall {
510503
// of the method to be invoked
511504
pub type MethodMap<'tcx> = RefCell<FnvHashMap<MethodCall, MethodCallee<'tcx>>>;
512505

513-
pub type vtable_param_res<'tcx> = Vec<vtable_origin<'tcx>>;
514-
515-
// Resolutions for bounds of all parameters, left to right, for a given path.
516-
pub type vtable_res<'tcx> = VecPerParamSpace<vtable_param_res<'tcx>>;
517-
518-
#[derive(Clone)]
519-
pub enum vtable_origin<'tcx> {
520-
/*
521-
Statically known vtable. def_id gives the impl item
522-
from whence comes the vtable, and tys are the type substs.
523-
vtable_res is the vtable itself.
524-
*/
525-
vtable_static(ast::DefId, subst::Substs<'tcx>, vtable_res<'tcx>),
526-
527-
/*
528-
Dynamic vtable, comes from a parameter that has a bound on it:
529-
fn foo<T:quux,baz,bar>(a: T) -- a's vtable would have a
530-
vtable_param origin
531-
532-
The first argument is the param index (identifying T in the example),
533-
and the second is the bound number (identifying baz)
534-
*/
535-
vtable_param(param_index, usize),
536-
537-
/*
538-
Vtable automatically generated for a closure. The def ID is the
539-
ID of the closure expression.
540-
*/
541-
vtable_closure(ast::DefId),
542-
543-
/*
544-
Asked to determine the vtable for ty_err. This is the value used
545-
for the vtables of `Self` in a virtual call like `foo.bar()`
546-
where `foo` is of object type. The same value is also used when
547-
type errors occur.
548-
*/
549-
vtable_error,
550-
}
551-
552-
553506
// For every explicit cast into an object type, maps from the cast
554507
// expr to the associated trait ref.
555508
pub type ObjectCastMap<'tcx> = RefCell<NodeMap<ty::PolyTraitRef<'tcx>>>;
@@ -803,9 +756,6 @@ pub struct ctxt<'tcx> {
803756
/// Maps any item's def-id to its stability index.
804757
pub stability: RefCell<stability::Index>,
805758

806-
/// Maps def IDs to true if and only if they're associated types.
807-
pub associated_types: RefCell<DefIdMap<bool>>,
808-
809759
/// Caches the results of trait selection. This cache is used
810760
/// for things that do not have to do with the parameters in scope.
811761
pub selection_cache: traits::SelectionCache<'tcx>,
@@ -2816,7 +2766,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
28162766
node_lint_levels: RefCell::new(FnvHashMap()),
28172767
transmute_restrictions: RefCell::new(Vec::new()),
28182768
stability: RefCell::new(stability),
2819-
associated_types: RefCell::new(DefIdMap()),
28202769
selection_cache: traits::SelectionCache::new(),
28212770
repr_hint_cache: RefCell::new(DefIdMap()),
28222771
type_impls_copy_cache: RefCell::new(HashMap::new()),
@@ -4305,17 +4254,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
43054254
}
43064255

43074256
pub fn type_is_trait(ty: Ty) -> bool {
4308-
type_trait_info(ty).is_some()
4309-
}
4310-
4311-
pub fn type_trait_info<'tcx>(ty: Ty<'tcx>) -> Option<&'tcx TyTrait<'tcx>> {
43124257
match ty.sty {
4313-
ty_uniq(ty) | ty_rptr(_, mt { ty, ..}) | ty_ptr(mt { ty, ..}) => match ty.sty {
4314-
ty_trait(ref t) => Some(&**t),
4315-
_ => None
4316-
},
4317-
ty_trait(ref t) => Some(&**t),
4318-
_ => None
4258+
ty_trait(..) => true,
4259+
_ => false
43194260
}
43204261
}
43214262

@@ -5399,26 +5340,6 @@ pub fn impl_or_trait_item<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
53995340
})
54005341
}
54015342

5402-
/// Returns true if the given ID refers to an associated type and false if it
5403-
/// refers to anything else.
5404-
pub fn is_associated_type(cx: &ctxt, id: ast::DefId) -> bool {
5405-
memoized(&cx.associated_types, id, |id: ast::DefId| {
5406-
if id.krate == ast::LOCAL_CRATE {
5407-
match cx.impl_or_trait_items.borrow().get(&id) {
5408-
Some(ref item) => {
5409-
match **item {
5410-
TypeTraitItem(_) => true,
5411-
_ => false,
5412-
}
5413-
}
5414-
None => false,
5415-
}
5416-
} else {
5417-
csearch::is_associated_type(&cx.sess.cstore, id)
5418-
}
5419-
})
5420-
}
5421-
54225343
/// Returns the parameter index that the given associated type corresponds to.
54235344
pub fn associated_type_parameter_index(cx: &ctxt,
54245345
trait_def: &TraitDef,
@@ -7223,32 +7144,6 @@ impl<'tcx> Repr<'tcx> for ty::Predicate<'tcx> {
72237144
}
72247145
}
72257146

7226-
impl<'tcx> Repr<'tcx> for vtable_origin<'tcx> {
7227-
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
7228-
match *self {
7229-
vtable_static(def_id, ref tys, ref vtable_res) => {
7230-
format!("vtable_static({:?}:{}, {}, {})",
7231-
def_id,
7232-
ty::item_path_str(tcx, def_id),
7233-
tys.repr(tcx),
7234-
vtable_res.repr(tcx))
7235-
}
7236-
7237-
vtable_param(x, y) => {
7238-
format!("vtable_param({:?}, {})", x, y)
7239-
}
7240-
7241-
vtable_closure(def_id) => {
7242-
format!("vtable_closure({:?})", def_id)
7243-
}
7244-
7245-
vtable_error => {
7246-
format!("vtable_error")
7247-
}
7248-
}
7249-
}
7250-
}
7251-
72527147
pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>,
72537148
trait_ref: &ty::TraitRef<'tcx>,
72547149
method: &ty::Method<'tcx>)

src/librustc/middle/ty_fold.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -336,27 +336,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::MethodOrigin<'tcx> {
336336
}
337337
}
338338

339-
impl<'tcx> TypeFoldable<'tcx> for ty::vtable_origin<'tcx> {
340-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::vtable_origin<'tcx> {
341-
match *self {
342-
ty::vtable_static(def_id, ref substs, ref origins) => {
343-
let r_substs = substs.fold_with(folder);
344-
let r_origins = origins.fold_with(folder);
345-
ty::vtable_static(def_id, r_substs, r_origins)
346-
}
347-
ty::vtable_param(n, b) => {
348-
ty::vtable_param(n, b)
349-
}
350-
ty::vtable_closure(def_id) => {
351-
ty::vtable_closure(def_id)
352-
}
353-
ty::vtable_error => {
354-
ty::vtable_error
355-
}
356-
}
357-
}
358-
}
359-
360339
impl<'tcx> TypeFoldable<'tcx> for ty::BuiltinBounds {
361340
fn fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> ty::BuiltinBounds {
362341
*self

0 commit comments

Comments
 (0)