@@ -24,13 +24,11 @@ use middle::mem_categorization as mc;
24
24
use middle:: resolve;
25
25
use middle:: resolve_lifetime;
26
26
use middle:: stability;
27
- use middle:: subst:: { Subst , Substs , VecPerParamSpace } ;
28
- use middle:: subst;
27
+ use middle:: subst:: { mod, Subst , Substs , VecPerParamSpace } ;
29
28
use middle:: traits;
30
29
use middle:: ty;
31
30
use middle:: typeck;
32
- use middle:: ty_fold;
33
- use middle:: ty_fold:: { TypeFoldable , TypeFolder } ;
31
+ use middle:: ty_fold:: { mod, TypeFoldable , TypeFolder } ;
34
32
use middle;
35
33
use util:: ppaux:: { note_and_explain_region, bound_region_ptr_to_string} ;
36
34
use util:: ppaux:: { trait_store_to_string, ty_to_string} ;
@@ -40,10 +38,8 @@ use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet, FnvHashMap};
40
38
41
39
use std:: cell:: { Cell , RefCell } ;
42
40
use std:: cmp;
43
- use std:: fmt:: Show ;
44
- use std:: fmt;
41
+ use std:: fmt:: { mod, Show } ;
45
42
use std:: hash:: { Hash , sip, Writer } ;
46
- use std:: iter:: AdditiveIterator ;
47
43
use std:: mem;
48
44
use std:: ops;
49
45
use std:: rc:: Rc ;
@@ -55,15 +51,11 @@ use syntax::ast::{CrateNum, DefId, FnStyle, Ident, ItemTrait, LOCAL_CRATE};
55
51
use syntax:: ast:: { MutImmutable , MutMutable , Name , NamedField , NodeId } ;
56
52
use syntax:: ast:: { Onceness , StmtExpr , StmtSemi , StructField , UnnamedField } ;
57
53
use 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 } ;
62
56
use syntax:: codemap:: Span ;
63
- use syntax:: parse:: token;
64
- use syntax:: parse:: token:: InternedString ;
57
+ use syntax:: parse:: token:: { mod, InternedString } ;
65
58
use syntax:: { ast, ast_map} ;
66
- use syntax:: util:: small_vector:: SmallVector ;
67
59
use std:: collections:: enum_set:: { EnumSet , CLike } ;
68
60
69
61
pub type Disr = u64 ;
@@ -493,7 +485,6 @@ pub struct ctxt<'tcx> {
493
485
pub lang_items : middle:: lang_items:: LanguageItems ,
494
486
/// A mapping of fake provided method def_ids to the default implementation
495
487
pub provided_method_sources : RefCell < DefIdMap < ast:: DefId > > ,
496
- pub superstructs : RefCell < DefIdMap < Option < ast:: DefId > > > ,
497
488
pub struct_fields : RefCell < DefIdMap < Rc < Vec < field_ty > > > > ,
498
489
499
490
/// Maps from def-id of a type or region parameter to its
@@ -1512,7 +1503,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
1512
1503
normalized_cache : RefCell :: new ( HashMap :: new ( ) ) ,
1513
1504
lang_items : lang_items,
1514
1505
provided_method_sources : RefCell :: new ( DefIdMap :: new ( ) ) ,
1515
- superstructs : RefCell :: new ( DefIdMap :: new ( ) ) ,
1516
1506
struct_fields : RefCell :: new ( DefIdMap :: new ( ) ) ,
1517
1507
destructor_for_type : RefCell :: new ( DefIdMap :: new ( ) ) ,
1518
1508
destructors : RefCell :: new ( DefIdSet :: new ( ) ) ,
@@ -4539,53 +4529,19 @@ pub fn lookup_field_type(tcx: &ctxt,
4539
4529
t. subst ( tcx, substs)
4540
4530
}
4541
4531
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
-
4563
4532
// Look up the list of field names and IDs for a given struct.
4564
4533
// Fails if the id is not bound to a struct.
4565
4534
pub fn lookup_struct_fields ( cx : & ctxt , did : ast:: DefId ) -> Vec < field_ty > {
4566
4535
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.
4571
4536
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 ( ) ) ;
4581
4543
}
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
+ }
4589
4545
} else {
4590
4546
csearch:: get_struct_fields ( & cx. sess . cstore , did)
4591
4547
}
0 commit comments