@@ -34,15 +34,14 @@ use rustc::hir;
34
34
use rustc:: hir:: intravisit:: { self , Visitor } ;
35
35
use syntax:: abi:: Abi ;
36
36
use syntax:: ast;
37
- use syntax:: attr:: AttrMetaMethods ;
38
37
use syntax:: codemap:: Span ;
39
38
40
39
pub fn build_mir_for_crate < ' tcx > ( tcx : & TyCtxt < ' tcx > ) -> MirMap < ' tcx > {
41
40
let mut map = MirMap {
42
41
map : NodeMap ( ) ,
43
42
} ;
44
43
{
45
- let mut dump = OuterDump {
44
+ let mut dump = BuildMir {
46
45
tcx : tcx,
47
46
map : & mut map,
48
47
} ;
@@ -52,79 +51,14 @@ pub fn build_mir_for_crate<'tcx>(tcx: &TyCtxt<'tcx>) -> MirMap<'tcx> {
52
51
}
53
52
54
53
///////////////////////////////////////////////////////////////////////////
55
- // OuterDump -- walks a crate, looking for fn items and methods to build MIR from
54
+ // BuildMir -- walks a crate, looking for fn items and methods to build MIR from
56
55
57
- struct OuterDump < ' a , ' tcx : ' a > {
56
+ struct BuildMir < ' a , ' tcx : ' a > {
58
57
tcx : & ' a TyCtxt < ' tcx > ,
59
58
map : & ' a mut MirMap < ' tcx > ,
60
59
}
61
60
62
- impl < ' a , ' tcx > OuterDump < ' a , ' tcx > {
63
- fn visit_mir < OP > ( & mut self , attributes : & ' a [ ast:: Attribute ] , mut walk_op : OP )
64
- where OP : for < ' m > FnMut ( & mut InnerDump < ' a , ' m , ' tcx > )
65
- {
66
- let mut closure_dump = InnerDump {
67
- tcx : self . tcx ,
68
- attr : None ,
69
- map : & mut * self . map ,
70
- } ;
71
- for attr in attributes {
72
- if attr. check_name ( "rustc_mir" ) {
73
- closure_dump. attr = Some ( attr) ;
74
- }
75
- }
76
- walk_op ( & mut closure_dump) ;
77
- }
78
- }
79
-
80
-
81
- impl < ' a , ' tcx > Visitor < ' tcx > for OuterDump < ' a , ' tcx > {
82
- fn visit_item ( & mut self , item : & ' tcx hir:: Item ) {
83
- self . visit_mir ( & item. attrs , |c| intravisit:: walk_item ( c, item) ) ;
84
- intravisit:: walk_item ( self , item) ;
85
- }
86
-
87
- fn visit_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem ) {
88
- match trait_item. node {
89
- hir:: MethodTraitItem ( _, Some ( _) ) => {
90
- self . visit_mir ( & trait_item. attrs , |c| intravisit:: walk_trait_item ( c, trait_item) ) ;
91
- }
92
- hir:: MethodTraitItem ( _, None ) |
93
- hir:: ConstTraitItem ( ..) |
94
- hir:: TypeTraitItem ( ..) => { }
95
- }
96
- intravisit:: walk_trait_item ( self , trait_item) ;
97
- }
98
-
99
- fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem ) {
100
- match impl_item. node {
101
- hir:: ImplItemKind :: Method ( ..) => {
102
- self . visit_mir ( & impl_item. attrs , |c| intravisit:: walk_impl_item ( c, impl_item) ) ;
103
- }
104
- hir:: ImplItemKind :: Const ( ..) | hir:: ImplItemKind :: Type ( ..) => { }
105
- }
106
- intravisit:: walk_impl_item ( self , impl_item) ;
107
- }
108
- }
109
-
110
- ///////////////////////////////////////////////////////////////////////////
111
- // InnerDump -- dumps MIR for a single fn and its contained closures
112
-
113
- struct InnerDump < ' a , ' m , ' tcx : ' a + ' m > {
114
- tcx : & ' a TyCtxt < ' tcx > ,
115
- map : & ' m mut MirMap < ' tcx > ,
116
- attr : Option < & ' a ast:: Attribute > ,
117
- }
118
-
119
- impl < ' a , ' m , ' tcx > Visitor < ' tcx > for InnerDump < ' a , ' m , ' tcx > {
120
- fn visit_trait_item ( & mut self , _: & ' tcx hir:: TraitItem ) {
121
- // ignore methods; the outer dump will call us for them independently
122
- }
123
-
124
- fn visit_impl_item ( & mut self , _: & ' tcx hir:: ImplItem ) {
125
- // ignore methods; the outer dump will call us for them independently
126
- }
127
-
61
+ impl < ' a , ' tcx > Visitor < ' tcx > for BuildMir < ' a , ' tcx > {
128
62
fn visit_fn ( & mut self ,
129
63
fk : intravisit:: FnKind < ' tcx > ,
130
64
decl : & ' tcx hir:: FnDecl ,
0 commit comments