@@ -20,16 +20,10 @@ extern crate syntax;
2020extern crate rustc_front;
2121
2222use build;
23- use graphviz;
24- use pretty;
25- use transform:: { clear_dead_blocks, simplify_cfg, type_check} ;
26- use transform:: { no_landing_pads} ;
2723use rustc:: dep_graph:: DepNode ;
2824use rustc:: mir:: repr:: Mir ;
2925use hair:: cx:: Cx ;
30- use std:: fs:: File ;
3126
32- use rustc:: mir:: transform:: MirPass ;
3327use rustc:: mir:: mir_map:: MirMap ;
3428use rustc:: middle:: infer;
3529use rustc:: middle:: region:: CodeExtentData ;
@@ -136,61 +130,16 @@ impl<'a, 'm, 'tcx> Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
136130 body : & ' tcx hir:: Block ,
137131 span : Span ,
138132 id : ast:: NodeId ) {
139- let ( prefix, implicit_arg_tys) = match fk {
140- intravisit:: FnKind :: Closure =>
141- ( format ! ( "{}-" , id) , vec ! [ closure_self_ty( & self . tcx, id, body. id) ] ) ,
142- _ =>
143- ( format ! ( "" ) , vec ! [ ] ) ,
133+ let implicit_arg_tys = if let intravisit:: FnKind :: Closure = fk {
134+ vec ! [ closure_self_ty( & self . tcx, id, body. id) ]
135+ } else {
136+ vec ! [ ]
144137 } ;
145138
146139 let param_env = ty:: ParameterEnvironment :: for_item ( self . tcx , id) ;
147-
148140 let infcx = infer:: new_infer_ctxt ( self . tcx , & self . tcx . tables , Some ( param_env) ) ;
149-
150141 match build_mir ( Cx :: new ( & infcx) , implicit_arg_tys, id, span, decl, body) {
151- Ok ( mut mir) => {
152- clear_dead_blocks:: ClearDeadBlocks :: new ( ) . run_on_mir ( & mut mir, & infcx) ;
153- type_check:: TypeckMir :: new ( ) . run_on_mir ( & mut mir, & infcx) ;
154- no_landing_pads:: NoLandingPads . run_on_mir ( & mut mir, & infcx) ;
155- if self . tcx . sess . opts . mir_opt_level > 0 {
156- simplify_cfg:: SimplifyCfg :: new ( ) . run_on_mir ( & mut mir, & infcx) ;
157- }
158- let meta_item_list = self . attr
159- . iter ( )
160- . flat_map ( |a| a. meta_item_list ( ) )
161- . flat_map ( |l| l. iter ( ) ) ;
162- for item in meta_item_list {
163- if item. check_name ( "graphviz" ) || item. check_name ( "pretty" ) {
164- match item. value_str ( ) {
165- Some ( s) => {
166- let filename = format ! ( "{}{}" , prefix, s) ;
167- let result = File :: create ( & filename) . and_then ( |ref mut output| {
168- if item. check_name ( "graphviz" ) {
169- graphviz:: write_mir_graphviz ( & mir, output)
170- } else {
171- pretty:: write_mir_pretty ( & mir, output)
172- }
173- } ) ;
174-
175- if let Err ( e) = result {
176- self . tcx . sess . span_fatal (
177- item. span ,
178- & format ! ( "Error writing MIR {} results to `{}`: {}" ,
179- item. name( ) , filename, e) ) ;
180- }
181- }
182- None => {
183- self . tcx . sess . span_err (
184- item. span ,
185- & format ! ( "{} attribute requires a path" , item. name( ) ) ) ;
186- }
187- }
188- }
189- }
190-
191- let previous = self . map . map . insert ( id, mir) ;
192- assert ! ( previous. is_none( ) ) ;
193- }
142+ Ok ( mir) => assert ! ( self . map. map. insert( id, mir) . is_none( ) ) ,
194143 Err ( ErrorReported ) => { }
195144 }
196145
0 commit comments