@@ -24,13 +24,11 @@ use middle::mem_categorization as mc;
2424use middle:: resolve;
2525use middle:: resolve_lifetime;
2626use middle:: stability;
27- use middle:: subst:: { Subst , Substs , VecPerParamSpace } ;
28- use middle:: subst;
27+ use middle:: subst:: { mod, Subst , Substs , VecPerParamSpace } ;
2928use middle:: traits;
3029use middle:: ty;
3130use middle:: typeck;
32- use middle:: ty_fold;
33- use middle:: ty_fold:: { TypeFoldable , TypeFolder } ;
31+ use middle:: ty_fold:: { mod, TypeFoldable , TypeFolder } ;
3432use middle;
3533use util:: ppaux:: { note_and_explain_region, bound_region_ptr_to_string} ;
3634use util:: ppaux:: { trait_store_to_string, ty_to_string} ;
@@ -40,10 +38,8 @@ use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet, FnvHashMap};
4038
4139use std:: cell:: { Cell , RefCell } ;
4240use std:: cmp;
43- use std:: fmt:: Show ;
44- use std:: fmt;
41+ use std:: fmt:: { mod, Show } ;
4542use std:: hash:: { Hash , sip, Writer } ;
46- use std:: iter:: AdditiveIterator ;
4743use std:: mem;
4844use std:: ops;
4945use std:: rc:: Rc ;
@@ -55,15 +51,11 @@ use syntax::ast::{CrateNum, DefId, FnStyle, Ident, ItemTrait, LOCAL_CRATE};
5551use syntax:: ast:: { MutImmutable , MutMutable , Name , NamedField , NodeId } ;
5652use syntax:: ast:: { Onceness , StmtExpr , StmtSemi , StructField , UnnamedField } ;
5753use syntax:: ast:: { Visibility } ;
58- use syntax:: ast_util:: { PostExpansionMethod , is_local, lit_is_str} ;
59- use syntax:: ast_util;
60- use syntax:: attr;
61- use syntax:: attr:: AttrMetaMethods ;
54+ use syntax:: ast_util:: { mod, PostExpansionMethod , is_local, lit_is_str} ;
55+ use syntax:: attr:: { mod, AttrMetaMethods } ;
6256use syntax:: codemap:: Span ;
63- use syntax:: parse:: token;
64- use syntax:: parse:: token:: InternedString ;
57+ use syntax:: parse:: token:: { mod, InternedString } ;
6558use syntax:: { ast, ast_map} ;
66- use syntax:: util:: small_vector:: SmallVector ;
6759use std:: collections:: enum_set:: { EnumSet , CLike } ;
6860
6961pub type Disr = u64 ;
@@ -493,7 +485,6 @@ pub struct ctxt<'tcx> {
493485 pub lang_items : middle:: lang_items:: LanguageItems ,
494486 /// A mapping of fake provided method def_ids to the default implementation
495487 pub provided_method_sources : RefCell < DefIdMap < ast:: DefId > > ,
496- pub superstructs : RefCell < DefIdMap < Option < ast:: DefId > > > ,
497488 pub struct_fields : RefCell < DefIdMap < Rc < Vec < field_ty > > > > ,
498489
499490 /// Maps from def-id of a type or region parameter to its
@@ -1512,7 +1503,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
15121503 normalized_cache : RefCell :: new ( HashMap :: new ( ) ) ,
15131504 lang_items : lang_items,
15141505 provided_method_sources : RefCell :: new ( DefIdMap :: new ( ) ) ,
1515- superstructs : RefCell :: new ( DefIdMap :: new ( ) ) ,
15161506 struct_fields : RefCell :: new ( DefIdMap :: new ( ) ) ,
15171507 destructor_for_type : RefCell :: new ( DefIdMap :: new ( ) ) ,
15181508 destructors : RefCell :: new ( DefIdSet :: new ( ) ) ,
@@ -4539,53 +4529,19 @@ pub fn lookup_field_type(tcx: &ctxt,
45394529 t. subst ( tcx, substs)
45404530}
45414531
4542- // Lookup all ancestor structs of a struct indicated by did. That is the reflexive,
4543- // transitive closure of doing a single lookup in cx.superstructs.
4544- fn each_super_struct ( cx : & ctxt , mut did : ast:: DefId , f: |ast:: DefId |) {
4545- let superstructs = cx. superstructs . borrow ( ) ;
4546-
4547- loop {
4548- f ( did) ;
4549- match superstructs. find ( & did) {
4550- Some ( & Some ( def_id) ) => {
4551- did = def_id;
4552- } ,
4553- Some ( & None ) => break ,
4554- None => {
4555- cx. sess . bug (
4556- format ! ( "ID not mapped to super-struct: {}" ,
4557- cx. map. node_to_string( did. node) ) . as_slice ( ) ) ;
4558- }
4559- }
4560- }
4561- }
4562-
45634532// Look up the list of field names and IDs for a given struct.
45644533// Fails if the id is not bound to a struct.
45654534pub fn lookup_struct_fields ( cx : & ctxt , did : ast:: DefId ) -> Vec < field_ty > {
45664535 if did. krate == ast:: LOCAL_CRATE {
4567- // We store the fields which are syntactically in each struct in cx. So
4568- // we have to walk the inheritance chain of the struct to get all the
4569- // fields (explicit and inherited) for a struct. If this is expensive
4570- // we could cache the whole list of fields here.
45714536 let struct_fields = cx. struct_fields . borrow ( ) ;
4572- let mut results: SmallVector < & [ field_ty ] > = SmallVector :: zero ( ) ;
4573- each_super_struct ( cx, did, |s| {
4574- match struct_fields. find ( & s) {
4575- Some ( fields) => results. push ( fields. as_slice ( ) ) ,
4576- _ => {
4577- cx. sess . bug (
4578- format ! ( "ID not mapped to struct fields: {}" ,
4579- cx. map. node_to_string( did. node) ) . as_slice ( ) ) ;
4580- }
4537+ match struct_fields. find ( & did) {
4538+ Some ( fields) => ( * * fields) . clone ( ) ,
4539+ _ => {
4540+ cx. sess . bug (
4541+ format ! ( "ID not mapped to struct fields: {}" ,
4542+ cx. map. node_to_string( did. node) ) . as_slice ( ) ) ;
45814543 }
4582- } ) ;
4583-
4584- let len = results. as_slice ( ) . iter ( ) . map ( |x| x. len ( ) ) . sum ( ) ;
4585- let mut result: Vec < field_ty > = Vec :: with_capacity ( len) ;
4586- result. extend ( results. as_slice ( ) . iter ( ) . flat_map ( |rs| rs. iter ( ) . map ( |f| f. clone ( ) ) ) ) ;
4587- assert ! ( result. len( ) == len) ;
4588- result
4544+ }
45894545 } else {
45904546 csearch:: get_struct_fields ( & cx. sess . cstore , did)
45914547 }
0 commit comments