]> git.lizzy.rs Git - rust.git/blob - src/librustc_mir/build/mod.rs
b206538324b4a22dc35a0100e560f0efd195c433
[rust.git] / src / librustc_mir / build / mod.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 use build;
13 use hair::cx::Cx;
14 use hair::LintLevel;
15 use rustc::hir;
16 use rustc::hir::def_id::DefId;
17 use rustc::middle::region;
18 use rustc::mir::*;
19 use rustc::mir::transform::MirSource;
20 use rustc::mir::visit::{MutVisitor, Lookup};
21 use rustc::ty::{self, Ty, TyCtxt};
22 use rustc::ty::subst::Substs;
23 use rustc::util::nodemap::NodeMap;
24 use rustc_const_eval::pattern::{BindingMode, PatternKind};
25 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
26 use shim;
27 use std::mem;
28 use std::u32;
29 use syntax::abi::Abi;
30 use syntax::ast;
31 use syntax::symbol::keywords;
32 use syntax_pos::Span;
33 use util as mir_util;
34
35 /// Construct the MIR for a given def-id.
36 pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'tcx> {
37     let id = tcx.hir.as_local_node_id(def_id).unwrap();
38     let unsupported = || {
39         span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id);
40     };
41
42     // Figure out what primary body this item has.
43     let body_id = match tcx.hir.get(id) {
44         hir::map::NodeItem(item) => {
45             match item.node {
46                 hir::ItemConst(_, body) |
47                 hir::ItemStatic(_, _, body) |
48                 hir::ItemFn(.., body) => body,
49                 _ => unsupported()
50             }
51         }
52         hir::map::NodeTraitItem(item) => {
53             match item.node {
54                 hir::TraitItemKind::Const(_, Some(body)) |
55                 hir::TraitItemKind::Method(_,
56                     hir::TraitMethod::Provided(body)) => body,
57                 _ => unsupported()
58             }
59         }
60         hir::map::NodeImplItem(item) => {
61             match item.node {
62                 hir::ImplItemKind::Const(_, body) |
63                 hir::ImplItemKind::Method(_, body) => body,
64                 _ => unsupported()
65             }
66         }
67         hir::map::NodeExpr(expr) => {
68             // FIXME(eddyb) Closures should have separate
69             // function definition IDs and expression IDs.
70             // Type-checking should not let closures get
71             // this far in a constant position.
72             // Assume that everything other than closures
73             // is a constant "initializer" expression.
74             match expr.node {
75                 hir::ExprClosure(_, _, body, _, _) => body,
76                 _ => hir::BodyId { node_id: expr.id },
77             }
78         }
79         hir::map::NodeVariant(variant) =>
80             return create_constructor_shim(tcx, id, &variant.node.data),
81         hir::map::NodeStructCtor(ctor) =>
82             return create_constructor_shim(tcx, id, ctor),
83         _ => unsupported(),
84     };
85
86     let src = MirSource::from_node(tcx, id);
87     tcx.infer_ctxt().enter(|infcx| {
88         let cx = Cx::new(&infcx, src);
89         let mut mir = if cx.tables().tainted_by_errors {
90             build::construct_error(cx, body_id)
91         } else if let MirSource::Fn(id) = src {
92             // fetch the fully liberated fn signature (that is, all bound
93             // types/lifetimes replaced)
94             let fn_hir_id = tcx.hir.node_to_hir_id(id);
95             let fn_sig = cx.tables().liberated_fn_sigs()[fn_hir_id].clone();
96
97             let ty = tcx.type_of(tcx.hir.local_def_id(id));
98             let mut abi = fn_sig.abi;
99             let implicit_argument = match ty.sty {
100                 ty::TyClosure(..) => {
101                     // HACK(eddyb) Avoid having RustCall on closures,
102                     // as it adds unnecessary (and wrong) auto-tupling.
103                     abi = Abi::Rust;
104                     Some((closure_self_ty(tcx, id, body_id), None))
105                 }
106                 ty::TyGenerator(..) => {
107                     let gen_ty =  tcx.body_tables(body_id).node_id_to_type(fn_hir_id);
108                     Some((gen_ty, None))
109                 }
110                 _ => None,
111             };
112
113             // FIXME: safety in closures
114             let safety = match fn_sig.unsafety {
115                 hir::Unsafety::Normal => Safety::Safe,
116                 hir::Unsafety::Unsafe => Safety::FnUnsafe,
117             };
118
119             let body = tcx.hir.body(body_id);
120             let explicit_arguments =
121                 body.arguments
122                     .iter()
123                     .enumerate()
124                     .map(|(index, arg)| {
125                         (fn_sig.inputs()[index], Some(&*arg.pat))
126                     });
127
128             let arguments = implicit_argument.into_iter().chain(explicit_arguments);
129
130             let (yield_ty, return_ty) = if body.is_generator {
131                 let gen_sig = cx.tables().generator_sigs()[fn_hir_id].clone().unwrap();
132                 (Some(gen_sig.yield_ty), gen_sig.return_ty)
133             } else {
134                 (None, fn_sig.output())
135             };
136
137             build::construct_fn(cx, id, arguments, safety, abi,
138                                 return_ty, yield_ty, body)
139         } else {
140             build::construct_const(cx, body_id)
141         };
142
143         // Convert the Mir to global types.
144         let mut globalizer = GlobalizeMir {
145             tcx,
146             span: mir.span
147         };
148         globalizer.visit_mir(&mut mir);
149         let mir = unsafe {
150             mem::transmute::<Mir, Mir<'tcx>>(mir)
151         };
152
153         mir_util::dump_mir(tcx, None, "mir_map", &0, src, &mir, |_, _| Ok(()) );
154
155         mir
156     })
157 }
158
159 /// A pass to lift all the types and substitutions in a Mir
160 /// to the global tcx. Sadly, we don't have a "folder" that
161 /// can change 'tcx so we have to transmute afterwards.
162 struct GlobalizeMir<'a, 'gcx: 'a> {
163     tcx: TyCtxt<'a, 'gcx, 'gcx>,
164     span: Span
165 }
166
167 impl<'a, 'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'a, 'gcx> {
168     fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: Lookup) {
169         if let Some(lifted) = self.tcx.lift(ty) {
170             *ty = lifted;
171         } else {
172             span_bug!(self.span,
173                       "found type `{:?}` with inference types/regions in MIR",
174                       ty);
175         }
176     }
177
178     fn visit_region(&mut self, region: &mut ty::Region<'tcx>, _: Location) {
179         if let Some(lifted) = self.tcx.lift(region) {
180             *region = lifted;
181         } else {
182             span_bug!(self.span,
183                       "found region `{:?}` with inference types/regions in MIR",
184                       region);
185         }
186     }
187
188     fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) {
189         if let Some(lifted) = self.tcx.lift(constant) {
190             *constant = lifted;
191         } else {
192             span_bug!(self.span,
193                       "found constant `{:?}` with inference types/regions in MIR",
194                       constant);
195         }
196     }
197
198     fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, _: Location) {
199         if let Some(lifted) = self.tcx.lift(substs) {
200             *substs = lifted;
201         } else {
202             span_bug!(self.span,
203                       "found substs `{:?}` with inference types/regions in MIR",
204                       substs);
205         }
206     }
207 }
208
209 fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
210                                      ctor_id: ast::NodeId,
211                                      v: &'tcx hir::VariantData)
212                                      -> Mir<'tcx>
213 {
214     let span = tcx.hir.span(ctor_id);
215     if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
216         tcx.infer_ctxt().enter(|infcx| {
217             let (mut mir, src) =
218                 shim::build_adt_ctor(&infcx, ctor_id, fields, span);
219
220             // Convert the Mir to global types.
221             let tcx = infcx.tcx.global_tcx();
222             let mut globalizer = GlobalizeMir {
223                 tcx,
224                 span: mir.span
225             };
226             globalizer.visit_mir(&mut mir);
227             let mir = unsafe {
228                 mem::transmute::<Mir, Mir<'tcx>>(mir)
229             };
230
231             mir_util::dump_mir(tcx, None, "mir_map", &0, src, &mir, |_, _| Ok(()) );
232
233             mir
234         })
235     } else {
236         span_bug!(span, "attempting to create MIR for non-tuple variant {:?}", v);
237     }
238 }
239
240 ///////////////////////////////////////////////////////////////////////////
241 // BuildMir -- walks a crate, looking for fn items and methods to build MIR from
242
243 pub fn closure_self_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
244                                        closure_expr_id: ast::NodeId,
245                                        body_id: hir::BodyId)
246                                        -> Ty<'tcx> {
247     let closure_expr_hir_id = tcx.hir.node_to_hir_id(closure_expr_id);
248     let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_hir_id);
249
250     let closure_def_id = tcx.hir.local_def_id(closure_expr_id);
251     let region = ty::ReFree(ty::FreeRegion {
252         scope: closure_def_id,
253         bound_region: ty::BoundRegion::BrEnv,
254     });
255     let region = tcx.mk_region(region);
256
257     match tcx.closure_kind(closure_def_id) {
258         ty::ClosureKind::Fn =>
259             tcx.mk_ref(region,
260                        ty::TypeAndMut { ty: closure_ty,
261                                         mutbl: hir::MutImmutable }),
262         ty::ClosureKind::FnMut =>
263             tcx.mk_ref(region,
264                        ty::TypeAndMut { ty: closure_ty,
265                                         mutbl: hir::MutMutable }),
266         ty::ClosureKind::FnOnce =>
267             closure_ty
268     }
269 }
270
271 struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
272     hir: Cx<'a, 'gcx, 'tcx>,
273     cfg: CFG<'tcx>,
274
275     fn_span: Span,
276     arg_count: usize,
277
278     /// the current set of scopes, updated as we traverse;
279     /// see the `scope` module for more details
280     scopes: Vec<scope::Scope<'tcx>>,
281
282     /// The current unsafe block in scope, even if it is hidden by
283     /// a PushUnsafeBlock
284     unpushed_unsafe: Safety,
285
286     /// The number of `push_unsafe_block` levels in scope
287     push_unsafe_count: usize,
288
289     /// the current set of breakables; see the `scope` module for more
290     /// details
291     breakable_scopes: Vec<scope::BreakableScope<'tcx>>,
292
293     /// the vector of all scopes that we have created thus far;
294     /// we track this for debuginfo later
295     visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
296     visibility_scope_info: IndexVec<VisibilityScope, VisibilityScopeInfo>,
297     visibility_scope: VisibilityScope,
298
299     /// Maps node ids of variable bindings to the `Local`s created for them.
300     var_indices: NodeMap<Local>,
301     local_decls: IndexVec<Local, LocalDecl<'tcx>>,
302     unit_temp: Option<Lvalue<'tcx>>,
303
304     /// cached block with the RESUME terminator; this is created
305     /// when first set of cleanups are built.
306     cached_resume_block: Option<BasicBlock>,
307     /// cached block with the RETURN terminator
308     cached_return_block: Option<BasicBlock>,
309 }
310
311 struct CFG<'tcx> {
312     basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
313 }
314
315 newtype_index!(ScopeId { derive[RustcEncodable, RustcDecodable] });
316
317 ///////////////////////////////////////////////////////////////////////////
318 /// The `BlockAnd` "monad" packages up the new basic block along with a
319 /// produced value (sometimes just unit, of course). The `unpack!`
320 /// macro (and methods below) makes working with `BlockAnd` much more
321 /// convenient.
322
323 #[must_use] // if you don't use one of these results, you're leaving a dangling edge
324 struct BlockAnd<T>(BasicBlock, T);
325
326 trait BlockAndExtension {
327     fn and<T>(self, v: T) -> BlockAnd<T>;
328     fn unit(self) -> BlockAnd<()>;
329 }
330
331 impl BlockAndExtension for BasicBlock {
332     fn and<T>(self, v: T) -> BlockAnd<T> {
333         BlockAnd(self, v)
334     }
335
336     fn unit(self) -> BlockAnd<()> {
337         BlockAnd(self, ())
338     }
339 }
340
341 /// Update a block pointer and return the value.
342 /// Use it like `let x = unpack!(block = self.foo(block, foo))`.
343 macro_rules! unpack {
344     ($x:ident = $c:expr) => {
345         {
346             let BlockAnd(b, v) = $c;
347             $x = b;
348             v
349         }
350     };
351
352     ($c:expr) => {
353         {
354             let BlockAnd(b, ()) = $c;
355             b
356         }
357     };
358 }
359
360 ///////////////////////////////////////////////////////////////////////////
361 /// the main entry point for building MIR for a function
362
363 fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
364                                    fn_id: ast::NodeId,
365                                    arguments: A,
366                                    safety: Safety,
367                                    abi: Abi,
368                                    return_ty: Ty<'gcx>,
369                                    yield_ty: Option<Ty<'gcx>>,
370                                    body: &'gcx hir::Body)
371                                    -> Mir<'tcx>
372     where A: Iterator<Item=(Ty<'gcx>, Option<&'gcx hir::Pat>)>
373 {
374     let arguments: Vec<_> = arguments.collect();
375
376     let tcx = hir.tcx();
377     let span = tcx.hir.span(fn_id);
378     let mut builder = Builder::new(hir.clone(),
379         span,
380         arguments.len(),
381         safety,
382         return_ty);
383
384     let call_site_scope = region::Scope::CallSite(body.value.hir_id.local_id);
385     let arg_scope = region::Scope::Arguments(body.value.hir_id.local_id);
386     let mut block = START_BLOCK;
387     let source_info = builder.source_info(span);
388     let call_site_s = (call_site_scope, source_info);
389     unpack!(block = builder.in_scope(call_site_s, LintLevel::Inherited, block, |builder| {
390         let arg_scope_s = (arg_scope, source_info);
391         unpack!(block = builder.in_scope(arg_scope_s, LintLevel::Inherited, block, |builder| {
392             builder.args_and_body(block, &arguments, arg_scope, &body.value)
393         }));
394         // Attribute epilogue to function's closing brace
395         let fn_end = span.with_lo(span.hi());
396         let source_info = builder.source_info(fn_end);
397         let return_block = builder.return_block();
398         builder.cfg.terminate(block, source_info,
399                               TerminatorKind::Goto { target: return_block });
400         builder.cfg.terminate(return_block, source_info,
401                               TerminatorKind::Return);
402         return_block.unit()
403     }));
404     assert_eq!(block, builder.return_block());
405
406     let mut spread_arg = None;
407     if abi == Abi::RustCall {
408         // RustCall pseudo-ABI untuples the last argument.
409         spread_arg = Some(Local::new(arguments.len()));
410     }
411
412     // Gather the upvars of a closure, if any.
413     let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| {
414         freevars.iter().map(|fv| {
415             let var_id = fv.var_id();
416             let var_hir_id = tcx.hir.node_to_hir_id(var_id);
417             let closure_expr_id = tcx.hir.local_def_id(fn_id).index;
418             let capture = hir.tables().upvar_capture(ty::UpvarId {
419                 var_id: var_hir_id,
420                 closure_expr_id,
421             });
422             let by_ref = match capture {
423                 ty::UpvarCapture::ByValue => false,
424                 ty::UpvarCapture::ByRef(..) => true
425             };
426             let mut decl = UpvarDecl {
427                 debug_name: keywords::Invalid.name(),
428                 by_ref,
429             };
430             if let Some(hir::map::NodeBinding(pat)) = tcx.hir.find(var_id) {
431                 if let hir::PatKind::Binding(_, _, ref ident, _) = pat.node {
432                     decl.debug_name = ident.node;
433                 }
434             }
435             decl
436         }).collect()
437     });
438
439     let mut mir = builder.finish(upvar_decls, return_ty, yield_ty);
440     mir.spread_arg = spread_arg;
441     mir
442 }
443
444 fn construct_const<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
445                                    body_id: hir::BodyId)
446                                    -> Mir<'tcx> {
447     let tcx = hir.tcx();
448     let ast_expr = &tcx.hir.body(body_id).value;
449     let ty = hir.tables().expr_ty_adjusted(ast_expr);
450     let owner_id = tcx.hir.body_owner(body_id);
451     let span = tcx.hir.span(owner_id);
452     let mut builder = Builder::new(hir.clone(), span, 0, Safety::Safe, ty);
453
454     let mut block = START_BLOCK;
455     let expr = builder.hir.mirror(ast_expr);
456     unpack!(block = builder.into_expr(&Lvalue::Local(RETURN_POINTER), block, expr));
457
458     let source_info = builder.source_info(span);
459     builder.cfg.terminate(block, source_info, TerminatorKind::Return);
460
461     // Constants can't `return` so a return block should not be created.
462     assert_eq!(builder.cached_return_block, None);
463
464     builder.finish(vec![], ty, None)
465 }
466
467 fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
468                                    body_id: hir::BodyId)
469                                    -> Mir<'tcx> {
470     let owner_id = hir.tcx().hir.body_owner(body_id);
471     let span = hir.tcx().hir.span(owner_id);
472     let ty = hir.tcx().types.err;
473     let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty);
474     let source_info = builder.source_info(span);
475     builder.cfg.terminate(START_BLOCK, source_info, TerminatorKind::Unreachable);
476     builder.finish(vec![], ty, None)
477 }
478
479 impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
480     fn new(hir: Cx<'a, 'gcx, 'tcx>,
481            span: Span,
482            arg_count: usize,
483            safety: Safety,
484            return_ty: Ty<'tcx>)
485            -> Builder<'a, 'gcx, 'tcx> {
486         let lint_level = LintLevel::Explicit(hir.root_lint_level);
487         let mut builder = Builder {
488             hir,
489             cfg: CFG { basic_blocks: IndexVec::new() },
490             fn_span: span,
491             arg_count,
492             scopes: vec![],
493             visibility_scopes: IndexVec::new(),
494             visibility_scope: ARGUMENT_VISIBILITY_SCOPE,
495             visibility_scope_info: IndexVec::new(),
496             push_unsafe_count: 0,
497             unpushed_unsafe: safety,
498             breakable_scopes: vec![],
499             local_decls: IndexVec::from_elem_n(LocalDecl::new_return_pointer(return_ty,
500                                                                              span), 1),
501             var_indices: NodeMap(),
502             unit_temp: None,
503             cached_resume_block: None,
504             cached_return_block: None
505         };
506
507         assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
508         assert_eq!(
509             builder.new_visibility_scope(span, lint_level, Some(safety)),
510             ARGUMENT_VISIBILITY_SCOPE);
511         builder.visibility_scopes[ARGUMENT_VISIBILITY_SCOPE].parent_scope = None;
512
513         builder
514     }
515
516     fn finish(self,
517               upvar_decls: Vec<UpvarDecl>,
518               return_ty: Ty<'tcx>,
519               yield_ty: Option<Ty<'tcx>>)
520               -> Mir<'tcx> {
521         for (index, block) in self.cfg.basic_blocks.iter().enumerate() {
522             if block.terminator.is_none() {
523                 span_bug!(self.fn_span, "no terminator on block {:?}", index);
524             }
525         }
526
527         Mir::new(self.cfg.basic_blocks,
528                  self.visibility_scopes,
529                  ClearOnDecode::Set(self.visibility_scope_info),
530                  IndexVec::new(),
531                  return_ty,
532                  yield_ty,
533                  self.local_decls,
534                  self.arg_count,
535                  upvar_decls,
536                  self.fn_span
537         )
538     }
539
540     fn args_and_body(&mut self,
541                      mut block: BasicBlock,
542                      arguments: &[(Ty<'gcx>, Option<&'gcx hir::Pat>)],
543                      argument_scope: region::Scope,
544                      ast_body: &'gcx hir::Expr)
545                      -> BlockAnd<()>
546     {
547         // Allocate locals for the function arguments
548         for &(ty, pattern) in arguments.iter() {
549             // If this is a simple binding pattern, give the local a nice name for debuginfo.
550             let mut name = None;
551             if let Some(pat) = pattern {
552                 if let hir::PatKind::Binding(_, _, ref ident, _) = pat.node {
553                     name = Some(ident.node);
554                 }
555             }
556
557             self.local_decls.push(LocalDecl {
558                 mutability: Mutability::Not,
559                 ty,
560                 source_info: SourceInfo {
561                     scope: ARGUMENT_VISIBILITY_SCOPE,
562                     span: pattern.map_or(self.fn_span, |pat| pat.span)
563                 },
564                 lexical_scope: ARGUMENT_VISIBILITY_SCOPE,
565                 name,
566                 internal: false,
567                 is_user_variable: false,
568             });
569         }
570
571         let mut scope = None;
572         // Bind the argument patterns
573         for (index, &(ty, pattern)) in arguments.iter().enumerate() {
574             // Function arguments always get the first Local indices after the return pointer
575             let local = Local::new(index + 1);
576             let lvalue = Lvalue::Local(local);
577
578             if let Some(pattern) = pattern {
579                 let pattern = self.hir.pattern_from_hir(pattern);
580
581                 match *pattern.kind {
582                     // Don't introduce extra copies for simple bindings
583                     PatternKind::Binding { mutability, var, mode: BindingMode::ByValue, .. } => {
584                         self.local_decls[local].mutability = mutability;
585                         self.var_indices.insert(var, local);
586                     }
587                     _ => {
588                         scope = self.declare_bindings(scope, ast_body.span,
589                                                       LintLevel::Inherited, &pattern);
590                         unpack!(block = self.lvalue_into_pattern(block, pattern, &lvalue));
591                     }
592                 }
593             }
594
595             // Make sure we drop (parts of) the argument even when not matched on.
596             self.schedule_drop(pattern.as_ref().map_or(ast_body.span, |pat| pat.span),
597                                argument_scope, &lvalue, ty);
598
599         }
600
601         // Enter the argument pattern bindings visibility scope, if it exists.
602         if let Some(visibility_scope) = scope {
603             self.visibility_scope = visibility_scope;
604         }
605
606         let body = self.hir.mirror(ast_body);
607         self.into(&Lvalue::Local(RETURN_POINTER), block, body)
608     }
609
610     fn get_unit_temp(&mut self) -> Lvalue<'tcx> {
611         match self.unit_temp {
612             Some(ref tmp) => tmp.clone(),
613             None => {
614                 let ty = self.hir.unit_ty();
615                 let fn_span = self.fn_span;
616                 let tmp = self.temp(ty, fn_span);
617                 self.unit_temp = Some(tmp.clone());
618                 tmp
619             }
620         }
621     }
622
623     fn return_block(&mut self) -> BasicBlock {
624         match self.cached_return_block {
625             Some(rb) => rb,
626             None => {
627                 let rb = self.cfg.start_new_block();
628                 self.cached_return_block = Some(rb);
629                 rb
630             }
631         }
632     }
633 }
634
635 ///////////////////////////////////////////////////////////////////////////
636 // Builder methods are broken up into modules, depending on what kind
637 // of thing is being translated. Note that they use the `unpack` macro
638 // above extensively.
639
640 mod block;
641 mod cfg;
642 mod expr;
643 mod into;
644 mod matches;
645 mod misc;
646 mod scope;