diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2014-09-06 19:13:04 +0300 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2014-09-08 15:28:24 +0300 |
| commit | f7a997be05e364248521ee4d11ab57fcb2e99a40 (patch) | |
| tree | 8894b56715c16ec48e720575e8892fd81e396392 | |
| parent | 28be695b2c727b380d075986cbe52e699761b56e (diff) | |
| download | rust-f7a997be05e364248521ee4d11ab57fcb2e99a40.tar.gz rust-f7a997be05e364248521ee4d11ab57fcb2e99a40.zip | |
rustc: fix fallout from the addition of a 'tcx lifetime on trans::Block.
| -rw-r--r-- | src/librustc/middle/trans/_match.rs | 297 | ||||
| -rw-r--r-- | src/librustc/middle/trans/adt.rs | 32 | ||||
| -rw-r--r-- | src/librustc/middle/trans/asm.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/trans/base.rs | 256 | ||||
| -rw-r--r-- | src/librustc/middle/trans/build.rs | 216 | ||||
| -rw-r--r-- | src/librustc/middle/trans/callee.rs | 135 | ||||
| -rw-r--r-- | src/librustc/middle/trans/cleanup.rs | 92 | ||||
| -rw-r--r-- | src/librustc/middle/trans/closure.rs | 81 | ||||
| -rw-r--r-- | src/librustc/middle/trans/common.rs | 63 | ||||
| -rw-r--r-- | src/librustc/middle/trans/controlflow.rs | 114 | ||||
| -rw-r--r-- | src/librustc/middle/trans/datum.rs | 191 | ||||
| -rw-r--r-- | src/librustc/middle/trans/debuginfo.rs | 10 | ||||
| -rw-r--r-- | src/librustc/middle/trans/expr.rs | 421 | ||||
| -rw-r--r-- | src/librustc/middle/trans/foreign.rs | 15 | ||||
| -rw-r--r-- | src/librustc/middle/trans/glue.rs | 81 | ||||
| -rw-r--r-- | src/librustc/middle/trans/intrinsic.rs | 17 | ||||
| -rw-r--r-- | src/librustc/middle/trans/meth.rs | 72 | ||||
| -rw-r--r-- | src/librustc/middle/trans/reflect.rs | 19 | ||||
| -rw-r--r-- | src/librustc/middle/trans/tvec.rs | 112 | ||||
| -rw-r--r-- | src/librustc/middle/trans/value.rs | 2 |
20 files changed, 1095 insertions, 1135 deletions
diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 1b93e197441..dd0668b8fa0 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -225,14 +225,14 @@ use syntax::ast::Ident; use syntax::codemap::Span; use syntax::fold::Folder; -struct ConstantExpr<'a>(&'a ty::ctxt, Gc<ast::Expr>); +struct ConstantExpr<'a, 'tcx: 'a>(&'a ty::ctxt<'tcx>, Gc<ast::Expr>); -impl<'a> Eq for ConstantExpr<'a> { +impl<'a, 'tcx> Eq for ConstantExpr<'a, 'tcx> { fn assert_receiver_is_total_eq(&self) {} } -impl<'a> PartialEq for ConstantExpr<'a> { - fn eq(&self, other: &ConstantExpr<'a>) -> bool { +impl<'a, 'tcx> PartialEq for ConstantExpr<'a, 'tcx> { + fn eq(&self, other: &ConstantExpr<'a, 'tcx>) -> bool { let &ConstantExpr(tcx, expr) = self; let &ConstantExpr(_, other_expr) = other; match const_eval::compare_lit_exprs(tcx, &*expr, &*other_expr) { @@ -244,16 +244,16 @@ impl<'a> PartialEq for ConstantExpr<'a> { // An option identifying a branch (either a literal, an enum variant or a range) #[deriving(Eq, PartialEq)] -enum Opt<'a> { - ConstantValue(ConstantExpr<'a>), - ConstantRange(ConstantExpr<'a>, ConstantExpr<'a>), +enum Opt<'blk, 'tcx: 'blk> { + ConstantValue(ConstantExpr<'blk, 'tcx>), + ConstantRange(ConstantExpr<'blk, 'tcx>, ConstantExpr<'blk, 'tcx>), Variant(ty::Disr, Rc<adt::Repr>, ast::DefId), SliceLengthEqual(uint), SliceLengthGreaterOrEqual(/* prefix length */ uint, /* suffix length */ uint), } -impl<'a> Opt<'a> { - fn trans(&self, mut bcx: &'a Block<'a>) -> OptResult<'a> { +impl<'blk, 'tcx> Opt<'blk, 'tcx> { + fn trans(&self, mut bcx: Block<'blk, 'tcx>) -> OptResult<'blk, 'tcx> { let _icx = push_ctxt("match::trans_opt"); let ccx = bcx.ccx(); match *self { @@ -293,10 +293,10 @@ pub enum BranchKind { CompareSliceLength } -pub enum OptResult<'a> { - SingleResult(Result<'a>), - RangeResult(Result<'a>, Result<'a>), - LowerBound(Result<'a>) +pub enum OptResult<'blk, 'tcx: 'blk> { + SingleResult(Result<'blk, 'tcx>), + RangeResult(Result<'blk, 'tcx>, Result<'blk, 'tcx>), + LowerBound(Result<'blk, 'tcx>) } #[deriving(Clone)] @@ -325,8 +325,8 @@ pub struct BindingInfo { type BindingsMap = HashMap<Ident, BindingInfo>; -struct ArmData<'a, 'b> { - bodycx: &'b Block<'b>, +struct ArmData<'a, 'blk, 'tcx: 'blk> { + bodycx: Block<'blk, 'tcx>, arm: &'a ast::Arm, bindings_map: BindingsMap } @@ -337,13 +337,13 @@ struct ArmData<'a, 'b> { * As we proceed `bound_ptrs` are filled with pointers to values to be bound, * these pointers are stored in llmatch variables just before executing `data` arm. */ -struct Match<'a, 'b:'a> { +struct Match<'a, 'blk: 'a, 'tcx: 'blk> { pats: Vec<Gc<ast::Pat>>, - data: &'a ArmData<'a, 'b>, + data: &'a ArmData<'a, 'blk, 'tcx>, bound_ptrs: Vec<(Ident, ValueRef)> } -impl<'a, 'b> Repr for Match<'a, 'b> { +impl<'a, 'blk, 'tcx> Repr for Match<'a, 'blk, 'tcx> { fn repr(&self, tcx: &ty::ctxt) -> String { if tcx.sess.verbose() { // for many programs, this just take too long to serialize @@ -364,12 +364,11 @@ fn has_nested_bindings(m: &[Match], col: uint) -> bool { return false; } -fn expand_nested_bindings<'a, 'b>( - bcx: &'b Block<'b>, - m: &'a [Match<'a, 'b>], - col: uint, - val: ValueRef) - -> Vec<Match<'a, 'b>> { +fn expand_nested_bindings<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + m: &'a [Match<'a, 'blk, 'tcx>], + col: uint, + val: ValueRef) + -> Vec<Match<'a, 'blk, 'tcx>> { debug!("expand_nested_bindings(bcx={}, m={}, col={}, val={})", bcx.to_str(), m.repr(bcx.tcx()), @@ -402,14 +401,13 @@ fn expand_nested_bindings<'a, 'b>( type EnterPatterns<'a> = |&[Gc<ast::Pat>]|: 'a -> Option<Vec<Gc<ast::Pat>>>; -fn enter_match<'a, 'b>( - bcx: &'b Block<'b>, - dm: &DefMap, - m: &'a [Match<'a, 'b>], - col: uint, - val: ValueRef, - e: EnterPatterns) - -> Vec<Match<'a, 'b>> { +fn enter_match<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + dm: &DefMap, + m: &'a [Match<'a, 'blk, 'tcx>], + col: uint, + val: ValueRef, + e: EnterPatterns) + -> Vec<Match<'a, 'blk, 'tcx>> { debug!("enter_match(bcx={}, m={}, col={}, val={})", bcx.to_str(), m.repr(bcx.tcx()), @@ -450,13 +448,12 @@ fn enter_match<'a, 'b>( }).collect() } -fn enter_default<'a, 'b>( - bcx: &'b Block<'b>, - dm: &DefMap, - m: &'a [Match<'a, 'b>], - col: uint, - val: ValueRef) - -> Vec<Match<'a, 'b>> { +fn enter_default<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + dm: &DefMap, + m: &'a [Match<'a, 'blk, 'tcx>], + col: uint, + val: ValueRef) + -> Vec<Match<'a, 'blk, 'tcx>> { debug!("enter_default(bcx={}, m={}, col={}, val={})", bcx.to_str(), m.repr(bcx.tcx()), @@ -502,16 +499,16 @@ fn enter_default<'a, 'b>( /// takes the complete row of patterns rather than just the first one. /// Also, most of the enter_() family functions have been unified with /// the check_match specialization step. -fn enter_opt<'a, 'b>( - bcx: &'b Block<'b>, +fn enter_opt<'a, 'blk, 'tcx>( + bcx: Block<'blk, 'tcx>, _: ast::NodeId, dm: &DefMap, - m: &'a [Match<'a, 'b>], + m: &'a [Match<'a, 'blk, 'tcx>], opt: &Opt, col: uint, variant_size: uint, val: ValueRef) - -> Vec<Match<'a, 'b>> { + -> Vec<Match<'a, 'blk, 'tcx>> { debug!("enter_opt(bcx={}, m={}, opt={:?}, col={}, val={})", bcx.to_str(), m.repr(bcx.tcx()), @@ -545,10 +542,12 @@ fn enter_opt<'a, 'b>( // Returns the options in one column of matches. An option is something that // needs to be conditionally matched at runtime; for example, the discriminant // on a set of enum variants or a literal. -fn get_branches<'a>(bcx: &'a Block, m: &[Match], col: uint) -> Vec<Opt<'a>> { +fn get_branches<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + m: &[Match], col: uint) + -> Vec<Opt<'blk, 'tcx>> { let ccx = bcx.ccx(); - fn add_to_set<'a>(set: &mut Vec<Opt<'a>>, opt: Opt<'a>) { + fn add_to_set<'blk, 'tcx>(set: &mut Vec<Opt<'blk, 'tcx>>, opt: Opt<'blk, 'tcx>) { if !set.contains(&opt) { set.push(opt); } @@ -593,17 +592,16 @@ fn get_branches<'a>(bcx: &'a Block, m: &[Match], col: uint) -> Vec<Opt<'a>> { found } -struct ExtractedBlock<'a> { - vals: Vec<ValueRef> , - bcx: &'a Block<'a>, +struct ExtractedBlock<'blk, 'tcx: 'blk> { + vals: Vec<ValueRef>, + bcx: Block<'blk, 'tcx>, } -fn extract_variant_args<'a>( - bcx: &'a Block<'a>, - repr: &adt::Repr, - disr_val: ty::Disr, - val: ValueRef) - -> ExtractedBlock<'a> { +fn extract_variant_args<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + repr: &adt::Repr, + disr_val: ty::Disr, + val: ValueRef) + -> ExtractedBlock<'blk, 'tcx> { let _icx = push_ctxt("match::extract_variant_args"); let args = Vec::from_fn(adt::num_args(repr, disr_val), |i| { adt::trans_field_ptr(bcx, repr, val, disr_val, i) @@ -621,12 +619,11 @@ fn match_datum(val: ValueRef, left_ty: ty::t) -> Datum<Lvalue> { Datum::new(val, left_ty, Lvalue) } -fn bind_subslice_pat<'a>( - bcx: &'a Block<'a>, - pat_id: ast::NodeId, - val: ValueRef, - offset_left: uint, - offset_right: uint) -> ValueRef { +fn bind_subslice_pat(bcx: Block, + pat_id: ast::NodeId, + val: ValueRef, + offset_left: uint, + offset_right: uint) -> ValueRef { let _icx = push_ctxt("match::bind_subslice_pat"); let vec_ty = node_id_type(bcx, pat_id); let vt = tvec::vec_types(bcx, ty::sequence_element_type(bcx.tcx(), ty::type_content(vec_ty))); @@ -647,13 +644,12 @@ fn bind_subslice_pat<'a>( scratch.val } -fn extract_vec_elems<'a>( - bcx: &'a Block<'a>, - left_ty: ty::t, - before: uint, - after: uint, - val: ValueRef) - -> ExtractedBlock<'a> { +fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + left_ty: ty::t, + before: uint, + after: uint, + val: ValueRef) + -> ExtractedBlock<'blk, 'tcx> { let _icx = push_ctxt("match::extract_vec_elems"); let vec_datum = match_datum(val, left_ty); let (base, len) = vec_datum.get_vec_base_and_len(bcx); @@ -714,13 +710,13 @@ fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: uint) -> bool { } /// What to do when the pattern match fails. -enum FailureHandler<'a> { +enum FailureHandler { Infallible, JumpToBasicBlock(BasicBlockRef), Unreachable } -impl<'a> FailureHandler<'a> { +impl FailureHandler { fn is_fallible(&self) -> bool { match *self { Infallible => false, @@ -732,7 +728,7 @@ impl<'a> FailureHandler<'a> { !self.is_fallible() } - fn handle_fail(&self, bcx: &Block) { + fn handle_fail(&self, bcx: Block) { match *self { Infallible => fail!("attempted to fail in an infallible failure handler!"), @@ -774,17 +770,16 @@ fn pick_col(m: &[Match]) -> uint { } // Compiles a comparison between two things. -fn compare_values<'a>( - cx: &'a Block<'a>, - lhs: ValueRef, - rhs: ValueRef, - rhs_t: ty::t) - -> Result<'a> { - fn compare_str<'a>(cx: &'a Block<'a>, - lhs: ValueRef, - rhs: ValueRef, - rhs_t: ty::t) - -> Result<'a> { +fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>, + lhs: ValueRef, + rhs: ValueRef, + rhs_t: ty::t) + -> Result<'blk, 'tcx> { + fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>, + lhs: ValueRef, + rhs: ValueRef, + rhs_t: ty::t) + -> Result<'blk, 'tcx> { let did = langcall(cx, None, format!("comparison of `{}`", @@ -819,9 +814,10 @@ fn compare_values<'a>( } } -fn insert_lllocals<'a>(mut bcx: &'a Block<'a>, bindings_map: &BindingsMap, - cs: Option<cleanup::ScopeId>) - -> &'a Block<'a> { +fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + bindings_map: &BindingsMap, + cs: Option<cleanup::ScopeId>) + -> Block<'blk, 'tcx> { /*! * For each binding in `data.bindings_map`, adds an appropriate entry into * the `fcx.lllocals` map @@ -874,15 +870,14 @@ fn insert_lllocals<'a>(mut bcx: &'a Block<'a>, bindings_map: &BindingsMap, bcx } -fn compile_guard<'a, 'b>( - bcx: &'b Block<'b>, - guard_expr: &ast::Expr, - data: &ArmData, - m: &'a [Match<'a, 'b>], - vals: &[ValueRef], - chk: &FailureHandler, - has_genuine_default: bool) - -> &'b Block<'b> { +fn compile_guard<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + guard_expr: &ast::Expr, + data: &ArmData, + m: &'a [Match<'a, 'blk, 'tcx>], + vals: &[ValueRef], + chk: &FailureHandler, + has_genuine_default: bool) + -> Block<'blk, 'tcx> { debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals={})", bcx.to_str(), bcx.expr_to_string(guard_expr), @@ -923,12 +918,11 @@ fn compile_guard<'a, 'b>( }) } -fn compile_submatch<'a, 'b>( - bcx: &'b Block<'b>, - m: &'a [Match<'a, 'b>], - vals: &[ValueRef], - chk: &FailureHandler, - has_genuine_default: bool) { +fn compile_submatch<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + m: &'a [Match<'a, 'blk, 'tcx>], + vals: &[ValueRef], + chk: &FailureHandler, + has_genuine_default: bool) { debug!("compile_submatch(bcx={}, m={}, vals={})", bcx.to_str(), m.repr(bcx.tcx()), @@ -984,14 +978,13 @@ fn compile_submatch<'a, 'b>( } } -fn compile_submatch_continue<'a, 'b>( - mut bcx: &'b Block<'b>, - m: &'a [Match<'a, 'b>], - vals: &[ValueRef], - chk: &FailureHandler, - col: uint, - val: ValueRef, - has_genuine_default: bool) { +fn compile_submatch_continue<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + m: &'a [Match<'a, 'blk, 'tcx>], + vals: &[ValueRef], + chk: &FailureHandler, + col: uint, + val: ValueRef, + has_genuine_default: bool) { let fcx = bcx.fcx; let tcx = bcx.tcx(); let dm = &tcx.def_map; @@ -1218,19 +1211,18 @@ fn compile_submatch_continue<'a, 'b>( } } -pub fn trans_match<'a>( - bcx: &'a Block<'a>, - match_expr: &ast::Expr, - discr_expr: &ast::Expr, - arms: &[ast::Arm], - dest: Dest) - -> &'a Block<'a> { +pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + match_expr: &ast::Expr, + discr_expr: &ast::Expr, + arms: &[ast::Arm], + dest: Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("match::trans_match"); trans_match_inner(bcx, match_expr.id, discr_expr, arms, dest) } /// Checks whether the binding in `discr` is assigned to anywhere in the expression `body` -fn is_discr_reassigned(bcx: &Block, discr: &ast::Expr, body: &ast::Expr) -> bool { +fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool { match discr.node { ast::ExprPath(..) => match bcx.def(discr.id) { def::DefArg(vid, _) | def::DefBinding(vid, _) | @@ -1272,7 +1264,7 @@ impl euv::Delegate for ReassignmentChecker { } } -fn create_bindings_map(bcx: &Block, pat: Gc<ast::Pat>, +fn create_bindings_map(bcx: Block, pat: Gc<ast::Pat>, discr: &ast::Expr, body: &ast::Expr) -> BindingsMap { // Create the bindings map, which is a mapping from each binding name // to an alloca() that will be the value for that local variable. @@ -1327,11 +1319,11 @@ fn create_bindings_map(bcx: &Block, pat: Gc<ast::Pat>, return bindings_map; } -fn trans_match_inner<'a>(scope_cx: &'a Block<'a>, - match_id: ast::NodeId, - discr_expr: &ast::Expr, - arms: &[ast::Arm], - dest: Dest) -> &'a Block<'a> { +fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>, + match_id: ast::NodeId, + discr_expr: &ast::Expr, + arms: &[ast::Arm], + dest: Dest) -> Block<'blk, 'tcx> { let _icx = push_ctxt("match::trans_match_inner"); let fcx = scope_cx.fcx; let mut bcx = scope_cx; @@ -1402,9 +1394,9 @@ enum IrrefutablePatternBindingMode { BindArgument } -pub fn store_local<'a>(bcx: &'a Block<'a>, - local: &ast::Local) - -> &'a Block<'a> { +pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + local: &ast::Local) + -> Block<'blk, 'tcx> { /*! * Generates code for a local variable declaration like * `let <pat>;` or `let <pat> = <opt_init_expr>`. @@ -1457,9 +1449,9 @@ pub fn store_local<'a>(bcx: &'a Block<'a>, } }; - fn create_dummy_locals<'a>(mut bcx: &'a Block<'a>, - pat: Gc<ast::Pat>) - -> &'a Block<'a> { + fn create_dummy_locals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + pat: Gc<ast::Pat>) + -> Block<'blk, 'tcx> { // create dummy memory for the variables if we have no // value to store into them immediately let tcx = bcx.tcx(); @@ -1473,11 +1465,11 @@ pub fn store_local<'a>(bcx: &'a Block<'a>, } } -pub fn store_arg<'a>(mut bcx: &'a Block<'a>, - pat: Gc<ast::Pat>, - arg: Datum<Rvalue>, - arg_scope: cleanup::ScopeId) - -> &'a Block<'a> { +pub fn store_arg<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + pat: Gc<ast::Pat>, + arg: Datum<Rvalue>, + arg_scope: cleanup::ScopeId) + -> Block<'blk, 'tcx> { /*! * Generates code for argument patterns like `fn foo(<pat>: T)`. * Creates entries in the `llargs` map for each of the bindings @@ -1527,12 +1519,11 @@ pub fn store_arg<'a>(mut bcx: &'a Block<'a>, /// Generates code for the pattern binding in a `for` loop like /// `for <pat> in <expr> { ... }`. -pub fn store_for_loop_binding<'a>( - bcx: &'a Block<'a>, - pat: Gc<ast::Pat>, - llvalue: ValueRef, - body_scope: cleanup::ScopeId) - -> &'a Block<'a> { +pub fn store_for_loop_binding<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + pat: Gc<ast::Pat>, + llvalue: ValueRef, + body_scope: cleanup::ScopeId) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("match::store_for_loop_binding"); if simple_identifier(&*pat).is_some() { @@ -1550,14 +1541,15 @@ pub fn store_for_loop_binding<'a>( bind_irrefutable_pat(bcx, pat, llvalue, BindLocal, body_scope) } -fn mk_binding_alloca<'a,A>(bcx: &'a Block<'a>, - p_id: ast::NodeId, - ident: &ast::Ident, - binding_mode: IrrefutablePatternBindingMode, - cleanup_scope: cleanup::ScopeId, - arg: A, - populate: |A, &'a Block<'a>, ValueRef, ty::t| -> &'a Block<'a>) - -> &'a Block<'a> { +fn mk_binding_alloca<'blk, 'tcx, A>(bcx: Block<'blk, 'tcx>, + p_id: ast::NodeId, + ident: &ast::Ident, + binding_mode: IrrefutablePatternBindingMode, + cleanup_scope: cleanup::ScopeId, + arg: A, + populate: |A, Block<'blk, 'tcx>, ValueRef, ty::t| + -> Block<'blk, 'tcx>) + -> Block<'blk, 'tcx> { let var_ty = node_id_type(bcx, p_id); // Allocate memory on stack for the binding. @@ -1580,13 +1572,12 @@ fn mk_binding_alloca<'a,A>(bcx: &'a Block<'a>, bcx } -fn bind_irrefutable_pat<'a>( - bcx: &'a Block<'a>, - pat: Gc<ast::Pat>, - val: ValueRef, - binding_mode: IrrefutablePatternBindingMode, - cleanup_scope: cleanup::ScopeId) - -> &'a Block<'a> { +fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + pat: Gc<ast::Pat>, + val: ValueRef, + binding_mode: IrrefutablePatternBindingMode, + cleanup_scope: cleanup::ScopeId) + -> Block<'blk, 'tcx> { /*! * A simple version of the pattern matching code that only handles * irrefutable patterns. This is used in let/argument patterns, diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 21673a67ea8..e62e3563a0a 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -143,7 +143,7 @@ pub struct Struct { * these, for places in trans where the `ty::t` isn't directly * available. */ -pub fn represent_node(bcx: &Block, node: ast::NodeId) -> Rc<Repr> { +pub fn represent_node(bcx: Block, node: ast::NodeId) -> Rc<Repr> { represent_type(bcx.ccx(), node_id_type(bcx, node)) } @@ -574,7 +574,7 @@ fn struct_llfields(cx: &CrateContext, st: &Struct, sizing: bool, dst: bool) -> V * * This should ideally be less tightly tied to `_match`. */ -pub fn trans_switch(bcx: &Block, r: &Repr, scrutinee: ValueRef) +pub fn trans_switch(bcx: Block, r: &Repr, scrutinee: ValueRef) -> (_match::BranchKind, Option<ValueRef>) { match *r { CEnum(..) | General(..) | @@ -590,7 +590,7 @@ pub fn trans_switch(bcx: &Block, r: &Repr, scrutinee: ValueRef) /// Obtain the actual discriminant of a value. -pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>) +pub fn trans_get_discr(bcx: Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>) -> ValueRef { let signed; let val; @@ -625,7 +625,7 @@ pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Opti } } -fn struct_wrapped_nullable_bitdiscr(bcx: &Block, nndiscr: Disr, ptrfield: PointerField, +fn struct_wrapped_nullable_bitdiscr(bcx: Block, nndiscr: Disr, ptrfield: PointerField, scrutinee: ValueRef) -> ValueRef { let llptrptr = match ptrfield { ThinPointer(field) => GEPi(bcx, scrutinee, [0, field]), @@ -637,7 +637,7 @@ fn struct_wrapped_nullable_bitdiscr(bcx: &Block, nndiscr: Disr, ptrfield: Pointe } /// Helper for cases where the discriminant is simply loaded. -fn load_discr(bcx: &Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) +fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) -> ValueRef { let llty = ll_inttype(bcx.ccx(), ity); assert_eq!(val_ty(ptr), llty.ptr_to()); @@ -666,8 +666,8 @@ fn load_discr(bcx: &Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) * * This should ideally be less tightly tied to `_match`. */ -pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr) - -> _match::OptResult<'a> { +pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr) + -> _match::OptResult<'blk, 'tcx> { match *r { CEnum(ity, _, _) => { _match::SingleResult(Result::new(bcx, C_integral(ll_inttype(bcx.ccx(), ity), @@ -692,7 +692,7 @@ pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr) * Set the discriminant for a new value of the given case of the given * representation. */ -pub fn trans_set_discr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr) { +pub fn trans_set_discr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr) { match *r { CEnum(ity, min, max) => { assert_discr_in_range(ity, min, max, discr); @@ -770,7 +770,7 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint { } /// Access a field, at a point when the value's case is known. -pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr, +pub fn trans_field_ptr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr, ix: uint) -> ValueRef { // Note: if this ever needs to generate conditionals (e.g., if we // decide to do some kind of cdr-coding-like non-unique repr @@ -809,7 +809,7 @@ pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr, } } -pub fn struct_field_ptr(bcx: &Block, st: &Struct, val: ValueRef, +pub fn struct_field_ptr(bcx: Block, st: &Struct, val: ValueRef, ix: uint, needs_cast: bool) -> ValueRef { let val = if needs_cast { let ccx = bcx.ccx(); @@ -823,10 +823,10 @@ pub fn struct_field_ptr(bcx: &Block, st: &Struct, val: ValueRef, GEPi(bcx, val, [0, ix]) } -pub fn fold_variants<'r, 'b>( - bcx: &'b Block<'b>, r: &Repr, value: ValueRef, - f: |&'b Block<'b>, &Struct, ValueRef|: 'r -> &'b Block<'b> -) -> &'b Block<'b> { +pub fn fold_variants<'blk, 'tcx>( + bcx: Block<'blk, 'tcx>, r: &Repr, value: ValueRef, + f: |Block<'blk, 'tcx>, &Struct, ValueRef| -> Block<'blk, 'tcx>) + -> Block<'blk, 'tcx> { let fcx = bcx.fcx; match *r { Univariant(ref st, _) => { @@ -864,8 +864,8 @@ pub fn fold_variants<'r, 'b>( } /// Access the struct drop flag, if present. -pub fn trans_drop_flag_ptr<'b>(mut bcx: &'b Block<'b>, r: &Repr, - val: ValueRef) -> datum::DatumBlock<'b, datum::Expr> { +pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr, val: ValueRef) + -> datum::DatumBlock<'blk, 'tcx, datum::Expr> { let ptr_ty = ty::mk_imm_ptr(bcx.tcx(), ty::mk_bool()); match *r { Univariant(ref st, true) => { diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index be5f586bb97..7fb692c270e 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -27,8 +27,8 @@ use std::string::String; use syntax::ast; // Take an inline assembly expression and splat it out via LLVM -pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm) - -> &'a Block<'a> { +pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) + -> Block<'blk, 'tcx> { let fcx = bcx.fcx; let mut bcx = bcx; let mut constraints = Vec::new(); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index dc1be08e444..dc2aa16eb72 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -344,7 +344,7 @@ pub fn get_extern_const(externs: &mut ExternMap, llmod: ModuleRef, // Returns a pointer to the body for the box. The box may be an opaque // box. The result will be casted to the type of body_t, if it is statically // known. -pub fn at_box_body(bcx: &Block, body_t: ty::t, boxptr: ValueRef) -> ValueRef { +pub fn at_box_body(bcx: Block, body_t: ty::t, boxptr: ValueRef) -> ValueRef { let _icx = push_ctxt("at_box_body"); let ccx = bcx.ccx(); let ty = Type::at_box(ccx, type_of(ccx, body_t)); @@ -352,7 +352,7 @@ pub fn at_box_body(bcx: &Block, body_t: ty::t, boxptr: ValueRef) -> ValueRef { GEPi(bcx, boxptr, [0u, abi::box_field_body]) } -fn require_alloc_fn(bcx: &Block, info_ty: ty::t, it: LangItem) -> ast::DefId { +fn require_alloc_fn(bcx: Block, info_ty: ty::t, it: LangItem) -> ast::DefId { match bcx.tcx().lang_items.require(it) { Ok(id) => id, Err(s) => { @@ -366,12 +366,12 @@ fn require_alloc_fn(bcx: &Block, info_ty: ty::t, it: LangItem) -> ast::DefId { // The following malloc_raw_dyn* functions allocate a box to contain // a given type, but with a potentially dynamic size. -pub fn malloc_raw_dyn<'a>(bcx: &'a Block<'a>, - llty_ptr: Type, - info_ty: ty::t, - size: ValueRef, - align: ValueRef) - -> Result<'a> { +pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + llty_ptr: Type, + info_ty: ty::t, + size: ValueRef, + align: ValueRef) + -> Result<'blk, 'tcx> { let _icx = push_ctxt("malloc_raw_exchange"); // Allocate space: @@ -383,9 +383,9 @@ pub fn malloc_raw_dyn<'a>(bcx: &'a Block<'a>, Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr)) } -pub fn malloc_raw_dyn_proc<'a>( - bcx: &'a Block<'a>, - t: ty::t, alloc_fn: LangItem) -> Result<'a> { +pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + t: ty::t, alloc_fn: LangItem) + -> Result<'blk, 'tcx> { let _icx = push_ctxt("malloc_raw_dyn_proc"); let ccx = bcx.ccx(); @@ -414,12 +414,11 @@ pub fn malloc_raw_dyn_proc<'a>( } -pub fn malloc_raw_dyn_managed<'a>( - bcx: &'a Block<'a>, - t: ty::t, - alloc_fn: LangItem, - size: ValueRef) - -> Result<'a> { +pub fn malloc_raw_dyn_managed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + t: ty::t, + alloc_fn: LangItem, + size: ValueRef) + -> Result<'blk, 'tcx> { let _icx = push_ctxt("malloc_raw_dyn_managed"); let ccx = bcx.ccx(); @@ -585,13 +584,12 @@ pub fn maybe_name_value(cx: &CrateContext, v: ValueRef, s: &str) { // Used only for creating scalar comparison glue. pub enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, } -pub fn compare_scalar_types<'a>( - cx: &'a Block<'a>, - lhs: ValueRef, - rhs: ValueRef, - t: ty::t, - op: ast::BinOp) - -> Result<'a> { +pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>, + lhs: ValueRef, + rhs: ValueRef, + t: ty::t, + op: ast::BinOp) + -> Result<'blk, 'tcx> { let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op)); match ty::get(t).sty { @@ -607,15 +605,14 @@ pub fn compare_scalar_types<'a>( // A helper function to do the actual comparison of scalar values. -pub fn compare_scalar_values<'a>( - cx: &'a Block<'a>, - lhs: ValueRef, - rhs: ValueRef, - nt: scalar_type, - op: ast::BinOp) - -> ValueRef { +pub fn compare_scalar_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>, + lhs: ValueRef, + rhs: ValueRef, + nt: scalar_type, + op: ast::BinOp) + -> ValueRef { let _icx = push_ctxt("compare_scalar_values"); - fn die(cx: &Block) -> ! { + fn die(cx: Block) -> ! { cx.sess().bug("compare_scalar_values: must be a comparison operator"); } match nt { @@ -669,7 +666,7 @@ pub fn compare_scalar_values<'a>( } pub fn compare_simd_types( - cx: &Block, + cx: Block, lhs: ValueRef, rhs: ValueRef, t: ty::t, @@ -706,28 +703,24 @@ pub fn compare_simd_types( } } -pub type val_and_ty_fn<'r,'b> = - |&'b Block<'b>, ValueRef, ty::t|: 'r -> &'b Block<'b>; +pub type val_and_ty_fn<'a, 'blk, 'tcx> = + |Block<'blk, 'tcx>, ValueRef, ty::t|: 'a -> Block<'blk, 'tcx>; // Iterates through the elements of a structural type. -pub fn iter_structural_ty<'r, - 'b>( - cx: &'b Block<'b>, - av: ValueRef, - t: ty::t, - f: val_and_ty_fn<'r,'b>) - -> &'b Block<'b> { +pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, + av: ValueRef, + t: ty::t, + f: val_and_ty_fn<'a, 'blk, 'tcx>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("iter_structural_ty"); - fn iter_variant<'r, - 'b>( - cx: &'b Block<'b>, - repr: &adt::Repr, - av: ValueRef, - variant: &ty::VariantInfo, - substs: &subst::Substs, - f: val_and_ty_fn<'r,'b>) - -> &'b Block<'b> { + fn iter_variant<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, + repr: &adt::Repr, + av: ValueRef, + variant: &ty::VariantInfo, + substs: &subst::Substs, + f: val_and_ty_fn<'a, 'blk, 'tcx>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("iter_variant"); let tcx = cx.tcx(); let mut cx = cx; @@ -847,8 +840,7 @@ pub fn iter_structural_ty<'r, return cx; } -pub fn cast_shift_expr_rhs<'a>( - cx: &'a Block<'a>, +pub fn cast_shift_expr_rhs(cx: Block, op: ast::BinOp, lhs: ValueRef, rhs: ValueRef) @@ -895,14 +887,14 @@ pub fn cast_shift_rhs(op: ast::BinOp, } } -pub fn fail_if_zero_or_overflows<'a>( - cx: &'a Block<'a>, - span: Span, - divrem: ast::BinOp, - lhs: ValueRef, - rhs: ValueRef, - rhs_t: ty::t) - -> &'a Block<'a> { +pub fn fail_if_zero_or_overflows<'blk, 'tcx>( + cx: Block<'blk, 'tcx>, + span: Span, + divrem: ast::BinOp, + lhs: ValueRef, + rhs: ValueRef, + rhs_t: ty::t) + -> Block<'blk, 'tcx> { let (zero_text, overflow_text) = if divrem == ast::BiDiv { ("attempted to divide by zero", "attempted to divide with overflow") @@ -999,16 +991,15 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val } } -pub fn invoke<'a>( - bcx: &'a Block<'a>, - llfn: ValueRef, - llargs: Vec<ValueRef> , - fn_ty: ty::t, - call_info: Option<NodeInfo>, - // FIXME(15064) is_lang_item is a horrible hack, please remove it - // at the soonest opportunity. - is_lang_item: bool) - -> (ValueRef, &'a Block<'a>) { +pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + llfn: ValueRef, + llargs: Vec<ValueRef> , + fn_ty: ty::t, + call_info: Option<NodeInfo>, + // FIXME(15064) is_lang_item is a horrible hack, please remove it + // at the soonest opportunity. + is_lang_item: bool) + -> (ValueRef, Block<'blk, 'tcx>) { let _icx = push_ctxt("invoke_"); if bcx.unreachable.get() { return (C_null(Type::i8(bcx.ccx())), bcx); @@ -1067,7 +1058,7 @@ pub fn invoke<'a>( } } -pub fn need_invoke(bcx: &Block) -> bool { +pub fn need_invoke(bcx: Block) -> bool { if bcx.sess().no_landing_pads() { return false; } @@ -1080,13 +1071,13 @@ pub fn need_invoke(bcx: &Block) -> bool { bcx.fcx.needs_invoke() } -pub fn load_if_immediate(cx: &Block, v: ValueRef, t: ty::t) -> ValueRef { +pub fn load_if_immediate(cx: Block, v: ValueRef, t: ty::t) -> ValueRef { let _icx = push_ctxt("load_if_immediate"); if type_is_immediate(cx.ccx(), t) { return load_ty(cx, v, t); } return v; } -pub fn load_ty(cx: &Block, ptr: ValueRef, t: ty::t) -> ValueRef { +pub fn load_ty(cx: Block, ptr: ValueRef, t: ty::t) -> ValueRef { /*! * Helper for loading values from memory. Does the necessary conversion if * the in-memory type differs from the type used for SSA values. Also @@ -1106,7 +1097,7 @@ pub fn load_ty(cx: &Block, ptr: ValueRef, t: ty::t) -> ValueRef { } } -pub fn store_ty(cx: &Block, v: ValueRef, dst: ValueRef, t: ty::t) { +pub fn store_ty(cx: Block, v: ValueRef, dst: ValueRef, t: ty::t) { /*! * Helper for storing values in memory. Does the necessary conversion if * the in-memory type differs from the type used for SSA values. @@ -1118,33 +1109,31 @@ pub fn store_ty(cx: &Block, v: ValueRef, dst: ValueRef, t: ty::t) { }; } -pub fn ignore_lhs(_bcx: &Block, local: &ast::Local) -> bool { +pub fn ignore_lhs(_bcx: Block, local: &ast::Local) -> bool { match local.pat.node { ast::PatWild(ast::PatWildSingle) => true, _ => false } } -pub fn init_local<'a>(bcx: &'a Block<'a>, local: &ast::Local) - -> &'a Block<'a> { +pub fn init_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, local: &ast::Local) + -> Block<'blk, 'tcx> { debug!("init_local(bcx={}, local.id={:?})", bcx.to_str(), local.id); let _indenter = indenter(); let _icx = push_ctxt("init_local"); _match::store_local(bcx, local) } -pub fn raw_block<'a>( - fcx: &'a FunctionContext<'a>, - is_lpad: bool, - llbb: BasicBlockRef) - -> &'a Block<'a> { - common::Block::new(llbb, is_lpad, None, fcx) +pub fn raw_block<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>, + is_lpad: bool, + llbb: BasicBlockRef) + -> Block<'blk, 'tcx> { + common::BlockS::new(llbb, is_lpad, None, fcx) } -pub fn with_cond<'a>( - bcx: &'a Block<'a>, - val: ValueRef, - f: |&'a Block<'a>| -> &'a Block<'a>) - -> &'a Block<'a> { +pub fn with_cond<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + val: ValueRef, + f: |Block<'blk, 'tcx>| -> Block<'blk, 'tcx>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("with_cond"); let fcx = bcx.fcx; let next_cx = fcx.new_temp_block("next"); @@ -1157,7 +1146,7 @@ pub fn with_cond<'a>( next_cx } -pub fn call_lifetime_start(cx: &Block, ptr: ValueRef) { +pub fn call_lifetime_start(cx: Block, ptr: ValueRef) { if cx.sess().opts.optimize == config::No { return; } @@ -1171,7 +1160,7 @@ pub fn call_lifetime_start(cx: &Block, ptr: ValueRef) { Call(cx, lifetime_start, [llsize, ptr], None); } -pub fn call_lifetime_end(cx: &Block, ptr: ValueRef) { +pub fn call_lifetime_end(cx: Block, ptr: ValueRef) { if cx.sess().opts.optimize == config::No { return; } @@ -1185,7 +1174,7 @@ pub fn call_lifetime_end(cx: &Block, ptr: ValueRef) { Call(cx, lifetime_end, [llsize, ptr], None); } -pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) { +pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) { let _icx = push_ctxt("call_memcpy"); let ccx = cx.ccx(); let key = match ccx.sess().targ_cfg.arch { @@ -1201,7 +1190,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], None); } -pub fn memcpy_ty(bcx: &Block, dst: ValueRef, src: ValueRef, t: ty::t) { +pub fn memcpy_ty(bcx: Block, dst: ValueRef, src: ValueRef, t: ty::t) { let _icx = push_ctxt("memcpy_ty"); let ccx = bcx.ccx(); if ty::type_is_structural(t) { @@ -1214,7 +1203,7 @@ pub fn memcpy_ty(bcx: &Block, dst: ValueRef, src: ValueRef, t: ty::t) { } } -pub fn zero_mem(cx: &Block, llptr: ValueRef, t: ty::t) { +pub fn zero_mem(cx: Block, llptr: ValueRef, t: ty::t) { if cx.unreachable.get() { return; } let _icx = push_ctxt("zero_mem"); let bcx = cx; @@ -1246,7 +1235,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: ty::t) { b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], None); } -pub fn alloc_ty(bcx: &Block, t: ty::t, name: &str) -> ValueRef { +pub fn alloc_ty(bcx: Block, t: ty::t, name: &str) -> ValueRef { let _icx = push_ctxt("alloc_ty"); let ccx = bcx.ccx(); let ty = type_of::type_of(ccx, t); @@ -1255,13 +1244,13 @@ pub fn alloc_ty(bcx: &Block, t: ty::t, name: &str) -> ValueRef { return val; } -pub fn alloca(cx: &Block, ty: Type, name: &str) -> ValueRef { +pub fn alloca(cx: Block, ty: Type, name: &str) -> ValueRef { let p = alloca_no_lifetime(cx, ty, name); call_lifetime_start(cx, p); p } -pub fn alloca_no_lifetime(cx: &Block, ty: Type, name: &str) -> ValueRef { +pub fn alloca_no_lifetime(cx: Block, ty: Type, name: &str) -> ValueRef { let _icx = push_ctxt("alloca"); if cx.unreachable.get() { unsafe { @@ -1272,7 +1261,7 @@ pub fn alloca_no_lifetime(cx: &Block, ty: Type, name: &str) -> ValueRef { Alloca(cx, ty, name) } -pub fn alloca_zeroed(cx: &Block, ty: ty::t, name: &str) -> ValueRef { +pub fn alloca_zeroed(cx: Block, ty: ty::t, name: &str) -> ValueRef { let llty = type_of::type_of(cx.ccx(), ty); if cx.unreachable.get() { unsafe { @@ -1286,7 +1275,7 @@ pub fn alloca_zeroed(cx: &Block, ty: ty::t, name: &str) -> ValueRef { p } -pub fn arrayalloca(cx: &Block, ty: Type, v: ValueRef) -> ValueRef { +pub fn arrayalloca(cx: Block, ty: Type, v: ValueRef) -> ValueRef { let _icx = push_ctxt("arrayalloca"); if cx.unreachable.get() { unsafe { @@ -1441,15 +1430,15 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool { // // Be warned! You must call `init_function` before doing anything with the // returned function context. -pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext, - llfndecl: ValueRef, - id: ast::NodeId, - has_env: bool, - output_type: ty::t, - param_substs: &'a param_substs, - sp: Option<Span>, - block_arena: &'a TypedArena<Block<'a>>) - -> FunctionContext<'a> { +pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>, + llfndecl: ValueRef, + id: ast::NodeId, + has_env: bool, + output_type: ty::t, + param_substs: &'a param_substs, + sp: Option<Span>, + block_arena: &'a TypedArena<common::BlockS<'a, 'tcx>>) + -> FunctionContext<'a, 'tcx> { param_substs.validate(); debug!("new_fn_ctxt(path={}, id={}, param_substs={})", @@ -1495,9 +1484,9 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext, /// Performs setup on a newly created function, creating the entry scope block /// and allocating space for the return pointer. -pub fn init_function<'a>(fcx: &'a FunctionContext<'a>, - skip_retptr: bool, - output_type: ty::t) -> &'a Block<'a> { +pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>, + skip_retptr: bool, + output_type: ty::t) -> Block<'a, 'tcx> { let entry_bcx = fcx.new_temp_block("entry-block"); // Use a dummy instruction as the insertion point for all allocas. @@ -1565,9 +1554,8 @@ pub fn create_datums_for_fn_args(fcx: &FunctionContext, /// datums. /// /// FIXME(pcwalton): Reduce the amount of code bloat this is responsible for. -fn create_datums_for_fn_args_under_call_abi< - 'a>( - mut bcx: &'a Block<'a>, +fn create_datums_for_fn_args_under_call_abi( + mut bcx: Block, arg_scope: cleanup::CustomScopeIndex, arg_tys: &[ty::t]) -> Vec<RvalueDatum> { @@ -1633,12 +1621,12 @@ fn create_datums_for_fn_args_under_call_abi< result } -fn copy_args_to_allocas<'a>(fcx: &FunctionContext<'a>, - arg_scope: cleanup::CustomScopeIndex, - bcx: &'a Block<'a>, - args: &[ast::Arg], - arg_datums: Vec<RvalueDatum> ) - -> &'a Block<'a> { +fn copy_args_to_allocas<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>, + arg_scope: cleanup::CustomScopeIndex, + bcx: Block<'blk, 'tcx>, + args: &[ast::Arg], + arg_datums: Vec<RvalueDatum> ) + -> Block<'blk, 'tcx> { debug!("copy_args_to_allocas"); let _icx = push_ctxt("copy_args_to_allocas"); @@ -1665,13 +1653,13 @@ fn copy_args_to_allocas<'a>(fcx: &FunctionContext<'a>, bcx } -fn copy_unboxed_closure_args_to_allocas<'a>( - mut bcx: &'a Block<'a>, +fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>( + mut bcx: Block<'blk, 'tcx>, arg_scope: cleanup::CustomScopeIndex, args: &[ast::Arg], arg_datums: Vec<RvalueDatum>, monomorphized_arg_types: &[ty::t]) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { let _icx = push_ctxt("copy_unboxed_closure_args_to_allocas"); let arg_scope_id = cleanup::CustomScope(arg_scope); @@ -1721,9 +1709,9 @@ fn copy_unboxed_closure_args_to_allocas<'a>( // Ties up the llstaticallocas -> llloadenv -> lltop edges, // and builds the return block. -pub fn finish_fn<'a>(fcx: &'a FunctionContext<'a>, - last_bcx: &'a Block<'a>, - retty: ty::t) { +pub fn finish_fn<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>, + last_bcx: Block<'blk, 'tcx>, + retty: ty::t) { let _icx = push_ctxt("finish_fn"); // This shouldn't need to recompute the return type, @@ -1745,7 +1733,7 @@ pub fn finish_fn<'a>(fcx: &'a FunctionContext<'a>, } // Builds the return block for a function. -pub fn build_return_block(fcx: &FunctionContext, ret_cx: &Block, retty: ty::t) { +pub fn build_return_block(fcx: &FunctionContext, ret_cx: Block, retty: ty::t) { if fcx.llretslotptr.get().is_none() || (!fcx.needs_ret_allocas && fcx.caller_expects_out_pointer) { return RetVoid(ret_cx); @@ -1814,8 +1802,8 @@ pub fn trans_closure(ccx: &CrateContext, abi: Abi, has_env: bool, is_unboxed_closure: IsUnboxedClosureFlag, - maybe_load_env: <'a>|&'a Block<'a>, ScopeId| - -> &'a Block<'a>) { + maybe_load_env: <'blk, 'tcx> |Block<'blk, 'tcx>, ScopeId| + -> Block<'blk, 'tcx>) { ccx.stats().n_closures.set(ccx.stats().n_closures.get() + 1); let _icx = push_ctxt("trans_closure"); @@ -1981,11 +1969,11 @@ pub fn trans_enum_variant(ccx: &CrateContext, llfndecl); } -pub fn trans_named_tuple_constructor<'a>(mut bcx: &'a Block<'a>, - ctor_ty: ty::t, - disr: ty::Disr, - args: callee::CallArgs, - dest: expr::Dest) -> Result<'a> { +pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + ctor_ty: ty::t, + disr: ty::Disr, + args: callee::CallArgs, + dest: expr::Dest) -> Result<'blk, 'tcx> { let ccx = bcx.fcx.ccx; let tcx = ccx.tcx(); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 95f6118908e..e30f9af02c6 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -23,18 +23,18 @@ use middle::trans::type_::Type; use libc::{c_uint, c_ulonglong, c_char}; -pub fn terminate(cx: &Block, _: &str) { +pub fn terminate(cx: Block, _: &str) { debug!("terminate({})", cx.to_str()); cx.terminated.set(true); } -pub fn check_not_terminated(cx: &Block) { +pub fn check_not_terminated(cx: Block) { if cx.terminated.get() { fail!("already terminated!"); } } -pub fn B<'b, 'tcx>(cx: &'b Block<'b, 'tcx>) -> Builder<'b, 'tcx> { +pub fn B<'blk, 'tcx>(cx: Block<'blk, 'tcx>) -> Builder<'blk, 'tcx> { let b = cx.fcx.ccx.builder(); b.position_at_end(cx.llbb); b @@ -48,35 +48,35 @@ pub fn B<'b, 'tcx>(cx: &'b Block<'b, 'tcx>) -> Builder<'b, 'tcx> { // for (fail/break/return statements, call to diverging functions, etc), and // further instructions to the block should simply be ignored. -pub fn RetVoid(cx: &Block) { +pub fn RetVoid(cx: Block) { if cx.unreachable.get() { return; } check_not_terminated(cx); terminate(cx, "RetVoid"); B(cx).ret_void(); } -pub fn Ret(cx: &Block, v: ValueRef) { +pub fn Ret(cx: Block, v: ValueRef) { if cx.unreachable.get() { return; } check_not_terminated(cx); terminate(cx, "Ret"); B(cx).ret(v); } -pub fn AggregateRet(cx: &Block, ret_vals: &[ValueRef]) { +pub fn AggregateRet(cx: Block, ret_vals: &[ValueRef]) { if cx.unreachable.get() { return; } check_not_terminated(cx); terminate(cx, "AggregateRet"); B(cx).aggregate_ret(ret_vals); } -pub fn Br(cx: &Block, dest: BasicBlockRef) { +pub fn Br(cx: Block, dest: BasicBlockRef) { if cx.unreachable.get() { return; } check_not_terminated(cx); terminate(cx, "Br"); B(cx).br(dest); } -pub fn CondBr(cx: &Block, +pub fn CondBr(cx: Block, if_: ValueRef, then: BasicBlockRef, else_: BasicBlockRef) { @@ -86,7 +86,7 @@ pub fn CondBr(cx: &Block, B(cx).cond_br(if_, then, else_); } -pub fn Switch(cx: &Block, v: ValueRef, else_: BasicBlockRef, num_cases: uint) +pub fn Switch(cx: Block, v: ValueRef, else_: BasicBlockRef, num_cases: uint) -> ValueRef { if cx.unreachable.get() { return _Undef(v); } check_not_terminated(cx); @@ -101,14 +101,14 @@ pub fn AddCase(s: ValueRef, on_val: ValueRef, dest: BasicBlockRef) { } } -pub fn IndirectBr(cx: &Block, addr: ValueRef, num_dests: uint) { +pub fn IndirectBr(cx: Block, addr: ValueRef, num_dests: uint) { if cx.unreachable.get() { return; } check_not_terminated(cx); terminate(cx, "IndirectBr"); B(cx).indirect_br(addr, num_dests); } -pub fn Invoke(cx: &Block, +pub fn Invoke(cx: Block, fn_: ValueRef, args: &[ValueRef], then: BasicBlockRef, @@ -126,7 +126,7 @@ pub fn Invoke(cx: &Block, B(cx).invoke(fn_, args, then, catch, attributes) } -pub fn Unreachable(cx: &Block) { +pub fn Unreachable(cx: Block) { if cx.unreachable.get() { return } @@ -143,163 +143,163 @@ pub fn _Undef(val: ValueRef) -> ValueRef { } /* Arithmetic */ -pub fn Add(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn Add(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).add(lhs, rhs) } -pub fn NSWAdd(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn NSWAdd(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).nswadd(lhs, rhs) } -pub fn NUWAdd(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn NUWAdd(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).nuwadd(lhs, rhs) } -pub fn FAdd(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn FAdd(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).fadd(lhs, rhs) } -pub fn Sub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn Sub(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).sub(lhs, rhs) } -pub fn NSWSub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn NSWSub(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).nswsub(lhs, rhs) } -pub fn NUWSub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn NUWSub(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).nuwsub(lhs, rhs) } -pub fn FSub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn FSub(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).fsub(lhs, rhs) } -pub fn Mul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn Mul(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).mul(lhs, rhs) } -pub fn NSWMul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn NSWMul(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).nswmul(lhs, rhs) } -pub fn NUWMul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn NUWMul(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).nuwmul(lhs, rhs) } -pub fn FMul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn FMul(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).fmul(lhs, rhs) } -pub fn UDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn UDiv(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).udiv(lhs, rhs) } -pub fn SDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn SDiv(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).sdiv(lhs, rhs) } -pub fn ExactSDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn ExactSDiv(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).exactsdiv(lhs, rhs) } -pub fn FDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn FDiv(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).fdiv(lhs, rhs) } -pub fn URem(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn URem(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).urem(lhs, rhs) } -pub fn SRem(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn SRem(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).srem(lhs, rhs) } -pub fn FRem(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn FRem(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).frem(lhs, rhs) } -pub fn Shl(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn Shl(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).shl(lhs, rhs) } -pub fn LShr(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn LShr(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).lshr(lhs, rhs) } -pub fn AShr(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn AShr(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).ashr(lhs, rhs) } -pub fn And(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn And(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).and(lhs, rhs) } -pub fn Or(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn Or(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).or(lhs, rhs) } -pub fn Xor(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn Xor(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).xor(lhs, rhs) } -pub fn BinOp(cx: &Block, op: Opcode, lhs: ValueRef, rhs: ValueRef) +pub fn BinOp(cx: Block, op: Opcode, lhs: ValueRef, rhs: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(lhs); } B(cx).binop(op, lhs, rhs) } -pub fn Neg(cx: &Block, v: ValueRef) -> ValueRef { +pub fn Neg(cx: Block, v: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(v); } B(cx).neg(v) } -pub fn NSWNeg(cx: &Block, v: ValueRef) -> ValueRef { +pub fn NSWNeg(cx: Block, v: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(v); } B(cx).nswneg(v) } -pub fn NUWNeg(cx: &Block, v: ValueRef) -> ValueRef { +pub fn NUWNeg(cx: Block, v: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(v); } B(cx).nuwneg(v) } -pub fn FNeg(cx: &Block, v: ValueRef) -> ValueRef { +pub fn FNeg(cx: Block, v: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(v); } B(cx).fneg(v) } -pub fn Not(cx: &Block, v: ValueRef) -> ValueRef { +pub fn Not(cx: Block, v: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(v); } B(cx).not(v) } /* Memory */ -pub fn Malloc(cx: &Block, ty: Type) -> ValueRef { +pub fn Malloc(cx: Block, ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref()); @@ -308,7 +308,7 @@ pub fn Malloc(cx: &Block, ty: Type) -> ValueRef { } } -pub fn ArrayMalloc(cx: &Block, ty: Type, val: ValueRef) -> ValueRef { +pub fn ArrayMalloc(cx: Block, ty: Type, val: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref()); @@ -317,7 +317,7 @@ pub fn ArrayMalloc(cx: &Block, ty: Type, val: ValueRef) -> ValueRef { } } -pub fn Alloca(cx: &Block, ty: Type, name: &str) -> ValueRef { +pub fn Alloca(cx: Block, ty: Type, name: &str) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.ptr_to().to_ref()); } AllocaFcx(cx.fcx, ty, name) @@ -330,7 +330,7 @@ pub fn AllocaFcx(fcx: &FunctionContext, ty: Type, name: &str) -> ValueRef { b.alloca(ty, name) } -pub fn ArrayAlloca(cx: &Block, ty: Type, val: ValueRef) -> ValueRef { +pub fn ArrayAlloca(cx: Block, ty: Type, val: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.ptr_to().to_ref()); } let b = cx.fcx.ccx.builder(); @@ -339,12 +339,12 @@ pub fn ArrayAlloca(cx: &Block, ty: Type, val: ValueRef) -> ValueRef { } } -pub fn Free(cx: &Block, pointer_val: ValueRef) { +pub fn Free(cx: Block, pointer_val: ValueRef) { if cx.unreachable.get() { return; } B(cx).free(pointer_val) } -pub fn Load(cx: &Block, pointer_val: ValueRef) -> ValueRef { +pub fn Load(cx: Block, pointer_val: ValueRef) -> ValueRef { unsafe { let ccx = cx.fcx.ccx; if cx.unreachable.get() { @@ -360,7 +360,7 @@ pub fn Load(cx: &Block, pointer_val: ValueRef) -> ValueRef { } } -pub fn VolatileLoad(cx: &Block, pointer_val: ValueRef) -> ValueRef { +pub fn VolatileLoad(cx: Block, pointer_val: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).to_ref()); @@ -369,7 +369,7 @@ pub fn VolatileLoad(cx: &Block, pointer_val: ValueRef) -> ValueRef { } } -pub fn AtomicLoad(cx: &Block, pointer_val: ValueRef, order: AtomicOrdering) -> ValueRef { +pub fn AtomicLoad(cx: Block, pointer_val: ValueRef, order: AtomicOrdering) -> ValueRef { unsafe { let ccx = cx.fcx.ccx; if cx.unreachable.get() { @@ -380,7 +380,7 @@ pub fn AtomicLoad(cx: &Block, pointer_val: ValueRef, order: AtomicOrdering) -> V } -pub fn LoadRangeAssert(cx: &Block, pointer_val: ValueRef, lo: c_ulonglong, +pub fn LoadRangeAssert(cx: Block, pointer_val: ValueRef, lo: c_ulonglong, hi: c_ulonglong, signed: llvm::Bool) -> ValueRef { if cx.unreachable.get() { let ccx = cx.fcx.ccx; @@ -398,22 +398,22 @@ pub fn LoadRangeAssert(cx: &Block, pointer_val: ValueRef, lo: c_ulonglong, } } -pub fn Store(cx: &Block, val: ValueRef, ptr: ValueRef) { +pub fn Store(cx: Block, val: ValueRef, ptr: ValueRef) { if cx.unreachable.get() { return; } B(cx).store(val, ptr) } -pub fn VolatileStore(cx: &Block, val: ValueRef, ptr: ValueRef) { +pub fn VolatileStore(cx: Block, val: ValueRef, ptr: ValueRef) { if cx.unreachable.get() { return; } B(cx).volatile_store(val, ptr) } -pub fn AtomicStore(cx: &Block, val: ValueRef, ptr: ValueRef, order: AtomicOrdering) { +pub fn AtomicStore(cx: Block, val: ValueRef, ptr: ValueRef, order: AtomicOrdering) { if cx.unreachable.get() { return; } B(cx).atomic_store(val, ptr, order) } -pub fn GEP(cx: &Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef { +pub fn GEP(cx: Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).ptr_to().to_ref()); @@ -425,7 +425,7 @@ pub fn GEP(cx: &Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef { // Simple wrapper around GEP that takes an array of ints and wraps them // in C_i32() #[inline] -pub fn GEPi(cx: &Block, base: ValueRef, ixs: &[uint]) -> ValueRef { +pub fn GEPi(cx: Block, base: ValueRef, ixs: &[uint]) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).ptr_to().to_ref()); @@ -434,7 +434,7 @@ pub fn GEPi(cx: &Block, base: ValueRef, ixs: &[uint]) -> ValueRef { } } -pub fn InBoundsGEP(cx: &Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef { +pub fn InBoundsGEP(cx: Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).ptr_to().to_ref()); @@ -443,7 +443,7 @@ pub fn InBoundsGEP(cx: &Block, pointer: ValueRef, indices: &[ValueRef]) -> Value } } -pub fn StructGEP(cx: &Block, pointer: ValueRef, idx: uint) -> ValueRef { +pub fn StructGEP(cx: Block, pointer: ValueRef, idx: uint) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).ptr_to().to_ref()); @@ -452,7 +452,7 @@ pub fn StructGEP(cx: &Block, pointer: ValueRef, idx: uint) -> ValueRef { } } -pub fn GlobalString(cx: &Block, _str: *const c_char) -> ValueRef { +pub fn GlobalString(cx: Block, _str: *const c_char) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref()); @@ -461,7 +461,7 @@ pub fn GlobalString(cx: &Block, _str: *const c_char) -> ValueRef { } } -pub fn GlobalStringPtr(cx: &Block, _str: *const c_char) -> ValueRef { +pub fn GlobalStringPtr(cx: Block, _str: *const c_char) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref()); @@ -471,112 +471,112 @@ pub fn GlobalStringPtr(cx: &Block, _str: *const c_char) -> ValueRef { } /* Casts */ -pub fn Trunc(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn Trunc(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).trunc(val, dest_ty) } } -pub fn ZExt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn ZExt(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).zext(val, dest_ty) } } -pub fn SExt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn SExt(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).sext(val, dest_ty) } } -pub fn FPToUI(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn FPToUI(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).fptoui(val, dest_ty) } } -pub fn FPToSI(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn FPToSI(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).fptosi(val, dest_ty) } } -pub fn UIToFP(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn UIToFP(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).uitofp(val, dest_ty) } } -pub fn SIToFP(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn SIToFP(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).sitofp(val, dest_ty) } } -pub fn FPTrunc(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn FPTrunc(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).fptrunc(val, dest_ty) } } -pub fn FPExt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn FPExt(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).fpext(val, dest_ty) } } -pub fn PtrToInt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn PtrToInt(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).ptrtoint(val, dest_ty) } } -pub fn IntToPtr(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn IntToPtr(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).inttoptr(val, dest_ty) } } -pub fn BitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn BitCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).bitcast(val, dest_ty) } } -pub fn ZExtOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn ZExtOrBitCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).zext_or_bitcast(val, dest_ty) } } -pub fn SExtOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn SExtOrBitCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).sext_or_bitcast(val, dest_ty) } } -pub fn TruncOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn TruncOrBitCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).trunc_or_bitcast(val, dest_ty) } } -pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type, +pub fn Cast(cx: Block, op: Opcode, val: ValueRef, dest_ty: Type, _: *const u8) -> ValueRef { unsafe { @@ -585,21 +585,21 @@ pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type, } } -pub fn PointerCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn PointerCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).pointercast(val, dest_ty) } } -pub fn IntCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn IntCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).intcast(val, dest_ty) } } -pub fn FPCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { +pub fn FPCast(cx: Block, val: ValueRef, dest_ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); } B(cx).fpcast(val, dest_ty) @@ -608,7 +608,7 @@ pub fn FPCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef { /* Comparisons */ -pub fn ICmp(cx: &Block, op: IntPredicate, lhs: ValueRef, rhs: ValueRef) +pub fn ICmp(cx: Block, op: IntPredicate, lhs: ValueRef, rhs: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { @@ -618,7 +618,7 @@ pub fn ICmp(cx: &Block, op: IntPredicate, lhs: ValueRef, rhs: ValueRef) } } -pub fn FCmp(cx: &Block, op: RealPredicate, lhs: ValueRef, rhs: ValueRef) +pub fn FCmp(cx: Block, op: RealPredicate, lhs: ValueRef, rhs: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { @@ -629,14 +629,14 @@ pub fn FCmp(cx: &Block, op: RealPredicate, lhs: ValueRef, rhs: ValueRef) } /* Miscellaneous instructions */ -pub fn EmptyPhi(cx: &Block, ty: Type) -> ValueRef { +pub fn EmptyPhi(cx: Block, ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); } B(cx).empty_phi(ty) } } -pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef], +pub fn Phi(cx: Block, ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); } @@ -651,7 +651,7 @@ pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) { } } -pub fn _UndefReturn(cx: &Block, fn_: ValueRef) -> ValueRef { +pub fn _UndefReturn(cx: Block, fn_: ValueRef) -> ValueRef { unsafe { let ccx = cx.fcx.ccx; let ty = val_ty(fn_); @@ -665,51 +665,51 @@ pub fn _UndefReturn(cx: &Block, fn_: ValueRef) -> ValueRef { } } -pub fn add_span_comment(cx: &Block, sp: Span, text: &str) { +pub fn add_span_comment(cx: Block, sp: Span, text: &str) { B(cx).add_span_comment(sp, text) } -pub fn add_comment(cx: &Block, text: &str) { +pub fn add_comment(cx: Block, text: &str) { B(cx).add_comment(text) } -pub fn InlineAsmCall(cx: &Block, asm: *const c_char, cons: *const c_char, +pub fn InlineAsmCall(cx: Block, asm: *const c_char, cons: *const c_char, inputs: &[ValueRef], output: Type, volatile: bool, alignstack: bool, dia: AsmDialect) -> ValueRef { B(cx).inline_asm_call(asm, cons, inputs, output, volatile, alignstack, dia) } -pub fn Call(cx: &Block, fn_: ValueRef, args: &[ValueRef], +pub fn Call(cx: Block, fn_: ValueRef, args: &[ValueRef], attributes: Option<AttrBuilder>) -> ValueRef { if cx.unreachable.get() { return _UndefReturn(cx, fn_); } B(cx).call(fn_, args, attributes) } -pub fn CallWithConv(cx: &Block, fn_: ValueRef, args: &[ValueRef], conv: CallConv, +pub fn CallWithConv(cx: Block, fn_: ValueRef, args: &[ValueRef], conv: CallConv, attributes: Option<AttrBuilder>) -> ValueRef { if cx.unreachable.get() { return _UndefReturn(cx, fn_); } B(cx).call_with_conv(fn_, args, conv, attributes) } -pub fn AtomicFence(cx: &Block, order: AtomicOrdering) { +pub fn AtomicFence(cx: Block, order: AtomicOrdering) { if cx.unreachable.get() { return; } B(cx).atomic_fence(order) } -pub fn Select(cx: &Block, if_: ValueRef, then: ValueRef, else_: ValueRef) -> ValueRef { +pub fn Select(cx: Block, if_: ValueRef, then: ValueRef, else_: ValueRef) -> ValueRef { if cx.unreachable.get() { return _Undef(then); } B(cx).select(if_, then, else_) } -pub fn VAArg(cx: &Block, list: ValueRef, ty: Type) -> ValueRef { +pub fn VAArg(cx: Block, list: ValueRef, ty: Type) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); } B(cx).va_arg(list, ty) } } -pub fn ExtractElement(cx: &Block, vec_val: ValueRef, index: ValueRef) -> ValueRef { +pub fn ExtractElement(cx: Block, vec_val: ValueRef, index: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).to_ref()); @@ -718,7 +718,7 @@ pub fn ExtractElement(cx: &Block, vec_val: ValueRef, index: ValueRef) -> ValueRe } } -pub fn InsertElement(cx: &Block, vec_val: ValueRef, elt_val: ValueRef, +pub fn InsertElement(cx: Block, vec_val: ValueRef, elt_val: ValueRef, index: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { @@ -728,7 +728,7 @@ pub fn InsertElement(cx: &Block, vec_val: ValueRef, elt_val: ValueRef, } } -pub fn ShuffleVector(cx: &Block, v1: ValueRef, v2: ValueRef, +pub fn ShuffleVector(cx: Block, v1: ValueRef, v2: ValueRef, mask: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { @@ -738,7 +738,7 @@ pub fn ShuffleVector(cx: &Block, v1: ValueRef, v2: ValueRef, } } -pub fn VectorSplat(cx: &Block, num_elts: uint, elt_val: ValueRef) -> ValueRef { +pub fn VectorSplat(cx: Block, num_elts: uint, elt_val: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).to_ref()); @@ -747,7 +747,7 @@ pub fn VectorSplat(cx: &Block, num_elts: uint, elt_val: ValueRef) -> ValueRef { } } -pub fn ExtractValue(cx: &Block, agg_val: ValueRef, index: uint) -> ValueRef { +pub fn ExtractValue(cx: Block, agg_val: ValueRef, index: uint) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).to_ref()); @@ -756,7 +756,7 @@ pub fn ExtractValue(cx: &Block, agg_val: ValueRef, index: uint) -> ValueRef { } } -pub fn InsertValue(cx: &Block, agg_val: ValueRef, elt_val: ValueRef, index: uint) -> ValueRef { +pub fn InsertValue(cx: Block, agg_val: ValueRef, elt_val: ValueRef, index: uint) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil(cx.ccx()).to_ref()); @@ -765,7 +765,7 @@ pub fn InsertValue(cx: &Block, agg_val: ValueRef, elt_val: ValueRef, index: uint } } -pub fn IsNull(cx: &Block, val: ValueRef) -> ValueRef { +pub fn IsNull(cx: Block, val: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1(cx.ccx()).to_ref()); @@ -774,7 +774,7 @@ pub fn IsNull(cx: &Block, val: ValueRef) -> ValueRef { } } -pub fn IsNotNull(cx: &Block, val: ValueRef) -> ValueRef { +pub fn IsNotNull(cx: Block, val: ValueRef) -> ValueRef { unsafe { if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1(cx.ccx()).to_ref()); @@ -783,7 +783,7 @@ pub fn IsNotNull(cx: &Block, val: ValueRef) -> ValueRef { } } -pub fn PtrDiff(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { +pub fn PtrDiff(cx: Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { unsafe { let ccx = cx.fcx.ccx; if cx.unreachable.get() { return llvm::LLVMGetUndef(ccx.int_type().to_ref()); } @@ -791,36 +791,36 @@ pub fn PtrDiff(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef { } } -pub fn Trap(cx: &Block) { +pub fn Trap(cx: Block) { if cx.unreachable.get() { return; } B(cx).trap(); } -pub fn LandingPad(cx: &Block, ty: Type, pers_fn: ValueRef, +pub fn LandingPad(cx: Block, ty: Type, pers_fn: ValueRef, num_clauses: uint) -> ValueRef { check_not_terminated(cx); assert!(!cx.unreachable.get()); B(cx).landing_pad(ty, pers_fn, num_clauses) } -pub fn SetCleanup(cx: &Block, landing_pad: ValueRef) { +pub fn SetCleanup(cx: Block, landing_pad: ValueRef) { B(cx).set_cleanup(landing_pad) } -pub fn Resume(cx: &Block, exn: ValueRef) -> ValueRef { +pub fn Resume(cx: Block, exn: ValueRef) -> ValueRef { check_not_terminated(cx); terminate(cx, "Resume"); B(cx).resume(exn) } // Atomic Operations -pub fn AtomicCmpXchg(cx: &Block, dst: ValueRef, +pub fn AtomicCmpXchg(cx: Block, dst: ValueRef, cmp: ValueRef, src: ValueRef, order: AtomicOrdering, failure_order: AtomicOrdering) -> ValueRef { B(cx).atomic_cmpxchg(dst, cmp, src, order, failure_order) } -pub fn AtomicRMW(cx: &Block, op: AtomicBinOp, +pub fn AtomicRMW(cx: Block, op: AtomicBinOp, dst: ValueRef, src: ValueRef, order: AtomicOrdering) -> ValueRef { B(cx).atomic_rmw(op, dst, src, order) diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 794e42563a9..5d66ec0a4b9 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -80,12 +80,13 @@ pub enum CalleeData { TraitItem(MethodData) } -pub struct Callee<'a> { - pub bcx: &'a Block<'a>, +pub struct Callee<'blk, 'tcx: 'blk> { + pub bcx: Block<'blk, 'tcx>, pub data: CalleeData, } -fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { +fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) + -> Callee<'blk, 'tcx> { let _icx = push_ctxt("trans_callee"); debug!("callee::trans(expr={})", expr.repr(bcx.tcx())); @@ -100,7 +101,8 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { // any other expressions are closures: return datum_callee(bcx, expr); - fn datum_callee<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { + fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) + -> Callee<'blk, 'tcx> { let DatumBlock {bcx: mut bcx, datum} = expr::trans(bcx, expr); match ty::get(datum.ty).sty { ty::ty_bare_fn(..) => { @@ -128,15 +130,16 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { } } - fn fn_callee<'a>(bcx: &'a Block<'a>, llfn: ValueRef) -> Callee<'a> { + fn fn_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, llfn: ValueRef) + -> Callee<'blk, 'tcx> { return Callee { bcx: bcx, data: Fn(llfn), }; } - fn trans_def<'a>(bcx: &'a Block<'a>, def: def::Def, ref_expr: &ast::Expr) - -> Callee<'a> { + fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: def::Def, ref_expr: &ast::Expr) + -> Callee<'blk, 'tcx> { debug!("trans_def(def={}, ref_expr={})", def.repr(bcx.tcx()), ref_expr.repr(bcx.tcx())); let expr_ty = node_id_type(bcx, ref_expr.id); match def { @@ -214,7 +217,7 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { } } -pub fn trans_fn_ref(bcx: &Block, def_id: ast::DefId, node: ExprOrMethodCall) -> ValueRef { +pub fn trans_fn_ref(bcx: Block, def_id: ast::DefId, node: ExprOrMethodCall) -> ValueRef { /*! * Translates a reference (with id `ref_id`) to the fn/method * with id `def_id` into a function pointer. This may require @@ -237,12 +240,12 @@ pub fn trans_fn_ref(bcx: &Block, def_id: ast::DefId, node: ExprOrMethodCall) -> trans_fn_ref_with_vtables(bcx, def_id, node, substs, vtables) } -fn trans_fn_ref_with_vtables_to_callee<'a>(bcx: &'a Block<'a>, - def_id: ast::DefId, - ref_id: ast::NodeId, - substs: subst::Substs, - vtables: typeck::vtable_res) - -> Callee<'a> { +fn trans_fn_ref_with_vtables_to_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + def_id: ast::DefId, + ref_id: ast::NodeId, + substs: subst::Substs, + vtables: typeck::vtable_res) + -> Callee<'blk, 'tcx> { Callee { bcx: bcx, data: Fn(trans_fn_ref_with_vtables(bcx, @@ -253,7 +256,7 @@ fn trans_fn_ref_with_vtables_to_callee<'a>(bcx: &'a Block<'a>, } } -fn resolve_default_method_vtables(bcx: &Block, +fn resolve_default_method_vtables(bcx: Block, impl_id: ast::DefId, substs: &subst::Substs, impl_vtables: typeck::vtable_res) @@ -281,7 +284,7 @@ fn resolve_default_method_vtables(bcx: &Block, /// Translates the adapter that deconstructs a `Box<Trait>` object into /// `Trait` so that a by-value self method can be called. -pub fn trans_unboxing_shim(bcx: &Block, +pub fn trans_unboxing_shim(bcx: Block, llshimmedfn: ValueRef, fty: &ty::BareFnTy, method_id: ast::DefId, @@ -406,7 +409,7 @@ pub fn trans_unboxing_shim(bcx: &Block, } pub fn trans_fn_ref_with_vtables( - bcx: &Block, // + bcx: Block, // def_id: ast::DefId, // def id of fn node: ExprOrMethodCall, // node id of use of fn; may be zero if N/A substs: subst::Substs, // values for fn's ty params @@ -625,13 +628,12 @@ pub fn trans_fn_ref_with_vtables( // ______________________________________________________________________ // Translating calls -pub fn trans_call<'a>( - in_cx: &'a Block<'a>, - call_ex: &ast::Expr, - f: &ast::Expr, - args: CallArgs, - dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_call<'blk, 'tcx>(in_cx: Block<'blk, 'tcx>, + call_ex: &ast::Expr, + f: &ast::Expr, + args: CallArgs, + dest: expr::Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_call"); trans_call_inner(in_cx, Some(common::expr_info(call_ex)), @@ -641,13 +643,12 @@ pub fn trans_call<'a>( Some(dest)).bcx } -pub fn trans_method_call<'a>( - bcx: &'a Block<'a>, - call_ex: &ast::Expr, - rcvr: &ast::Expr, - args: CallArgs, - dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_method_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + call_ex: &ast::Expr, + rcvr: &ast::Expr, + args: CallArgs, + dest: expr::Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_method_call"); debug!("trans_method_call(call_ex={})", call_ex.repr(bcx.tcx())); let method_call = MethodCall::expr(call_ex.id); @@ -663,12 +664,11 @@ pub fn trans_method_call<'a>( Some(dest)).bcx } -pub fn trans_lang_call<'a>( - bcx: &'a Block<'a>, - did: ast::DefId, - args: &[ValueRef], - dest: Option<expr::Dest>) - -> Result<'a> { +pub fn trans_lang_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + did: ast::DefId, + args: &[ValueRef], + dest: Option<expr::Dest>) + -> Result<'blk, 'tcx> { let fty = if did.krate == ast::LOCAL_CRATE { ty::node_id_to_type(bcx.tcx(), did.node) } else { @@ -688,16 +688,15 @@ pub fn trans_lang_call<'a>( dest) } -pub fn trans_call_inner<'a>( - bcx: &'a Block<'a>, - call_info: Option<NodeInfo>, - callee_ty: ty::t, - get_callee: |bcx: &'a Block<'a>, - arg_cleanup_scope: cleanup::ScopeId| - -> Callee<'a>, - args: CallArgs, - dest: Option<expr::Dest>) - -> Result<'a> { +pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + call_info: Option<NodeInfo>, + callee_ty: ty::t, + get_callee: |bcx: Block<'blk, 'tcx>, + arg_cleanup_scope: cleanup::ScopeId| + -> Callee<'blk, 'tcx>, + args: CallArgs, + dest: Option<expr::Dest>) + -> Result<'blk, 'tcx> { /*! * This behemoth of a function translates function calls. * Unfortunately, in order to generate more efficient LLVM @@ -920,14 +919,14 @@ pub enum CallArgs<'a> { ArgOverloadedCall(&'a [Gc<ast::Expr>]), } -fn trans_args_under_call_abi<'a>( - mut bcx: &'a Block<'a>, +fn trans_args_under_call_abi<'blk, 'tcx>( + mut bcx: Block<'blk, 'tcx>, arg_exprs: &[Gc<ast::Expr>], fn_ty: ty::t, llargs: &mut Vec<ValueRef>, arg_cleanup_scope: cleanup::ScopeId, ignore_self: bool) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { // Translate the `self` argument first. let arg_tys = ty::ty_fn_args(fn_ty); if !ignore_self { @@ -981,14 +980,14 @@ fn trans_args_under_call_abi<'a>( bcx } -fn trans_overloaded_call_args<'a>( - mut bcx: &'a Block<'a>, +fn trans_overloaded_call_args<'blk, 'tcx>( + mut bcx: Block<'blk, 'tcx>, arg_exprs: &[Gc<ast::Expr>], fn_ty: ty::t, llargs: &mut Vec<ValueRef>, arg_cleanup_scope: cleanup::ScopeId, ignore_self: bool) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { // Translate the `self` argument first. let arg_tys = ty::ty_fn_args(fn_ty); if !ignore_self { @@ -1028,15 +1027,14 @@ fn trans_overloaded_call_args<'a>( bcx } -pub fn trans_args<'a>( - cx: &'a Block<'a>, - args: CallArgs, - fn_ty: ty::t, - llargs: &mut Vec<ValueRef> , - arg_cleanup_scope: cleanup::ScopeId, - ignore_self: bool, - abi: synabi::Abi) - -> &'a Block<'a> { +pub fn trans_args<'blk, 'tcx>(cx: Block<'blk, 'tcx>, + args: CallArgs, + fn_ty: ty::t, + llargs: &mut Vec<ValueRef> , + arg_cleanup_scope: cleanup::ScopeId, + ignore_self: bool, + abi: synabi::Abi) + -> Block<'blk, 'tcx> { debug!("trans_args(abi={})", abi); let _icx = push_ctxt("trans_args"); @@ -1124,13 +1122,12 @@ pub enum AutorefArg { DoAutorefArg(ast::NodeId) } -pub fn trans_arg_datum<'a>( - bcx: &'a Block<'a>, - formal_arg_ty: ty::t, - arg_datum: Datum<Expr>, - arg_cleanup_scope: cleanup::ScopeId, - autoref_arg: AutorefArg) - -> Result<'a> { +pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + formal_arg_ty: ty::t, + arg_datum: Datum<Expr>, + arg_cleanup_scope: cleanup::ScopeId, + autoref_arg: AutorefArg) + -> Result<'blk, 'tcx> { let _icx = push_ctxt("trans_arg_datum"); let mut bcx = bcx; let ccx = bcx.ccx(); diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index cdfb8e48a46..4d54308031e 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -25,13 +25,13 @@ use middle::ty; use syntax::ast; use util::ppaux::Repr; -pub struct CleanupScope<'a> { +pub struct CleanupScope<'blk, 'tcx: 'blk> { // The id of this cleanup scope. If the id is None, // this is a *temporary scope* that is pushed during trans to // cleanup miscellaneous garbage that trans may generate whose // lifetime is a subset of some expression. See module doc for // more details. - kind: CleanupScopeKind<'a>, + kind: CleanupScopeKind<'blk, 'tcx>, // Cleanups to run upon scope exit. cleanups: Vec<CleanupObj>, @@ -48,10 +48,10 @@ pub static EXIT_BREAK: uint = 0; pub static EXIT_LOOP: uint = 1; pub static EXIT_MAX: uint = 2; -pub enum CleanupScopeKind<'a> { +pub enum CleanupScopeKind<'blk, 'tcx: 'blk> { CustomScopeKind, AstScopeKind(ast::NodeId), - LoopScopeKind(ast::NodeId, [&'a Block<'a>, ..EXIT_MAX]) + LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>, ..EXIT_MAX]) } #[deriving(PartialEq)] @@ -69,7 +69,7 @@ pub struct CachedEarlyExit { pub trait Cleanup { fn must_unwind(&self) -> bool; fn clean_on_unwind(&self) -> bool; - fn trans<'a>(&self, bcx: &'a Block<'a>) -> &'a Block<'a>; + fn trans<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>) -> Block<'blk, 'tcx>; } pub type CleanupObj = Box<Cleanup+'static>; @@ -79,7 +79,7 @@ pub enum ScopeId { CustomScope(CustomScopeIndex) } -impl<'a> CleanupMethods<'a> for FunctionContext<'a> { +impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { fn push_ast_cleanup_scope(&self, id: ast::NodeId) { /*! * Invoked when we start to trans the code contained @@ -109,7 +109,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { fn push_loop_cleanup_scope(&self, id: ast::NodeId, - exits: [&'a Block<'a>, ..EXIT_MAX]) { + exits: [Block<'blk, 'tcx>, ..EXIT_MAX]) { debug!("push_loop_cleanup_scope({})", self.ccx.tcx().map.node_to_string(id)); assert_eq!(Some(id), self.top_ast_scope()); @@ -125,9 +125,9 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { } fn pop_and_trans_ast_cleanup_scope(&self, - bcx: &'a Block<'a>, + bcx: Block<'blk, 'tcx>, cleanup_scope: ast::NodeId) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { /*! * Removes the cleanup scope for id `cleanup_scope`, which * must be at the top of the cleanup stack, and generates the @@ -175,9 +175,9 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { } fn pop_and_trans_custom_cleanup_scope(&self, - bcx: &'a Block<'a>, + bcx: Block<'blk, 'tcx>, custom_scope: CustomScopeIndex) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { /*! * Removes the top cleanup scope from the stack, which must be * a temporary scope, and generates the code to do its @@ -207,7 +207,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { self.ccx.sess().bug("no loop scope found"); } - fn normal_exit_block(&'a self, + fn normal_exit_block(&'blk self, cleanup_scope: ast::NodeId, exit: uint) -> BasicBlockRef { /*! @@ -219,7 +219,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { self.trans_cleanups_to_exit_scope(LoopExit(cleanup_scope, exit)) } - fn return_exit_block(&'a self) -> BasicBlockRef { + fn return_exit_block(&'blk self) -> BasicBlockRef { /*! * Returns a block to branch to which will perform all pending * cleanups and then return from this function @@ -426,7 +426,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { self.scopes.borrow().iter().rev().any(|s| s.needs_invoke()) } - fn get_landing_pad(&'a self) -> BasicBlockRef { + fn get_landing_pad(&'blk self) -> BasicBlockRef { /*! * Returns a basic block to branch to in the event of a failure. * This block will run the failure cleanups and eventually @@ -464,7 +464,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { } } -impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { +impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { fn top_ast_scope(&self) -> Option<ast::NodeId> { /*! * Returns the id of the current top-most AST scope, if any. @@ -496,8 +496,8 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { } fn trans_scope_cleanups(&self, // cannot borrow self, will recurse - bcx: &'a Block<'a>, - scope: &CleanupScope) -> &'a Block<'a> { + bcx: Block<'blk, 'tcx>, + scope: &CleanupScope) -> Block<'blk, 'tcx> { /*! Generates the cleanups for `scope` into `bcx` */ let mut bcx = bcx; @@ -513,11 +513,11 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { self.scopes.borrow().len() } - fn push_scope(&self, scope: CleanupScope<'a>) { + fn push_scope(&self, scope: CleanupScope<'blk, 'tcx>) { self.scopes.borrow_mut().push(scope) } - fn pop_scope(&self) -> CleanupScope<'a> { + fn pop_scope(&self) -> CleanupScope<'blk, 'tcx> { debug!("popping cleanup scope {}, {} scopes remaining", self.top_scope(|s| s.block_name("")), self.scopes_len() - 1); @@ -525,11 +525,11 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { self.scopes.borrow_mut().pop().unwrap() } - fn top_scope<R>(&self, f: |&CleanupScope<'a>| -> R) -> R { + fn top_scope<R>(&self, f: |&CleanupScope<'blk, 'tcx>| -> R) -> R { f(self.scopes.borrow().last().unwrap()) } - fn trans_cleanups_to_exit_scope(&'a self, + fn trans_cleanups_to_exit_scope(&'blk self, label: EarlyExitLabel) -> BasicBlockRef { /*! @@ -691,7 +691,7 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { prev_llbb } - fn get_or_create_landing_pad(&'a self) -> BasicBlockRef { + fn get_or_create_landing_pad(&'blk self) -> BasicBlockRef { /*! * Creates a landing pad for the top scope, if one does not * exist. The landing pad will perform all cleanups necessary @@ -784,8 +784,8 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { } } -impl<'a> CleanupScope<'a> { - fn new(kind: CleanupScopeKind<'a>) -> CleanupScope<'a> { +impl<'blk, 'tcx> CleanupScope<'blk, 'tcx> { + fn new(kind: CleanupScopeKind<'blk, 'tcx>) -> CleanupScope<'blk, 'tcx> { CleanupScope { kind: kind, cleanups: vec!(), @@ -836,7 +836,7 @@ impl<'a> CleanupScope<'a> { } } -impl<'a> CleanupScopeKind<'a> { +impl<'blk, 'tcx> CleanupScopeKind<'blk, 'tcx> { fn is_temp(&self) -> bool { match *self { CustomScopeKind => true, @@ -902,7 +902,7 @@ impl Cleanup for DropValue { self.must_unwind } - fn trans<'a>(&self, bcx: &'a Block<'a>) -> &'a Block<'a> { + fn trans<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>) -> Block<'blk, 'tcx> { let bcx = if self.is_immediate { glue::drop_ty_immediate(bcx, self.val, self.ty) } else { @@ -935,7 +935,7 @@ impl Cleanup for FreeValue { true } - fn trans<'a>(&self, bcx: &'a Block<'a>) -> &'a Block<'a> { + fn trans<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>) -> Block<'blk, 'tcx> { match self.heap { HeapManaged => { glue::trans_free(bcx, self.ptr) @@ -963,7 +963,7 @@ impl Cleanup for FreeSlice { true } - fn trans<'a>(&self, bcx: &'a Block<'a>) -> &'a Block<'a> { + fn trans<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>) -> Block<'blk, 'tcx> { match self.heap { HeapManaged => { glue::trans_free(bcx, self.ptr) @@ -988,7 +988,7 @@ impl Cleanup for LifetimeEnd { true } - fn trans<'a>(&self, bcx: &'a Block<'a>) -> &'a Block<'a> { + fn trans<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>) -> Block<'blk, 'tcx> { base::call_lifetime_end(bcx, self.ptr); bcx } @@ -1026,29 +1026,29 @@ fn cleanup_is_suitable_for(c: &Cleanup, /////////////////////////////////////////////////////////////////////////// // These traits just exist to put the methods into this file. -pub trait CleanupMethods<'a> { +pub trait CleanupMethods<'blk, 'tcx> { fn push_ast_cleanup_scope(&self, id: ast::NodeId); fn push_loop_cleanup_scope(&self, id: ast::NodeId, - exits: [&'a Block<'a>, ..EXIT_MAX]); + exits: [Block<'blk, 'tcx>, ..EXIT_MAX]); fn push_custom_cleanup_scope(&self) -> CustomScopeIndex; fn pop_and_trans_ast_cleanup_scope(&self, - bcx: &'a Block<'a>, + bcx: Block<'blk, 'tcx>, cleanup_scope: ast::NodeId) - -> &'a Block<'a>; + -> Block<'blk, 'tcx>; fn pop_loop_cleanup_scope(&self, cleanup_scope: ast::NodeId); fn pop_custom_cleanup_scope(&self, custom_scope: CustomScopeIndex); fn pop_and_trans_custom_cleanup_scope(&self, - bcx: &'a Block<'a>, + bcx: Block<'blk, 'tcx>, custom_scope: CustomScopeIndex) - -> &'a Block<'a>; + -> Block<'blk, 'tcx>; fn top_loop_scope(&self) -> ast::NodeId; - fn normal_exit_block(&'a self, + fn normal_exit_block(&'blk self, cleanup_scope: ast::NodeId, exit: uint) -> BasicBlockRef; - fn return_exit_block(&'a self) -> BasicBlockRef; + fn return_exit_block(&'blk self) -> BasicBlockRef; fn schedule_lifetime_end(&self, cleanup_scope: ScopeId, val: ValueRef); @@ -1085,23 +1085,23 @@ pub trait CleanupMethods<'a> { custom_scope: CustomScopeIndex, cleanup: CleanupObj); fn needs_invoke(&self) -> bool; - fn get_landing_pad(&'a self) -> BasicBlockRef; + fn get_landing_pad(&'blk self) -> BasicBlockRef; } -trait CleanupHelperMethods<'a> { +trait CleanupHelperMethods<'blk, 'tcx> { fn top_ast_scope(&self) -> Option<ast::NodeId>; fn top_nonempty_cleanup_scope(&self) -> Option<uint>; fn is_valid_to_pop_custom_scope(&self, custom_scope: CustomScopeIndex) -> bool; fn is_valid_custom_scope(&self, custom_scope: CustomScopeIndex) -> bool; fn trans_scope_cleanups(&self, - bcx: &'a Block<'a>, - scope: &CleanupScope<'a>) -> &'a Block<'a>; - fn trans_cleanups_to_exit_scope(&'a self, + bcx: Block<'blk, 'tcx>, + scope: &CleanupScope<'blk, 'tcx>) -> Block<'blk, 'tcx>; + fn trans_cleanups_to_exit_scope(&'blk self, label: EarlyExitLabel) -> BasicBlockRef; - fn get_or_create_landing_pad(&'a self) -> BasicBlockRef; + fn get_or_create_landing_pad(&'blk self) -> BasicBlockRef; fn scopes_len(&self) -> uint; - fn push_scope(&self, scope: CleanupScope<'a>); - fn pop_scope(&self) -> CleanupScope<'a>; - fn top_scope<R>(&self, f: |&CleanupScope<'a>| -> R) -> R; + fn push_scope(&self, scope: CleanupScope<'blk, 'tcx>); + fn pop_scope(&self) -> CleanupScope<'blk, 'tcx>; + fn top_scope<R>(&self, f: |&CleanupScope<'blk, 'tcx>| -> R) -> R; } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index b90ac39cf1d..7bbdf332fe1 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -135,10 +135,10 @@ fn tuplify_box_ty(tcx: &ty::ctxt, t: ty::t) -> ty::t { ty::mk_tup(tcx, vec!(ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t)) } -fn allocate_cbox<'a>(bcx: &'a Block<'a>, - store: ty::TraitStore, - cdata_ty: ty::t) - -> Result<'a> { +fn allocate_cbox<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + store: ty::TraitStore, + cdata_ty: ty::t) + -> Result<'blk, 'tcx> { let _icx = push_ctxt("closure::allocate_cbox"); let tcx = bcx.tcx(); @@ -155,21 +155,20 @@ fn allocate_cbox<'a>(bcx: &'a Block<'a>, } } -pub struct ClosureResult<'a> { +pub struct ClosureResult<'blk, 'tcx: 'blk> { llbox: ValueRef, // llvalue of ptr to closure cdata_ty: ty::t, // type of the closure data - bcx: &'a Block<'a> // final bcx + bcx: Block<'blk, 'tcx> // final bcx } // Given a block context and a list of tydescs and values to bind // construct a closure out of them. If copying is true, it is a // heap allocated closure that copies the upvars into environment. // Otherwise, it is stack allocated and copies pointers to the upvars. -pub fn store_environment<'a>( - bcx: &'a Block<'a>, - bound_values: Vec<EnvValue> , - store: ty::TraitStore) - -> ClosureResult<'a> { +pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + bound_values: Vec<EnvValue> , + store: ty::TraitStore) + -> ClosureResult<'blk, 'tcx> { let _icx = push_ctxt("closure::store_environment"); let ccx = bcx.ccx(); let tcx = ccx.tcx(); @@ -224,12 +223,11 @@ pub fn store_environment<'a>( // Given a context and a list of upvars, build a closure. This just // collects the upvars and packages them up for store_environment. -fn build_closure<'a>(bcx0: &'a Block<'a>, - freevar_mode: freevars::CaptureMode, - freevars: &Vec<freevars::freevar_entry>, - store: ty::TraitStore) - -> ClosureResult<'a> -{ +fn build_closure<'blk, 'tcx>(bcx0: Block<'blk, 'tcx>, + freevar_mode: freevars::CaptureMode, + freevars: &Vec<freevars::freevar_entry>, + store: ty::TraitStore) + -> ClosureResult<'blk, 'tcx> { let _icx = push_ctxt("closure::build_closure"); // If we need to, package up the iterator body to call @@ -248,11 +246,11 @@ fn build_closure<'a>(bcx0: &'a Block<'a>, // Given an enclosing block context, a new function context, a closure type, // and a list of upvars, generate code to load and populate the environment // with the upvars and type descriptors. -fn load_environment<'a>(bcx: &'a Block<'a>, - cdata_ty: ty::t, - freevars: &Vec<freevars::freevar_entry>, - store: ty::TraitStore) - -> &'a Block<'a> { +fn load_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + cdata_ty: ty::t, + freevars: &Vec<freevars::freevar_entry>, + store: ty::TraitStore) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("closure::load_environment"); // Don't bother to create the block if there's nothing to load @@ -301,12 +299,12 @@ fn load_environment<'a>(bcx: &'a Block<'a>, bcx } -fn load_unboxed_closure_environment<'a>( - bcx: &'a Block<'a>, +fn load_unboxed_closure_environment<'blk, 'tcx>( + bcx: Block<'blk, 'tcx>, arg_scope_id: ScopeId, freevars: &Vec<freevars::freevar_entry>, closure_id: ast::DefId) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { let _icx = push_ctxt("closure::load_environment"); if freevars.len() == 0 { @@ -343,20 +341,19 @@ fn load_unboxed_closure_environment<'a>( bcx } -fn fill_fn_pair(bcx: &Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) { +fn fill_fn_pair(bcx: Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) { Store(bcx, llfn, GEPi(bcx, pair, [0u, abi::fn_field_code])); let llenvptr = PointerCast(bcx, llenvptr, Type::i8p(bcx.ccx())); Store(bcx, llenvptr, GEPi(bcx, pair, [0u, abi::fn_field_box])); } -pub fn trans_expr_fn<'a>( - bcx: &'a Block<'a>, - store: ty::TraitStore, - decl: &ast::FnDecl, - body: &ast::Block, - id: ast::NodeId, - dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + store: ty::TraitStore, + decl: &ast::FnDecl, + body: &ast::Block, + id: ast::NodeId, + dest: expr::Dest) + -> Block<'blk, 'tcx> { /*! * * Translates the body of a closure expression. @@ -458,13 +455,13 @@ pub fn get_or_create_declaration_if_unboxed_closure(ccx: &CrateContext, Some(llfn) } -pub fn trans_unboxed_closure<'a>( - mut bcx: &'a Block<'a>, +pub fn trans_unboxed_closure<'blk, 'tcx>( + mut bcx: Block<'blk, 'tcx>, decl: &ast::FnDecl, body: &ast::Block, id: ast::NodeId, dest: expr::Dest) - -> &'a Block<'a> { + -> Block<'blk, 'tcx> { let _icx = push_ctxt("closure::trans_unboxed_closure"); debug!("trans_unboxed_closure()"); @@ -620,11 +617,11 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext, llfn } -pub fn make_closure_from_bare_fn<'a>(bcx: &'a Block<'a>, - closure_ty: ty::t, - def: def::Def, - fn_ptr: ValueRef) - -> DatumBlock<'a, Expr> { +pub fn make_closure_from_bare_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + closure_ty: ty::t, + def: def::Def, + fn_ptr: ValueRef) + -> DatumBlock<'blk, 'tcx, Expr> { let scratch = rvalue_scratch_datum(bcx, closure_ty, "__adjust"); let wrapper = get_wrapper_for_bare_fn(bcx.ccx(), closure_ty, def, fn_ptr, true); fill_fn_pair(bcx, scratch.val, wrapper, C_null(Type::i8p(bcx.ccx()))); diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 4d62386260b..4ac9ae64d5a 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -294,7 +294,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> { pub span: Option<Span>, // The arena that blocks are allocated from. - pub block_arena: &'a TypedArena<Block<'a>>, + pub block_arena: &'a TypedArena<BlockS<'a, 'tcx>>, // This function's enclosing crate context. pub ccx: &'a CrateContext<'a, 'tcx>, @@ -303,7 +303,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> { pub debug_context: debuginfo::FunctionDebugContext, // Cleanup scopes. - pub scopes: RefCell<Vec<cleanup::CleanupScope<'a>> >, + pub scopes: RefCell<Vec<cleanup::CleanupScope<'a, 'tcx>>>, } impl<'a, 'tcx> FunctionContext<'a, 'tcx> { @@ -350,7 +350,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { self.llreturn.get().unwrap() } - pub fn get_ret_slot(&self, bcx: &Block, ty: ty::t, name: &str) -> ValueRef { + pub fn get_ret_slot(&self, bcx: Block, ty: ty::t, name: &str) -> ValueRef { if self.needs_ret_allocas { base::alloca_no_lifetime(bcx, type_of::type_of(bcx.ccx(), ty), name) } else { @@ -362,34 +362,34 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { is_lpad: bool, name: &str, opt_node_id: Option<ast::NodeId>) - -> &'a Block<'a> { + -> Block<'a, 'tcx> { unsafe { let llbb = name.with_c_str(|buf| { llvm::LLVMAppendBasicBlockInContext(self.ccx.llcx(), self.llfn, buf) }); - Block::new(llbb, is_lpad, opt_node_id, self) + BlockS::new(llbb, is_lpad, opt_node_id, self) } } pub fn new_id_block(&'a self, name: &str, node_id: ast::NodeId) - -> &'a Block<'a> { + -> Block<'a, 'tcx> { self.new_block(false, name, Some(node_id)) } pub fn new_temp_block(&'a self, name: &str) - -> &'a Block<'a> { + -> Block<'a, 'tcx> { self.new_block(false, name, None) } pub fn join_blocks(&'a self, id: ast::NodeId, - in_cxs: &[&'a Block<'a>]) - -> &'a Block<'a> { + in_cxs: &[Block<'a, 'tcx>]) + -> Block<'a, 'tcx> { let out = self.new_id_block("join", id); let mut reachable = false; for bcx in in_cxs.iter() { @@ -410,7 +410,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { // code. Each basic block we generate is attached to a function, typically // with many basic blocks per function. All the basic blocks attached to a // function are organized as a directed graph. -pub struct Block<'a, 'tcx> { +pub struct BlockS<'blk, 'tcx: 'blk> { // The BasicBlockRef returned from a call to // llvm::LLVMAppendBasicBlock(llfn, name), which adds a basic // block to the function pointed to by llfn. We insert @@ -429,16 +429,18 @@ pub struct Block<'a, 'tcx> { // The function context for the function to which this block is // attached. - pub fcx: &'a FunctionContext<'a, 'tcx>, + pub fcx: &'blk FunctionContext<'blk, 'tcx>, } -impl<'a, 'tcx> Block<'a, 'tcx> { +pub type Block<'blk, 'tcx> = &'blk BlockS<'blk, 'tcx>; + +impl<'blk, 'tcx> BlockS<'blk, 'tcx> { pub fn new(llbb: BasicBlockRef, is_lpad: bool, opt_node_id: Option<ast::NodeId>, - fcx: &'a FunctionContext<'a, 'tcx>) - -> &'a Block<'a, 'tcx> { - fcx.block_arena.alloc(Block { + fcx: &'blk FunctionContext<'blk, 'tcx>) + -> Block<'blk, 'tcx> { + fcx.block_arena.alloc(BlockS { llbb: llbb, terminated: Cell::new(false), unreachable: Cell::new(false), @@ -448,11 +450,13 @@ impl<'a, 'tcx> Block<'a, 'tcx> { }) } - pub fn ccx(&self) -> &'a CrateContext<'a, 'tcx> { self.fcx.ccx } - pub fn tcx(&self) -> &'a ty::ctxt<'tcx> { + pub fn ccx(&self) -> &'blk CrateContext<'blk, 'tcx> { + self.fcx.ccx + } + pub fn tcx(&self) -> &'blk ty::ctxt<'tcx> { self.fcx.ccx.tcx() } - pub fn sess(&self) -> &'a Session { self.fcx.ccx.sess() } + pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() } pub fn ident(&self, ident: Ident) -> String { token::get_ident(ident).get().to_string() @@ -489,12 +493,11 @@ impl<'a, 'tcx> Block<'a, 'tcx> { } pub fn to_str(&self) -> String { - let blk: *const Block = self; - format!("[block {}]", blk) + format!("[block {:p}]", self) } } -impl<'blk, 'tcx> mc::Typer<'tcx> for Block<'blk, 'tcx> { +impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> { fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx() } @@ -535,12 +538,12 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for Block<'blk, 'tcx> { } pub struct Result<'blk, 'tcx: 'blk> { - pub bcx: &'blk Block<'blk, 'tcx>, + pub bcx: Block<'blk, 'tcx>, pub val: ValueRef } impl<'b, 'tcx> Result<'b, 'tcx> { - pub fn new(bcx: &'b Block<'b, 'tcx>, val: ValueRef) -> Result<'b, 'tcx> { + pub fn new(bcx: Block<'b, 'tcx>, val: ValueRef) -> Result<'b, 'tcx> { Result { bcx: bcx, val: val, @@ -745,21 +748,21 @@ pub fn is_null(val: ValueRef) -> bool { } } -pub fn monomorphize_type(bcx: Block, t: ty::t) -> ty::t { +pub fn monomorphize_type(bcx: &BlockS, t: ty::t) -> ty::t { t.subst(bcx.tcx(), &bcx.fcx.param_substs.substs) } -pub fn node_id_type(bcx: Block, id: ast::NodeId) -> ty::t { +pub fn node_id_type(bcx: &BlockS, id: ast::NodeId) -> ty::t { let tcx = bcx.tcx(); let t = ty::node_id_to_type(tcx, id); monomorphize_type(bcx, t) } -pub fn expr_ty(bcx: &Block, ex: &ast::Expr) -> ty::t { +pub fn expr_ty(bcx: Block, ex: &ast::Expr) -> ty::t { node_id_type(bcx, ex.id) } -pub fn expr_ty_adjusted(bcx: &Block, ex: &ast::Expr) -> ty::t { +pub fn expr_ty_adjusted(bcx: Block, ex: &ast::Expr) -> ty::t { monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex)) } @@ -773,7 +776,7 @@ pub enum ExprOrMethodCall { MethodCall(typeck::MethodCall) } -pub fn node_id_substs(bcx: &Block, +pub fn node_id_substs(bcx: Block, node: ExprOrMethodCall) -> subst::Substs { let tcx = bcx.tcx(); @@ -798,7 +801,7 @@ pub fn node_id_substs(bcx: &Block, substs.substp(tcx, bcx.fcx.param_substs) } -pub fn node_vtables(bcx: &Block, id: typeck::MethodCall) +pub fn node_vtables(bcx: Block, id: typeck::MethodCall) -> typeck::vtable_res { bcx.tcx().vtable_map.borrow().find(&id).map(|vts| { resolve_vtables_in_fn_ctxt(bcx.fcx, vts) @@ -876,7 +879,7 @@ pub fn find_vtable(tcx: &ty::ctxt, param_bounds.get(n_bound).clone() } -pub fn langcall(bcx: &Block, +pub fn langcall(bcx: Block, span: Option<Span>, msg: &str, li: LangItem) diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 9ec52341348..dd9e41a61bf 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -41,9 +41,9 @@ use syntax::visit::Visitor; use std::gc::Gc; -pub fn trans_stmt<'a>(cx: &'a Block<'a>, - s: &ast::Stmt) - -> &'a Block<'a> { +pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>, + s: &ast::Stmt) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_stmt"); let fcx = cx.fcx; debug!("trans_stmt({})", s.repr(cx.tcx())); @@ -83,7 +83,8 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>, return bcx; } -pub fn trans_stmt_semi<'a>(cx: &'a Block<'a>, e: &ast::Expr) -> &'a Block<'a> { +pub fn trans_stmt_semi<'blk, 'tcx>(cx: Block<'blk, 'tcx>, e: &ast::Expr) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_stmt_semi"); let ty = expr_ty(cx, e); if ty::type_needs_drop(cx.tcx(), ty) { @@ -93,10 +94,10 @@ pub fn trans_stmt_semi<'a>(cx: &'a Block<'a>, e: &ast::Expr) -> &'a Block<'a> { } } -pub fn trans_block<'a>(bcx: &'a Block<'a>, - b: &ast::Block, - mut dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_block<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + b: &ast::Block, + mut dest: expr::Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_block"); let fcx = bcx.fcx; let mut bcx = bcx; @@ -128,13 +129,13 @@ pub fn trans_block<'a>(bcx: &'a Block<'a>, return bcx; } -pub fn trans_if<'a>(bcx: &'a Block<'a>, - if_id: ast::NodeId, - cond: &ast::Expr, - thn: ast::P<ast::Block>, - els: Option<Gc<ast::Expr>>, - dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + if_id: ast::NodeId, + cond: &ast::Expr, + thn: ast::P<ast::Block>, + els: Option<Gc<ast::Expr>>, + dest: expr::Dest) + -> Block<'blk, 'tcx> { debug!("trans_if(bcx={}, if_id={}, cond={}, thn={:?}, dest={})", bcx.to_str(), if_id, bcx.expr_to_string(cond), thn.id, dest.to_string(bcx.ccx())); @@ -204,11 +205,11 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>, next_bcx } -pub fn trans_while<'a>(bcx: &'a Block<'a>, - loop_id: ast::NodeId, - cond: &ast::Expr, - body: &ast::Block) - -> &'a Block<'a> { +pub fn trans_while<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + loop_id: ast::NodeId, + cond: &ast::Expr, + body: &ast::Block) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_while"); let fcx = bcx.fcx; @@ -248,13 +249,12 @@ pub fn trans_while<'a>(bcx: &'a Block<'a>, } /// Translates a `for` loop. -pub fn trans_for<'a>( - mut bcx: &'a Block<'a>, - loop_info: NodeInfo, - pat: Gc<ast::Pat>, - head: &ast::Expr, - body: &ast::Block) - -> &'a Block<'a> { +pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + loop_info: NodeInfo, + pat: Gc<ast::Pat>, + head: &ast::Expr, + body: &ast::Block) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_for"); // bcx @@ -369,10 +369,10 @@ pub fn trans_for<'a>( next_bcx_in } -pub fn trans_loop<'a>(bcx:&'a Block<'a>, - loop_id: ast::NodeId, - body: &ast::Block) - -> &'a Block<'a> { +pub fn trans_loop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + loop_id: ast::NodeId, + body: &ast::Block) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_loop"); let fcx = bcx.fcx; @@ -405,11 +405,11 @@ pub fn trans_loop<'a>(bcx:&'a Block<'a>, return next_bcx_in; } -pub fn trans_break_cont<'a>(bcx: &'a Block<'a>, - expr_id: ast::NodeId, - opt_label: Option<Ident>, - exit: uint) - -> &'a Block<'a> { +pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr_id: ast::NodeId, + opt_label: Option<Ident>, + exit: uint) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_break_cont"); let fcx = bcx.fcx; @@ -438,23 +438,23 @@ pub fn trans_break_cont<'a>(bcx: &'a Block<'a>, return bcx; } -pub fn trans_break<'a>(bcx: &'a Block<'a>, - expr_id: ast::NodeId, - label_opt: Option<Ident>) - -> &'a Block<'a> { +pub fn trans_break<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr_id: ast::NodeId, + label_opt: Option<Ident>) + -> Block<'blk, 'tcx> { return trans_break_cont(bcx, expr_id, label_opt, cleanup::EXIT_BREAK); } -pub fn trans_cont<'a>(bcx: &'a Block<'a>, - expr_id: ast::NodeId, - label_opt: Option<Ident>) - -> &'a Block<'a> { +pub fn trans_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr_id: ast::NodeId, + label_opt: Option<Ident>) + -> Block<'blk, 'tcx> { return trans_break_cont(bcx, expr_id, label_opt, cleanup::EXIT_LOOP); } -pub fn trans_ret<'a>(bcx: &'a Block<'a>, - e: Option<Gc<ast::Expr>>) - -> &'a Block<'a> { +pub fn trans_ret<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + e: Option<Gc<ast::Expr>>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_ret"); let fcx = bcx.fcx; let mut bcx = bcx; @@ -483,11 +483,10 @@ pub fn trans_ret<'a>(bcx: &'a Block<'a>, return bcx; } -pub fn trans_fail<'a>( - bcx: &'a Block<'a>, - sp: Span, - fail_str: InternedString) - -> &'a Block<'a> { +pub fn trans_fail<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + sp: Span, + fail_str: InternedString) + -> Block<'blk, 'tcx> { let ccx = bcx.ccx(); let _icx = push_ctxt("trans_fail_value"); @@ -508,12 +507,11 @@ pub fn trans_fail<'a>( return bcx; } -pub fn trans_fail_bounds_check<'a>( - bcx: &'a Block<'a>, - sp: Span, - index: ValueRef, - len: ValueRef) - -> &'a Block<'a> { +pub fn trans_fail_bounds_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + sp: Span, + index: ValueRef, + len: ValueRef) + -> Block<'blk, 'tcx> { let ccx = bcx.ccx(); let _icx = push_ctxt("trans_fail_bounds_check"); diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 008af804a60..84d9f2cb740 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -47,8 +47,8 @@ pub struct Datum<K> { pub kind: K, } -pub struct DatumBlock<'a, K> { - pub bcx: &'a Block<'a>, +pub struct DatumBlock<'blk, 'tcx: 'blk, K> { + pub bcx: Block<'blk, 'tcx>, pub datum: Datum<K>, } @@ -94,23 +94,23 @@ pub fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum<Rvalue> { return Datum::new(val, ty, Rvalue::new(ByValue)); } -pub fn immediate_rvalue_bcx<'a>(bcx: &'a Block<'a>, - val: ValueRef, - ty: ty::t) - -> DatumBlock<'a, Rvalue> { +pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + val: ValueRef, + ty: ty::t) + -> DatumBlock<'blk, 'tcx, Rvalue> { return DatumBlock::new(bcx, immediate_rvalue(val, ty)) } -pub fn lvalue_scratch_datum<'a, A>(bcx: &'a Block<'a>, - ty: ty::t, - name: &str, - zero: bool, - scope: cleanup::ScopeId, - arg: A, - populate: |A, &'a Block<'a>, ValueRef| - -> &'a Block<'a>) - -> DatumBlock<'a, Lvalue> { +pub fn lvalue_scratch_datum<'blk, 'tcx, A>(bcx: Block<'blk, 'tcx>, + ty: ty::t, + name: &str, + zero: bool, + scope: cleanup::ScopeId, + arg: A, + populate: |A, Block<'blk, 'tcx>, ValueRef| + -> Block<'blk, 'tcx>) + -> DatumBlock<'blk, 'tcx, Lvalue> { /*! * Allocates temporary space on the stack using alloca() and * returns a by-ref Datum pointing to it. The memory will be @@ -135,7 +135,7 @@ pub fn lvalue_scratch_datum<'a, A>(bcx: &'a Block<'a>, DatumBlock::new(bcx, Datum::new(scratch, ty, Lvalue)) } -pub fn rvalue_scratch_datum(bcx: &Block, +pub fn rvalue_scratch_datum(bcx: Block, ty: ty::t, name: &str) -> Datum<Rvalue> { @@ -188,11 +188,11 @@ pub trait KindOps { * Take appropriate action after the value in `datum` has been * stored to a new location. */ - fn post_store<'a>(&self, - bcx: &'a Block<'a>, - val: ValueRef, - ty: ty::t) - -> &'a Block<'a>; + fn post_store<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + val: ValueRef, + ty: ty::t) + -> Block<'blk, 'tcx>; /** * True if this mode is a reference mode, meaning that the datum's @@ -208,11 +208,11 @@ pub trait KindOps { } impl KindOps for Rvalue { - fn post_store<'a>(&self, - bcx: &'a Block<'a>, - _val: ValueRef, - _ty: ty::t) - -> &'a Block<'a> { + fn post_store<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + _val: ValueRef, + _ty: ty::t) + -> Block<'blk, 'tcx> { // No cleanup is scheduled for an rvalue, so we don't have // to do anything after a move to cancel or duplicate it. bcx @@ -228,11 +228,11 @@ impl KindOps for Rvalue { } impl KindOps for Lvalue { - fn post_store<'a>(&self, - bcx: &'a Block<'a>, - val: ValueRef, - ty: ty::t) - -> &'a Block<'a> { + fn post_store<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + val: ValueRef, + ty: ty::t) + -> Block<'blk, 'tcx> { /*! * If an lvalue is moved, we must zero out the memory in which * it resides so as to cancel cleanup. If an @T lvalue is @@ -263,11 +263,11 @@ impl KindOps for Lvalue { } impl KindOps for Expr { - fn post_store<'a>(&self, - bcx: &'a Block<'a>, - val: ValueRef, - ty: ty::t) - -> &'a Block<'a> { + fn post_store<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + val: ValueRef, + ty: ty::t) + -> Block<'blk, 'tcx> { match *self { LvalueExpr => Lvalue.post_store(bcx, val, ty), RvalueExpr(ref r) => r.post_store(bcx, val, ty), @@ -302,11 +302,11 @@ impl Datum<Rvalue> { self.val } - pub fn to_lvalue_datum_in_scope<'a>(self, - bcx: &'a Block<'a>, - name: &str, - scope: cleanup::ScopeId) - -> DatumBlock<'a, Lvalue> { + pub fn to_lvalue_datum_in_scope<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + name: &str, + scope: cleanup::ScopeId) + -> DatumBlock<'blk, 'tcx, Lvalue> { /*! * Returns an lvalue datum (that is, a by ref datum with * cleanup scheduled). If `self` is not already an lvalue, @@ -328,7 +328,8 @@ impl Datum<Rvalue> { } } - pub fn to_ref_datum<'a>(self, bcx: &'a Block<'a>) -> DatumBlock<'a, Rvalue> { + pub fn to_ref_datum<'blk, 'tcx>(self, bcx: Block<'blk, 'tcx>) + -> DatumBlock<'blk, 'tcx, Rvalue> { let mut bcx = bcx; match self.kind.mode { ByRef => DatumBlock::new(bcx, self), @@ -340,9 +341,9 @@ impl Datum<Rvalue> { } } - pub fn to_appropriate_datum<'a>(self, - bcx: &'a Block<'a>) - -> DatumBlock<'a, Rvalue> { + pub fn to_appropriate_datum<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>) + -> DatumBlock<'blk, 'tcx, Rvalue> { match self.appropriate_rvalue_mode(bcx.ccx()) { ByRef => { self.to_ref_datum(bcx) @@ -381,7 +382,7 @@ impl Datum<Expr> { } #[allow(dead_code)] // potentially useful - pub fn assert_lvalue(self, bcx: &Block) -> Datum<Lvalue> { + pub fn assert_lvalue(self, bcx: Block) -> Datum<Lvalue> { /*! * Asserts that this datum *is* an lvalue and returns it. */ @@ -391,7 +392,7 @@ impl Datum<Expr> { |_| bcx.sess().bug("assert_lvalue given rvalue")) } - pub fn assert_rvalue(self, bcx: &Block) -> Datum<Rvalue> { + pub fn assert_rvalue(self, bcx: Block) -> Datum<Rvalue> { /*! * Asserts that this datum *is* an lvalue and returns it. */ @@ -401,11 +402,11 @@ impl Datum<Expr> { |r| r) } - pub fn store_to_dest<'a>(self, - bcx: &'a Block<'a>, - dest: expr::Dest, - expr_id: ast::NodeId) - -> &'a Block<'a> { + pub fn store_to_dest<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + dest: expr::Dest, + expr_id: ast::NodeId) + -> Block<'blk, 'tcx> { match dest { expr::Ignore => { self.add_clean_if_rvalue(bcx, expr_id); @@ -417,9 +418,9 @@ impl Datum<Expr> { } } - pub fn add_clean_if_rvalue<'a>(self, - bcx: &'a Block<'a>, - expr_id: ast::NodeId) { + pub fn add_clean_if_rvalue<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + expr_id: ast::NodeId) { /*! * Arranges cleanup for `self` if it is an rvalue. Use when * you are done working with a value that may need drop. @@ -433,11 +434,11 @@ impl Datum<Expr> { }) } - pub fn clean<'a>(self, - bcx: &'a Block<'a>, - name: &'static str, - expr_id: ast::NodeId) - -> &'a Block<'a> { + pub fn clean<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + name: &'static str, + expr_id: ast::NodeId) + -> Block<'blk, 'tcx> { /*! * Ensures that `self` will get cleaned up, if it is not an lvalue * already. @@ -446,11 +447,11 @@ impl Datum<Expr> { self.to_lvalue_datum(bcx, name, expr_id).bcx } - pub fn to_lvalue_datum<'a>(self, - bcx: &'a Block<'a>, - name: &str, - expr_id: ast::NodeId) - -> DatumBlock<'a, Lvalue> { + pub fn to_lvalue_datum<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + name: &str, + expr_id: ast::NodeId) + -> DatumBlock<'blk, 'tcx, Lvalue> { debug!("to_lvalue_datum self: {}", self.to_string(bcx.ccx())); assert!(ty::lltype_is_sized(bcx.tcx(), self.ty), @@ -463,10 +464,10 @@ impl Datum<Expr> { }) } - pub fn to_rvalue_datum<'a>(self, - bcx: &'a Block<'a>, - name: &'static str) - -> DatumBlock<'a, Rvalue> { + pub fn to_rvalue_datum<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + name: &'static str) + -> DatumBlock<'blk, 'tcx, Rvalue> { /*! * Ensures that we have an rvalue datum (that is, a datum with * no cleanup scheduled). @@ -514,11 +515,9 @@ impl Datum<Lvalue> { // datum may also be unsized _without the size information_. It is the // callers responsibility to package the result in some way to make a valid // datum in that case (e.g., by making a fat pointer or opened pair). - pub fn get_element<'a>(&self, - bcx: &'a Block<'a>, - ty: ty::t, - gep: |ValueRef| -> ValueRef) - -> Datum<Lvalue> { + pub fn get_element(&self, bcx: Block, ty: ty::t, + gep: |ValueRef| -> ValueRef) + -> Datum<Lvalue> { let val = match ty::get(self.ty).sty { _ if ty::type_is_sized(bcx.tcx(), self.ty) => gep(self.val), ty::ty_open(_) => { @@ -536,7 +535,7 @@ impl Datum<Lvalue> { } } - pub fn get_vec_base_and_len<'a>(&self, bcx: &'a Block<'a>) -> (ValueRef, ValueRef) { + pub fn get_vec_base_and_len(&self, bcx: Block) -> (ValueRef, ValueRef) { //! Converts a vector into the slice pair. tvec::get_base_and_len(bcx, self.val, self.ty) @@ -556,10 +555,10 @@ impl<K:KindOps> Datum<K> { Datum { val: val, ty: ty, kind: kind.to_expr_kind() } } - pub fn store_to<'a>(self, - bcx: &'a Block<'a>, - dst: ValueRef) - -> &'a Block<'a> { + pub fn store_to<'blk, 'tcx>(self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! * Moves or copies this value into a new home, as appropriate * depending on the type of the datum. This method consumes @@ -573,10 +572,10 @@ impl<K:KindOps> Datum<K> { self.kind.post_store(bcx, self.val, self.ty) } - fn shallow_copy<'a>(&self, - bcx: &'a Block<'a>, - dst: ValueRef) - -> &'a Block<'a> { + fn shallow_copy<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! * Helper function that performs a shallow copy of this value * into `dst`, which should be a pointer to a memory location @@ -606,10 +605,10 @@ impl<K:KindOps> Datum<K> { return bcx; } - pub fn shallow_copy_and_take<'a>(&self, - bcx: &'a Block<'a>, - dst: ValueRef) - -> &'a Block<'a> { + pub fn shallow_copy_and_take<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! * Copies the value into a new location and runs any necessary * take glue on the new location. This function always @@ -638,7 +637,7 @@ impl<K:KindOps> Datum<K> { appropriate_rvalue_mode(ccx, self.ty) } - pub fn to_llscalarish<'a>(self, bcx: &'a Block<'a>) -> ValueRef { + pub fn to_llscalarish(self, bcx: Block) -> ValueRef { /*! * Converts `self` into a by-value `ValueRef`. Consumes this * datum (i.e., absolves you of responsibility to cleanup the @@ -657,33 +656,33 @@ impl<K:KindOps> Datum<K> { } } - pub fn to_llbool<'a>(self, bcx: &'a Block<'a>) -> ValueRef { + pub fn to_llbool(self, bcx: Block) -> ValueRef { assert!(ty::type_is_bool(self.ty) || ty::type_is_bot(self.ty)) self.to_llscalarish(bcx) } } -impl <'a, K> DatumBlock<'a, K> { - pub fn new(bcx: &'a Block<'a>, datum: Datum<K>) -> DatumBlock<'a, K> { +impl<'blk, 'tcx, K> DatumBlock<'blk, 'tcx, K> { + pub fn new(bcx: Block<'blk, 'tcx>, datum: Datum<K>) -> DatumBlock<'blk, 'tcx, K> { DatumBlock { bcx: bcx, datum: datum } } } -impl<'a, K:KindOps> DatumBlock<'a, K> { - pub fn to_expr_datumblock(self) -> DatumBlock<'a, Expr> { +impl<'blk, 'tcx, K:KindOps> DatumBlock<'blk, 'tcx, K> { + pub fn to_expr_datumblock(self) -> DatumBlock<'blk, 'tcx, Expr> { DatumBlock::new(self.bcx, self.datum.to_expr_datum()) } } -impl<'a> DatumBlock<'a, Expr> { +impl<'blk, 'tcx> DatumBlock<'blk, 'tcx, Expr> { pub fn store_to_dest(self, dest: expr::Dest, - expr_id: ast::NodeId) -> &'a Block<'a> { + expr_id: ast::NodeId) -> Block<'blk, 'tcx> { let DatumBlock { bcx, datum } = self; datum.store_to_dest(bcx, dest, expr_id) } - pub fn to_llbool(self) -> Result<'a> { + pub fn to_llbool(self) -> Result<'blk, 'tcx> { let DatumBlock { datum, bcx } = self; Result::new(bcx, datum.to_llbool(bcx)) } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 01633bea956..b640f9ef5af 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -832,7 +832,7 @@ pub fn create_global_var_metadata(cx: &CrateContext, /// Creates debug information for the given local variable. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_local_var_metadata(bcx: &Block, local: &ast::Local) { +pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) { if fn_should_be_ignored(bcx.fcx) { return; } @@ -867,7 +867,7 @@ pub fn create_local_var_metadata(bcx: &Block, local: &ast::Local) { /// Creates debug information for a variable captured in a closure. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_captured_var_metadata(bcx: &Block, +pub fn create_captured_var_metadata(bcx: Block, node_id: ast::NodeId, env_data_type: ty::t, env_pointer: ValueRef, @@ -954,7 +954,7 @@ pub fn create_captured_var_metadata(bcx: &Block, /// match-statement arm. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_match_binding_metadata(bcx: &Block, +pub fn create_match_binding_metadata(bcx: Block, variable_ident: ast::Ident, binding: BindingInfo) { if fn_should_be_ignored(bcx.fcx) { @@ -994,7 +994,7 @@ pub fn create_match_binding_metadata(bcx: &Block, /// Creates debug information for the given function argument. /// /// Adds the created metadata nodes directly to the crate's IR. -pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) { +pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) { if fn_should_be_ignored(bcx.fcx) { return; } @@ -1518,7 +1518,7 @@ fn compile_unit_metadata(cx: &CrateContext) { } } -fn declare_local(bcx: &Block, +fn declare_local(bcx: Block, variable_ident: ast::Ident, variable_type: ty::t, scope_metadata: DIScope, diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 303594cba8f..0421aef45ef 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -100,10 +100,10 @@ impl Dest { } } -pub fn trans_into<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - dest: Dest) - -> &'a Block<'a> { +pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + dest: Dest) + -> Block<'blk, 'tcx> { /*! * This function is equivalent to `trans(bcx, expr).store_to_dest(dest)` * but it may generate better optimized LLVM code. @@ -139,9 +139,9 @@ pub fn trans_into<'a>(bcx: &'a Block<'a>, bcx.fcx.pop_and_trans_ast_cleanup_scope(bcx, expr.id) } -pub fn trans<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { /*! * Translates an expression, returning a datum (and new block) * encapsulating the result. When possible, it is preferred to @@ -161,18 +161,18 @@ pub fn trans<'a>(bcx: &'a Block<'a>, return DatumBlock::new(bcx, datum); } -pub fn get_len(bcx: &Block, fat_ptr: ValueRef) -> ValueRef { +pub fn get_len(bcx: Block, fat_ptr: ValueRef) -> ValueRef { GEPi(bcx, fat_ptr, [0u, abi::slice_elt_len]) } -pub fn get_dataptr(bcx: &Block, fat_ptr: ValueRef) -> ValueRef { +pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef { GEPi(bcx, fat_ptr, [0u, abi::slice_elt_base]) } -fn apply_adjustments<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>) - -> DatumBlock<'a, Expr> { +fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>) + -> DatumBlock<'blk, 'tcx, Expr> { /*! * Helper for trans that apply adjustments from `expr` to `datum`, * which should be the unadjusted translation of `expr`. @@ -245,11 +245,11 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, debug!("after adjustments, datum={}", datum.to_string(bcx.ccx())); return DatumBlock::new(bcx, datum); - fn apply_autoref<'a>(autoref: &ty::AutoRef, - bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>) - -> DatumBlock<'a, Expr> { + fn apply_autoref<'blk, 'tcx>(autoref: &ty::AutoRef, + bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; let mut datum = datum; @@ -281,10 +281,10 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, datum) } - fn ref_ptr<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>) - -> DatumBlock<'a, Expr> { + fn ref_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>) + -> DatumBlock<'blk, 'tcx, Expr> { if !ty::type_is_sized(bcx.tcx(), datum.ty) { debug!("Taking address of unsized type {}", bcx.ty_to_string(datum.ty)); @@ -303,11 +303,11 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, // into a type to be destructed. If we want to end up with a Box pointer, // then mk_ty should make a Box pointer (T -> Box<T>), if we want a // borrowed reference then it should be T -> &T. - fn unsized_info<'a>(bcx: &'a Block<'a>, - kind: &ty::UnsizeKind, - id: ast::NodeId, - unsized_ty: ty::t, - mk_ty: |ty::t| -> ty::t) -> ValueRef { + fn unsized_info<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + kind: &ty::UnsizeKind, + id: ast::NodeId, + unsized_ty: ty::t, + mk_ty: |ty::t| -> ty::t) -> ValueRef { match kind { &ty::UnsizeLength(len) => C_uint(bcx.ccx(), len), &ty::UnsizeStruct(box ref k, tp_index) => match ty::get(unsized_ty).sty { @@ -327,11 +327,11 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, } } - fn unsize_expr<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - k: &ty::UnsizeKind) - -> DatumBlock<'a, Expr> { + fn unsize_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + k: &ty::UnsizeKind) + -> DatumBlock<'blk, 'tcx, Expr> { let tcx = bcx.tcx(); let datum_ty = datum.ty; let unsized_ty = ty::unsize_ty(tcx, datum_ty, k, expr.span); @@ -361,10 +361,10 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, into_fat_ptr(bcx, expr, datum, dest_ty, base, info) } - fn ref_fat_ptr<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>) - -> DatumBlock<'a, Expr> { + fn ref_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>) + -> DatumBlock<'blk, 'tcx, Expr> { let tcx = bcx.tcx(); let dest_ty = ty::close_type(tcx, datum.ty); let base = |bcx, val| Load(bcx, get_dataptr(bcx, val)); @@ -372,13 +372,13 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, into_fat_ptr(bcx, expr, datum, dest_ty, base, len) } - fn into_fat_ptr<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - dest_ty: ty::t, - base: |&'a Block<'a>, ValueRef| -> ValueRef, - info: |&'a Block<'a>, ValueRef| -> ValueRef) - -> DatumBlock<'a, Expr> { + fn into_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + dest_ty: ty::t, + base: |Block<'blk, 'tcx>, ValueRef| -> ValueRef, + info: |Block<'blk, 'tcx>, ValueRef| -> ValueRef) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; // Arrange cleanup @@ -394,11 +394,11 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, scratch.to_expr_datum()) } - fn unsize_unique_vec<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - len: uint) - -> DatumBlock<'a, Expr> { + fn unsize_unique_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + len: uint) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; let tcx = bcx.tcx(); @@ -440,11 +440,11 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, scratch.to_expr_datum()) } - fn unsize_unique_expr<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - k: &ty::UnsizeKind) - -> DatumBlock<'a, Expr> { + fn unsize_unique_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + k: &ty::UnsizeKind) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; let tcx = bcx.tcx(); @@ -475,10 +475,10 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, scratch.to_expr_datum()) } - fn add_env<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>) - -> DatumBlock<'a, Expr> { + fn add_env<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>) + -> DatumBlock<'blk, 'tcx, Expr> { // This is not the most efficient thing possible; since closures // are two words it'd be better if this were compiled in // 'dest' mode, but I can't find a nice way to structure the @@ -492,10 +492,10 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, } } -pub fn trans_to_lvalue<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - name: &str) - -> DatumBlock<'a, Lvalue> { +pub fn trans_to_lvalue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + name: &str) + -> DatumBlock<'blk, 'tcx, Lvalue> { /*! * Translates an expression in "lvalue" mode -- meaning that it * returns a reference to the memory that the expr represents. @@ -512,9 +512,9 @@ pub fn trans_to_lvalue<'a>(bcx: &'a Block<'a>, return datum.to_lvalue_datum(bcx, name, expr.id); } -fn trans_unadjusted<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn trans_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { /*! * A version of `trans` that ignores adjustments. You almost * certainly do not want to call this directly. @@ -568,16 +568,17 @@ fn trans_unadjusted<'a>(bcx: &'a Block<'a>, } }; - fn nil<'a>(bcx: &'a Block<'a>, ty: ty::t) -> DatumBlock<'a, Expr> { + fn nil<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ty: ty::t) + -> DatumBlock<'blk, 'tcx, Expr> { let llval = C_undef(type_of::type_of(bcx.ccx(), ty)); let datum = immediate_rvalue(llval, ty); DatumBlock::new(bcx, datum.to_expr_datum()) } } -fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; let fcx = bcx.fcx; let _icx = push_ctxt("trans_datum_unadjusted"); @@ -665,10 +666,10 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>, } } -fn trans_rec_field<'a>(bcx: &'a Block<'a>, - base: &ast::Expr, - field: ast::Ident) - -> DatumBlock<'a, Expr> { +fn trans_rec_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + base: &ast::Expr, + field: ast::Ident) + -> DatumBlock<'blk, 'tcx, Expr> { //! Translates `base.field`. let mut bcx = bcx; @@ -698,12 +699,12 @@ fn trans_rec_field<'a>(bcx: &'a Block<'a>, }) } -fn trans_index<'a>(bcx: &'a Block<'a>, - index_expr: &ast::Expr, - base: &ast::Expr, - idx: &ast::Expr, - method_call: MethodCall) - -> DatumBlock<'a, Expr> { +fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + index_expr: &ast::Expr, + base: &ast::Expr, + idx: &ast::Expr, + method_call: MethodCall) + -> DatumBlock<'blk, 'tcx, Expr> { //! Translates `base[idx]`. let _icx = push_ctxt("trans_index"); @@ -803,11 +804,10 @@ fn trans_index<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, elt_datum) } -fn trans_def<'a>(bcx: &'a Block<'a>, - ref_expr: &ast::Expr, - def: def::Def) - -> DatumBlock<'a, Expr> -{ +fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + ref_expr: &ast::Expr, + def: def::Def) + -> DatumBlock<'blk, 'tcx, Expr> { //! Translates a reference to a path. let _icx = push_ctxt("trans_def_lvalue"); @@ -830,8 +830,8 @@ fn trans_def<'a>(bcx: &'a Block<'a>, // an external global, and return a pointer to that. let const_ty = expr_ty(bcx, ref_expr); - fn get_val<'a>(bcx: &'a Block<'a>, did: ast::DefId, const_ty: ty::t) - -> ValueRef { + fn get_val<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, did: ast::DefId, const_ty: ty::t) + -> ValueRef { // For external constants, we don't inline. if did.krate == ast::LOCAL_CRATE { // Case 1 or 2. (The inlining in case 2 produces a new @@ -880,9 +880,9 @@ fn trans_def<'a>(bcx: &'a Block<'a>, } } -fn trans_rvalue_stmt_unadjusted<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr) - -> &'a Block<'a> { +fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr) + -> Block<'blk, 'tcx> { let mut bcx = bcx; let _icx = push_ctxt("trans_rvalue_stmt"); @@ -961,10 +961,10 @@ fn trans_rvalue_stmt_unadjusted<'a>(bcx: &'a Block<'a>, } } -fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - dest: Dest) - -> &'a Block<'a> { +fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + dest: Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_rvalue_dps_unadjusted"); let mut bcx = bcx; let tcx = bcx.tcx(); @@ -1091,12 +1091,11 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>, } } -fn trans_def_dps_unadjusted<'a>( - bcx: &'a Block<'a>, - ref_expr: &ast::Expr, - def: def::Def, - dest: Dest) - -> &'a Block<'a> { +fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + ref_expr: &ast::Expr, + def: def::Def, + dest: Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_def_dps_unadjusted"); let lldest = match dest { @@ -1140,9 +1139,10 @@ fn trans_def_dps_unadjusted<'a>( } } -fn trans_def_fn_unadjusted<'a>(bcx: &'a Block<'a>, - ref_expr: &ast::Expr, - def: def::Def) -> DatumBlock<'a, Expr> { +fn trans_def_fn_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + ref_expr: &ast::Expr, + def: def::Def) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_def_datum_unadjusted"); let llfn = match def { @@ -1167,9 +1167,9 @@ fn trans_def_fn_unadjusted<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, Datum::new(llfn, fn_ty, RvalueExpr(Rvalue::new(ByValue)))) } -pub fn trans_local_var<'a>(bcx: &'a Block<'a>, - def: def::Def) - -> Datum<Lvalue> { +pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + def: def::Def) + -> Datum<Lvalue> { /*! * Translates a reference to a local variable or argument. * This always results in an lvalue datum. @@ -1203,10 +1203,10 @@ pub fn trans_local_var<'a>(bcx: &'a Block<'a>, } }; - fn take_local<'a>(bcx: &'a Block<'a>, - table: &NodeMap<Datum<Lvalue>>, - nid: ast::NodeId) - -> Datum<Lvalue> { + fn take_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + table: &NodeMap<Datum<Lvalue>>, + nid: ast::NodeId) + -> Datum<Lvalue> { let datum = match table.find(&nid) { Some(&v) => v, None => { @@ -1275,12 +1275,12 @@ pub fn with_field_tys<R>(tcx: &ty::ctxt, } } -fn trans_struct<'a>(bcx: &'a Block<'a>, - fields: &[ast::Field], - base: Option<Gc<ast::Expr>>, - expr_span: codemap::Span, - id: ast::NodeId, - dest: Dest) -> &'a Block<'a> { +fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + fields: &[ast::Field], + base: Option<Gc<ast::Expr>>, + expr_span: codemap::Span, + id: ast::NodeId, + dest: Dest) -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_rec"); let ty = node_id_type(bcx, id); @@ -1350,12 +1350,12 @@ pub struct StructBaseInfo { * - `optbase` contains information on the base struct (if any) from * which remaining fields are copied; see comments on `StructBaseInfo`. */ -pub fn trans_adt<'a>(mut bcx: &'a Block<'a>, - ty: ty::t, - discr: ty::Disr, - fields: &[(uint, Gc<ast::Expr>)], - optbase: Option<StructBaseInfo>, - dest: Dest) -> &'a Block<'a> { +pub fn trans_adt<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + ty: ty::t, + discr: ty::Disr, + fields: &[(uint, Gc<ast::Expr>)], + optbase: Option<StructBaseInfo>, + dest: Dest) -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_adt"); let fcx = bcx.fcx; let repr = adt::represent_type(bcx.ccx(), ty); @@ -1419,10 +1419,10 @@ pub fn trans_adt<'a>(mut bcx: &'a Block<'a>, } -fn trans_immediate_lit<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - lit: ast::Lit) - -> DatumBlock<'a, Expr> { +fn trans_immediate_lit<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + lit: ast::Lit) + -> DatumBlock<'blk, 'tcx, Expr> { // must not be a string constant, that is a RvalueDpsExpr let _icx = push_ctxt("trans_immediate_lit"); let ty = expr_ty(bcx, expr); @@ -1430,11 +1430,11 @@ fn trans_immediate_lit<'a>(bcx: &'a Block<'a>, immediate_rvalue_bcx(bcx, v, ty).to_expr_datumblock() } -fn trans_unary<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - op: ast::UnOp, - sub_expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + op: ast::UnOp, + sub_expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { let ccx = bcx.ccx(); let mut bcx = bcx; let _icx = push_ctxt("trans_unary_datum"); @@ -1481,11 +1481,11 @@ fn trans_unary<'a>(bcx: &'a Block<'a>, } } -fn trans_uniq_expr<'a>(bcx: &'a Block<'a>, - box_ty: ty::t, - contents: &ast::Expr, - contents_ty: ty::t) - -> DatumBlock<'a, Expr> { +fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + box_ty: ty::t, + contents: &ast::Expr, + contents_ty: ty::t) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_uniq_expr"); let fcx = bcx.fcx; assert!(ty::type_is_sized(bcx.tcx(), contents_ty)); @@ -1510,11 +1510,11 @@ fn trans_uniq_expr<'a>(bcx: &'a Block<'a>, immediate_rvalue_bcx(bcx, val, box_ty).to_expr_datumblock() } -fn trans_managed_expr<'a>(bcx: &'a Block<'a>, - box_ty: ty::t, - contents: &ast::Expr, - contents_ty: ty::t) - -> DatumBlock<'a, Expr> { +fn trans_managed_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + box_ty: ty::t, + contents: &ast::Expr, + contents_ty: ty::t) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_managed_expr"); let fcx = bcx.fcx; let ty = type_of::type_of(bcx.ccx(), contents_ty); @@ -1530,10 +1530,10 @@ fn trans_managed_expr<'a>(bcx: &'a Block<'a>, immediate_rvalue_bcx(bcx, bx, box_ty).to_expr_datumblock() } -fn trans_addr_of<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - subexpr: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + subexpr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_addr_of"); let mut bcx = bcx; let sub_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, subexpr, "addr_of")); @@ -1563,16 +1563,15 @@ fn trans_addr_of<'a>(bcx: &'a Block<'a>, // Important to get types for both lhs and rhs, because one might be _|_ // and the other not. -fn trans_eager_binop<'a>( - bcx: &'a Block<'a>, - binop_expr: &ast::Expr, - binop_ty: ty::t, - op: ast::BinOp, - lhs_t: ty::t, - lhs: ValueRef, - rhs_t: ty::t, - rhs: ValueRef) - -> DatumBlock<'a, Expr> { +fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + binop_expr: &ast::Expr, + binop_ty: ty::t, + op: ast::BinOp, + lhs_t: ty::t, + lhs: ValueRef, + rhs_t: ty::t, + rhs: ValueRef) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_eager_binop"); let tcx = bcx.tcx(); @@ -1663,13 +1662,12 @@ enum lazy_binop_ty { lazy_or, } -fn trans_lazy_binop<'a>( - bcx: &'a Block<'a>, - binop_expr: &ast::Expr, - op: lazy_binop_ty, - a: &ast::Expr, - b: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn trans_lazy_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + binop_expr: &ast::Expr, + op: lazy_binop_ty, + a: &ast::Expr, + b: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_lazy_binop"); let binop_ty = expr_ty(bcx, binop_expr); let fcx = bcx.fcx; @@ -1703,12 +1701,12 @@ fn trans_lazy_binop<'a>( return immediate_rvalue_bcx(join, phi, binop_ty).to_expr_datumblock(); } -fn trans_binary<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - op: ast::BinOp, - lhs: &ast::Expr, - rhs: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn trans_binary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + op: ast::BinOp, + lhs: &ast::Expr, + rhs: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_binary"); let ccx = bcx.ccx(); @@ -1745,14 +1743,13 @@ fn trans_binary<'a>(bcx: &'a Block<'a>, } } -fn trans_overloaded_op<'a, 'b>( - bcx: &'a Block<'a>, - expr: &ast::Expr, - method_call: MethodCall, - lhs: Datum<Expr>, - rhs: Option<(Datum<Expr>, ast::NodeId)>, - dest: Option<Dest>) - -> Result<'a> { +fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + method_call: MethodCall, + lhs: Datum<Expr>, + rhs: Option<(Datum<Expr>, ast::NodeId)>, + dest: Option<Dest>) + -> Result<'blk, 'tcx> { let method_ty = bcx.tcx().method_map.borrow().get(&method_call).ty; callee::trans_call_inner(bcx, Some(expr_info(expr)), @@ -1767,13 +1764,12 @@ fn trans_overloaded_op<'a, 'b>( dest) } -fn trans_overloaded_call<'a>( - mut bcx: &'a Block<'a>, - expr: &ast::Expr, - callee: Gc<ast::Expr>, - args: &[Gc<ast::Expr>], - dest: Option<Dest>) - -> &'a Block<'a> { +fn trans_overloaded_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + callee: Gc<ast::Expr>, + args: &[Gc<ast::Expr>], + dest: Option<Dest>) + -> Block<'blk, 'tcx> { let method_call = MethodCall::expr(expr.id); let method_type = bcx.tcx() .method_map @@ -1800,7 +1796,7 @@ fn trans_overloaded_call<'a>( bcx } -fn int_cast(bcx: &Block, +fn int_cast(bcx: Block, lldsttype: Type, llsrctype: Type, llsrc: ValueRef, @@ -1822,7 +1818,7 @@ fn int_cast(bcx: &Block, } } -fn float_cast(bcx: &Block, +fn float_cast(bcx: Block, lldsttype: Type, llsrctype: Type, llsrc: ValueRef) @@ -1879,10 +1875,10 @@ fn cast_is_noop(t_in: ty::t, t_out: ty::t) -> bool { } } -fn trans_imm_cast<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - id: ast::NodeId) - -> DatumBlock<'a, Expr> { +fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + id: ast::NodeId) + -> DatumBlock<'blk, 'tcx, Expr> { let _icx = push_ctxt("trans_cast"); let mut bcx = bcx; let ccx = bcx.ccx(); @@ -1971,13 +1967,12 @@ fn trans_imm_cast<'a>(bcx: &'a Block<'a>, return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock(); } -fn trans_assign_op<'a>( - bcx: &'a Block<'a>, - expr: &ast::Expr, - op: ast::BinOp, - dst: &ast::Expr, - src: Gc<ast::Expr>) - -> &'a Block<'a> { +fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + op: ast::BinOp, + dst: &ast::Expr, + src: Gc<ast::Expr>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_assign_op"); let mut bcx = bcx; @@ -2004,10 +1999,10 @@ fn trans_assign_op<'a>( return result_datum.store_to(bcx, dst_datum.val); } -fn auto_ref<'a>(bcx: &'a Block<'a>, - datum: Datum<Expr>, - expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + datum: Datum<Expr>, + expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; // Ensure cleanup of `datum` if not already scheduled and obtain @@ -2028,11 +2023,11 @@ fn auto_ref<'a>(bcx: &'a Block<'a>, DatumBlock::new(bcx, Datum::new(llref, ptr_ty, RvalueExpr(Rvalue::new(ByValue)))) } -fn deref_multiple<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - times: uint) - -> DatumBlock<'a, Expr> { +fn deref_multiple<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + times: uint) + -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; let mut datum = datum; for i in range(0, times) { @@ -2042,11 +2037,11 @@ fn deref_multiple<'a>(bcx: &'a Block<'a>, DatumBlock { bcx: bcx, datum: datum } } -fn deref_once<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - method_call: MethodCall) - -> DatumBlock<'a, Expr> { +fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + method_call: MethodCall) + -> DatumBlock<'blk, 'tcx, Expr> { let ccx = bcx.ccx(); debug!("deref_once(expr={}, datum={}, method_call={})", @@ -2146,11 +2141,11 @@ fn deref_once<'a>(bcx: &'a Block<'a>, return r; - fn deref_owned_pointer<'a>(bcx: &'a Block<'a>, - expr: &ast::Expr, - datum: Datum<Expr>, - content_ty: ty::t) - -> DatumBlock<'a, Expr> { + fn deref_owned_pointer<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + datum: Datum<Expr>, + content_ty: ty::t) + -> DatumBlock<'blk, 'tcx, Expr> { /*! * We microoptimize derefs of owned pointers a bit here. * Basically, the idea is to make the deref of an rvalue diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 8ed45f89c29..2cb8c860944 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -247,14 +247,13 @@ pub fn register_foreign_item_fn(ccx: &CrateContext, abi: Abi, fty: ty::t, llfn } -pub fn trans_native_call<'a>( - bcx: &'a Block<'a>, - callee_ty: ty::t, - llfn: ValueRef, - llretptr: ValueRef, - llargs_rust: &[ValueRef], - passed_arg_tys: Vec<ty::t> ) - -> &'a Block<'a> { +pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + callee_ty: ty::t, + llfn: ValueRef, + llretptr: ValueRef, + llargs_rust: &[ValueRef], + passed_arg_tys: Vec<ty::t> ) + -> Block<'blk, 'tcx> { /*! * Prepares a call to a native function. This requires adapting * from the Rust argument passing rules to the native rules. diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 09d28f03392..259f85098af 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -45,7 +45,8 @@ use libc::c_uint; use syntax::ast; use syntax::parse::token; -pub fn trans_free<'a>(cx: &'a Block<'a>, v: ValueRef) -> &'a Block<'a> { +pub fn trans_free<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_free"); callee::trans_lang_call(cx, langcall(cx, None, "", FreeFnLangItem), @@ -53,8 +54,9 @@ pub fn trans_free<'a>(cx: &'a Block<'a>, v: ValueRef) -> &'a Block<'a> { Some(expr::Ignore)).bcx } -pub fn trans_exchange_free_dyn<'a>(cx: &'a Block<'a>, v: ValueRef, size: ValueRef, - align: ValueRef) -> &'a Block<'a> { +pub fn trans_exchange_free_dyn<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, + size: ValueRef, align: ValueRef) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_exchange_free"); let ccx = cx.ccx(); callee::trans_lang_call(cx, @@ -63,14 +65,14 @@ pub fn trans_exchange_free_dyn<'a>(cx: &'a Block<'a>, v: ValueRef, size: ValueRe Some(expr::Ignore)).bcx } -pub fn trans_exchange_free<'a>(cx: &'a Block<'a>, v: ValueRef, size: u64, - align: u64) -> &'a Block<'a> { +pub fn trans_exchange_free<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, + size: u64, align: u64) -> Block<'blk, 'tcx> { trans_exchange_free_dyn(cx, v, C_uint(cx.ccx(), size as uint), C_uint(cx.ccx(), align as uint)) } -pub fn trans_exchange_free_ty<'a>(bcx: &'a Block<'a>, ptr: ValueRef, - content_ty: ty::t) -> &'a Block<'a> { +pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef, + content_ty: ty::t) -> Block<'blk, 'tcx> { assert!(ty::type_is_sized(bcx.ccx().tcx(), content_ty)); let sizing_type = sizing_type_of(bcx.ccx(), content_ty); let content_size = llsize_of_alloc(bcx.ccx(), sizing_type); @@ -84,8 +86,8 @@ pub fn trans_exchange_free_ty<'a>(bcx: &'a Block<'a>, ptr: ValueRef, } } -pub fn take_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) - -> &'a Block<'a> { +pub fn take_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) + -> Block<'blk, 'tcx> { // NB: v is an *alias* of type t here, not a direct value. let _icx = push_ctxt("take_ty"); match ty::get(t).sty { @@ -123,8 +125,8 @@ pub fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t { } } -pub fn drop_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) - -> &'a Block<'a> { +pub fn drop_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) + -> Block<'blk, 'tcx> { // NB: v is an *alias* of type t here, not a direct value. debug!("drop_ty(t={})", t.repr(bcx.tcx())); let _icx = push_ctxt("drop_ty"); @@ -142,8 +144,8 @@ pub fn drop_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) bcx } -pub fn drop_ty_immediate<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) - -> &'a Block<'a> { +pub fn drop_ty_immediate<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("drop_ty_immediate"); let vp = alloca(bcx, type_of(bcx.ccx(), t), ""); Store(bcx, v, vp); @@ -232,7 +234,7 @@ pub fn lazily_emit_visit_glue(ccx: &CrateContext, ti: &tydesc_info) -> ValueRef } // See [Note-arg-mode] -pub fn call_visit_glue(bcx: &Block, v: ValueRef, tydesc: ValueRef) { +pub fn call_visit_glue(bcx: Block, v: ValueRef, tydesc: ValueRef) { let _icx = push_ctxt("call_visit_glue"); // Select the glue function to call from the tydesc @@ -242,8 +244,8 @@ pub fn call_visit_glue(bcx: &Block, v: ValueRef, tydesc: ValueRef) { Call(bcx, llfn, [llrawptr], None); } -fn make_visit_glue<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) - -> &'a Block<'a> { +fn make_visit_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("make_visit_glue"); let mut bcx = bcx; let (visitor_trait, object_ty) = match ty::visitor_object_ty(bcx.tcx(), @@ -259,13 +261,13 @@ fn make_visit_glue<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) bcx } -fn trans_struct_drop_flag<'a>(mut bcx: &'a Block<'a>, - t: ty::t, - v0: ValueRef, - dtor_did: ast::DefId, - class_did: ast::DefId, - substs: &subst::Substs) - -> &'a Block<'a> { +fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, + t: ty::t, + v0: ValueRef, + dtor_did: ast::DefId, + class_did: ast::DefId, + substs: &subst::Substs) + -> Block<'blk, 'tcx> { let repr = adt::represent_type(bcx.ccx(), t); let struct_data = if ty::type_is_sized(bcx.tcx(), t) { v0 @@ -279,13 +281,13 @@ fn trans_struct_drop_flag<'a>(mut bcx: &'a Block<'a>, }) } -fn trans_struct_drop<'a>(bcx: &'a Block<'a>, - t: ty::t, - v0: ValueRef, - dtor_did: ast::DefId, - class_did: ast::DefId, - substs: &subst::Substs) - -> &'a Block<'a> { +fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + t: ty::t, + v0: ValueRef, + dtor_did: ast::DefId, + class_did: ast::DefId, + substs: &subst::Substs) + -> Block<'blk, 'tcx> { let repr = adt::represent_type(bcx.ccx(), t); // Find and call the actual destructor @@ -371,7 +373,7 @@ fn trans_struct_drop<'a>(bcx: &'a Block<'a>, }) } -fn size_and_align_of_dst<'a>(bcx: &'a Block<'a>, t :ty::t, info: ValueRef) -> (ValueRef, ValueRef) { +fn size_and_align_of_dst(bcx: Block, t :ty::t, info: ValueRef) -> (ValueRef, ValueRef) { debug!("calculate size of DST: {}; with lost info: {}", bcx.ty_to_string(t), bcx.val_to_string(info)); if ty::type_is_sized(bcx.tcx(), t) { @@ -426,7 +428,8 @@ fn size_and_align_of_dst<'a>(bcx: &'a Block<'a>, t :ty::t, info: ValueRef) -> (V } } -fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'a> { +fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t) + -> Block<'blk, 'tcx> { // NB: v0 is an *alias* of type t here, not a direct value. let _icx = push_ctxt("make_drop_glue"); match ty::get(t).sty { @@ -549,9 +552,9 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<' } } -fn decr_refcnt_maybe_free<'a>(bcx: &'a Block<'a>, - box_ptr_ptr: ValueRef, - t: ty::t) -> &'a Block<'a> { +fn decr_refcnt_maybe_free<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + box_ptr_ptr: ValueRef, + t: ty::t) -> Block<'blk, 'tcx> { let _icx = push_ctxt("decr_refcnt_maybe_free"); let fcx = bcx.fcx; let ccx = bcx.ccx(); @@ -578,8 +581,8 @@ fn decr_refcnt_maybe_free<'a>(bcx: &'a Block<'a>, next_bcx } -fn incr_refcnt_of_boxed<'a>(bcx: &'a Block<'a>, - box_ptr_ptr: ValueRef) -> &'a Block<'a> { +fn incr_refcnt_of_boxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + box_ptr_ptr: ValueRef) -> Block<'blk, 'tcx> { let _icx = push_ctxt("incr_refcnt_of_boxed"); let ccx = bcx.ccx(); let box_ptr = Load(bcx, box_ptr_ptr); @@ -645,8 +648,8 @@ fn declare_generic_glue(ccx: &CrateContext, t: ty::t, llfnty: Type, fn make_generic_glue(ccx: &CrateContext, t: ty::t, llfn: ValueRef, - helper: <'a> |&'a Block<'a>, ValueRef, ty::t| - -> &'a Block<'a>, + helper: <'blk, 'tcx> |Block<'blk, 'tcx>, ValueRef, ty::t| + -> Block<'blk, 'tcx>, name: &str) -> ValueRef { let _icx = push_ctxt("make_generic_glue"); diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index f10df00ca91..36184b2eed3 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -134,10 +134,11 @@ pub fn check_intrinsics(ccx: &CrateContext) { ccx.sess().abort_if_errors(); } -pub fn trans_intrinsic_call<'a>(mut bcx: &'a Block<'a>, node: ast::NodeId, - callee_ty: ty::t, cleanup_scope: cleanup::CustomScopeIndex, - args: callee::CallArgs, dest: expr::Dest, - substs: subst::Substs, call_info: NodeInfo) -> Result<'a> { +pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::NodeId, + callee_ty: ty::t, cleanup_scope: cleanup::CustomScopeIndex, + args: callee::CallArgs, dest: expr::Dest, + substs: subst::Substs, call_info: NodeInfo) + -> Result<'blk, 'tcx> { let fcx = bcx.fcx; let ccx = fcx.ccx; @@ -548,7 +549,7 @@ pub fn trans_intrinsic_call<'a>(mut bcx: &'a Block<'a>, node: ast::NodeId, Result::new(bcx, llresult) } -fn copy_intrinsic(bcx: &Block, allow_overlap: bool, volatile: bool, +fn copy_intrinsic(bcx: Block, allow_overlap: bool, volatile: bool, tp_ty: ty::t, dst: ValueRef, src: ValueRef, count: ValueRef) -> ValueRef { let ccx = bcx.ccx(); let lltp_ty = type_of::type_of(ccx, tp_ty); @@ -577,7 +578,7 @@ fn copy_intrinsic(bcx: &Block, allow_overlap: bool, volatile: bool, C_bool(ccx, volatile)], None) } -fn memset_intrinsic(bcx: &Block, volatile: bool, tp_ty: ty::t, +fn memset_intrinsic(bcx: Block, volatile: bool, tp_ty: ty::t, dst: ValueRef, val: ValueRef, count: ValueRef) -> ValueRef { let ccx = bcx.ccx(); let lltp_ty = type_of::type_of(ccx, tp_ty); @@ -596,13 +597,13 @@ fn memset_intrinsic(bcx: &Block, volatile: bool, tp_ty: ty::t, C_bool(ccx, volatile)], None) } -fn count_zeros_intrinsic(bcx: &Block, name: &'static str, val: ValueRef) -> ValueRef { +fn count_zeros_intrinsic(bcx: Block, name: &'static str, val: ValueRef) -> ValueRef { let y = C_bool(bcx.ccx(), false); let llfn = bcx.ccx().get_intrinsic(&name); Call(bcx, llfn, [val, y], None) } -fn with_overflow_intrinsic(bcx: &Block, name: &'static str, t: ty::t, +fn with_overflow_intrinsic(bcx: Block, name: &'static str, t: ty::t, a: ValueRef, b: ValueRef) -> ValueRef { let llfn = bcx.ccx().get_intrinsic(&name); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index c002f3e72c8..fb1a764f0fc 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -102,12 +102,11 @@ pub fn trans_impl(ccx: &CrateContext, } } -pub fn trans_method_callee<'a>( - bcx: &'a Block<'a>, - method_call: MethodCall, - self_expr: Option<&ast::Expr>, - arg_cleanup_scope: cleanup::ScopeId) - -> Callee<'a> { +pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + method_call: MethodCall, + self_expr: Option<&ast::Expr>, + arg_cleanup_scope: cleanup::ScopeId) + -> Callee<'blk, 'tcx> { let _icx = push_ctxt("meth::trans_method_callee"); let (origin, method_ty) = match bcx.tcx().method_map @@ -166,7 +165,7 @@ pub fn trans_method_callee<'a>( } } -pub fn trans_static_method_callee(bcx: &Block, +pub fn trans_static_method_callee(bcx: Block, method_id: ast::DefId, trait_id: ast::DefId, expr_id: ast::NodeId) @@ -262,13 +261,12 @@ fn method_with_name(ccx: &CrateContext, impl_id: ast::DefId, name: ast::Name) meth_did.def_id() } -fn trans_monomorphized_callee<'a>( - bcx: &'a Block<'a>, - method_call: MethodCall, - trait_id: ast::DefId, - n_method: uint, - vtbl: typeck::vtable_origin) - -> Callee<'a> { +fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + method_call: MethodCall, + trait_id: ast::DefId, + n_method: uint, + vtbl: typeck::vtable_origin) + -> Callee<'blk, 'tcx> { let _icx = push_ctxt("meth::trans_monomorphized_callee"); match vtbl { typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => { @@ -324,7 +322,7 @@ fn trans_monomorphized_callee<'a>( } } -fn combine_impl_and_methods_tps(bcx: &Block, +fn combine_impl_and_methods_tps(bcx: Block, node: ExprOrMethodCall, rcvr_substs: subst::Substs, rcvr_origins: typeck::vtable_res) @@ -378,12 +376,12 @@ fn combine_impl_and_methods_tps(bcx: &Block, (ty_substs, vtables) } -fn trans_trait_callee<'a>(bcx: &'a Block<'a>, - method_ty: ty::t, - n_method: uint, - self_expr: &ast::Expr, - arg_cleanup_scope: cleanup::ScopeId) - -> Callee<'a> { +fn trans_trait_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + method_ty: ty::t, + n_method: uint, + self_expr: &ast::Expr, + arg_cleanup_scope: cleanup::ScopeId) + -> Callee<'blk, 'tcx> { /*! * Create a method callee where the method is coming from a trait * object (e.g., Box<Trait> type). In this case, we must pull the fn @@ -422,11 +420,11 @@ fn trans_trait_callee<'a>(bcx: &'a Block<'a>, trans_trait_callee_from_llval(bcx, method_ty, n_method, llval) } -pub fn trans_trait_callee_from_llval<'a>(bcx: &'a Block<'a>, - callee_ty: ty::t, - n_method: uint, - llpair: ValueRef) - -> Callee<'a> { +pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + callee_ty: ty::t, + n_method: uint, + llpair: ValueRef) + -> Callee<'blk, 'tcx> { /*! * Same as `trans_trait_callee()` above, except that it is given * a by-ref pointer to the object pair. @@ -476,7 +474,7 @@ pub fn trans_trait_callee_from_llval<'a>(bcx: &'a Block<'a>, /// Creates the self type and (fake) callee substitutions for an unboxed /// closure with the given def ID. The static region and type parameters are /// lies, but we're in trans so it doesn't matter. -fn get_callee_substitutions_for_unboxed_closure(bcx: &Block, +fn get_callee_substitutions_for_unboxed_closure(bcx: Block, def_id: ast::DefId) -> subst::Substs { let self_ty = ty::mk_unboxed_closure(bcx.tcx(), def_id, ty::ReStatic); @@ -495,7 +493,7 @@ fn get_callee_substitutions_for_unboxed_closure(bcx: &Block, /// Creates a returns a dynamic vtable for the given type and vtable origin. /// This is used only for objects. -fn get_vtable(bcx: &Block, +fn get_vtable(bcx: Block, self_ty: ty::t, origins: typeck::vtable_param_res) -> ValueRef @@ -630,7 +628,7 @@ pub fn make_vtable<I: Iterator<ValueRef>>(ccx: &CrateContext, } } -fn emit_vtable_methods(bcx: &Block, +fn emit_vtable_methods(bcx: Block, impl_id: ast::DefId, substs: subst::Substs, vtables: typeck::vtable_res) @@ -686,9 +684,9 @@ fn emit_vtable_methods(bcx: &Block, }).collect() } -pub fn vtable_ptr<'a>(bcx: &'a Block<'a>, - id: ast::NodeId, - self_ty: ty::t) -> ValueRef { +pub fn vtable_ptr(bcx: Block, + id: ast::NodeId, + self_ty: ty::t) -> ValueRef { let ccx = bcx.ccx(); let origins = { let vtable_map = ccx.tcx().vtable_map.borrow(); @@ -706,11 +704,11 @@ pub fn vtable_ptr<'a>(bcx: &'a Block<'a>, get_vtable(bcx, self_ty, origins) } -pub fn trans_trait_cast<'a>(bcx: &'a Block<'a>, - datum: Datum<Expr>, - id: ast::NodeId, - dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_trait_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + datum: Datum<Expr>, + id: ast::NodeId, + dest: expr::Dest) + -> Block<'blk, 'tcx> { /*! * Generates the code to convert from a pointer (`Box<T>`, `&T`, etc) * into an object (`Box<Trait>`, `&Trait`, etc). This means creating a diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 1fcf4c18912..214726edd77 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -33,15 +33,15 @@ use syntax::ast_map; use syntax::parse::token::{InternedString, special_idents}; use syntax::parse::token; -pub struct Reflector<'a, 'b> { +pub struct Reflector<'a, 'blk, 'tcx: 'blk> { visitor_val: ValueRef, visitor_items: &'a [ty::ImplOrTraitItem], - final_bcx: &'b Block<'b>, + final_bcx: Block<'blk, 'tcx>, tydesc_ty: Type, - bcx: &'b Block<'b> + bcx: Block<'blk, 'tcx> } -impl<'a, 'b> Reflector<'a, 'b> { +impl<'a, 'blk, 'tcx> Reflector<'a, 'blk, 'tcx> { pub fn c_uint(&mut self, u: uint) -> ValueRef { C_uint(self.bcx.ccx(), u) } @@ -419,12 +419,11 @@ impl<'a, 'b> Reflector<'a, 'b> { } // Emit a sequence of calls to visit_ty::visit_foo -pub fn emit_calls_to_trait_visit_ty<'a>( - bcx: &'a Block<'a>, - t: ty::t, - visitor_val: ValueRef, - visitor_trait_id: DefId) - -> &'a Block<'a> { +pub fn emit_calls_to_trait_visit_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + t: ty::t, + visitor_val: ValueRef, + visitor_trait_id: DefId) + -> Block<'blk, 'tcx> { let fcx = bcx.fcx; let final = fcx.new_temp_block("final"); let tydesc_ty = ty::get_tydesc_ty(bcx.tcx()).unwrap(); diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 285105d22f6..00b9977c752 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -35,29 +35,28 @@ use util::ppaux::ty_to_string; use syntax::ast; use syntax::parse::token::InternedString; -fn get_len(bcx: &Block, vptr: ValueRef) -> ValueRef { +fn get_len(bcx: Block, vptr: ValueRef) -> ValueRef { let _icx = push_ctxt("tvec::get_lenl"); Load(bcx, expr::get_len(bcx, vptr)) } -fn get_dataptr(bcx: &Block, vptr: ValueRef) -> ValueRef { +fn get_dataptr(bcx: Block, vptr: ValueRef) -> ValueRef { let _icx = push_ctxt("tvec::get_dataptr"); Load(bcx, expr::get_dataptr(bcx, vptr)) } -pub fn pointer_add_byte(bcx: &Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { +pub fn pointer_add_byte(bcx: Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { let _icx = push_ctxt("tvec::pointer_add_byte"); let old_ty = val_ty(ptr); let bptr = PointerCast(bcx, ptr, Type::i8p(bcx.ccx())); return PointerCast(bcx, InBoundsGEP(bcx, bptr, [bytes]), old_ty); } -pub fn make_drop_glue_unboxed<'a>( - bcx: &'a Block<'a>, - vptr: ValueRef, - unit_ty: ty::t, - should_deallocate: bool) - -> &'a Block<'a> { +pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + vptr: ValueRef, + unit_ty: ty::t, + should_deallocate: bool) + -> Block<'blk, 'tcx> { let not_null = IsNotNull(bcx, vptr); with_cond(bcx, not_null, |bcx| { let ccx = bcx.ccx(); @@ -105,11 +104,10 @@ impl VecTypes { } } -pub fn trans_fixed_vstore<'a>( - bcx: &'a Block<'a>, - expr: &ast::Expr, - dest: expr::Dest) - -> &'a Block<'a> { +pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + expr: &ast::Expr, + dest: expr::Dest) + -> Block<'blk, 'tcx> { //! // // [...] allocates a fixed-size array and moves it around "by value". @@ -133,10 +131,10 @@ pub fn trans_fixed_vstore<'a>( }; } -pub fn trans_slice_vec<'a>(bcx: &'a Block<'a>, - slice_expr: &ast::Expr, - content_expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + slice_expr: &ast::Expr, + content_expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { /*! * &[...] allocates memory on the stack and writes the values into it, * returning the vector (the caller must make the reference). "..." is @@ -207,12 +205,11 @@ pub fn trans_slice_vec<'a>(bcx: &'a Block<'a>, immediate_rvalue_bcx(bcx, llfixed, vec_ty).to_expr_datumblock() } -pub fn trans_lit_str<'a>( - bcx: &'a Block<'a>, - lit_expr: &ast::Expr, - str_lit: InternedString, - dest: Dest) - -> &'a Block<'a> { +pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + lit_expr: &ast::Expr, + str_lit: InternedString, + dest: Dest) + -> Block<'blk, 'tcx> { /*! * Literal strings translate to slices into static memory. This is * different from trans_slice_vstore() above because it doesn't need to copy @@ -239,10 +236,10 @@ pub fn trans_lit_str<'a>( } } -pub fn trans_uniq_vec<'a>(bcx: &'a Block<'a>, - uniq_expr: &ast::Expr, - content_expr: &ast::Expr) - -> DatumBlock<'a, Expr> { +pub fn trans_uniq_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + uniq_expr: &ast::Expr, + content_expr: &ast::Expr) + -> DatumBlock<'blk, 'tcx, Expr> { /*! * Box<[...]> and "...".to_string() allocate boxes in the exchange heap and write * the array elements into them. @@ -327,13 +324,12 @@ pub fn trans_uniq_vec<'a>(bcx: &'a Block<'a>, } } -pub fn write_content<'a>( - bcx: &'a Block<'a>, - vt: &VecTypes, - vstore_expr: &ast::Expr, - content_expr: &ast::Expr, - dest: Dest) - -> &'a Block<'a> { +pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + vt: &VecTypes, + vstore_expr: &ast::Expr, + content_expr: &ast::Expr, + dest: Dest) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("tvec::write_content"); let fcx = bcx.fcx; let mut bcx = bcx; @@ -429,12 +425,12 @@ pub fn write_content<'a>( } } -pub fn vec_types_from_expr(bcx: &Block, vec_expr: &ast::Expr) -> VecTypes { +pub fn vec_types_from_expr(bcx: Block, vec_expr: &ast::Expr) -> VecTypes { let vec_ty = node_id_type(bcx, vec_expr.id); vec_types(bcx, ty::sequence_element_type(bcx.tcx(), vec_ty)) } -pub fn vec_types(bcx: &Block, unit_ty: ty::t) -> VecTypes { +pub fn vec_types(bcx: Block, unit_ty: ty::t) -> VecTypes { let ccx = bcx.ccx(); let llunit_ty = type_of::type_of(ccx, unit_ty); let llunit_size = nonzero_llsize_of(ccx, llunit_ty); @@ -448,7 +444,7 @@ pub fn vec_types(bcx: &Block, unit_ty: ty::t) -> VecTypes { } } -pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint { +pub fn elements_required(bcx: Block, content_expr: &ast::Expr) -> uint { //! Figure out the number of elements we need to store this content match content_expr.node { @@ -470,7 +466,7 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint { } } -pub fn get_fixed_base_and_len(bcx: &Block, +pub fn get_fixed_base_and_len(bcx: Block, llval: ValueRef, vec_length: uint) -> (ValueRef, ValueRef) { @@ -486,7 +482,7 @@ pub fn get_fixed_base_and_len(bcx: &Block, (base, len) } -fn get_slice_base_and_len(bcx: &Block, +fn get_slice_base_and_len(bcx: Block, llval: ValueRef) -> (ValueRef, ValueRef) { let base = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_base])); @@ -494,7 +490,7 @@ fn get_slice_base_and_len(bcx: &Block, (base, len) } -pub fn get_base_and_len(bcx: &Block, +pub fn get_base_and_len(bcx: Block, llval: ValueRef, vec_ty: ty::t) -> (ValueRef, ValueRef) { @@ -528,17 +524,15 @@ pub fn get_base_and_len(bcx: &Block, } } -pub type iter_vec_block<'r,'b> = - |&'b Block<'b>, ValueRef, ty::t|: 'r -> &'b Block<'b>; - -pub fn iter_vec_loop<'r, - 'b>( - bcx: &'b Block<'b>, - data_ptr: ValueRef, - vt: &VecTypes, - count: ValueRef, - f: iter_vec_block<'r,'b>) - -> &'b Block<'b> { +pub type iter_vec_block<'a, 'blk, 'tcx> = + |Block<'blk, 'tcx>, ValueRef, ty::t|: 'a -> Block<'blk, 'tcx>; + +pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + data_ptr: ValueRef, + vt: &VecTypes, + count: ValueRef, + f: iter_vec_block<'a, 'blk, 'tcx>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("tvec::iter_vec_loop"); let fcx = bcx.fcx; @@ -589,14 +583,12 @@ pub fn iter_vec_loop<'r, next_bcx } -pub fn iter_vec_raw<'r, - 'b>( - bcx: &'b Block<'b>, - data_ptr: ValueRef, - unit_ty: ty::t, - len: ValueRef, - f: iter_vec_block<'r,'b>) - -> &'b Block<'b> { +pub fn iter_vec_raw<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, + data_ptr: ValueRef, + unit_ty: ty::t, + len: ValueRef, + f: iter_vec_block<'a, 'blk, 'tcx>) + -> Block<'blk, 'tcx> { let _icx = push_ctxt("tvec::iter_vec_raw"); let fcx = bcx.fcx; diff --git a/src/librustc/middle/trans/value.rs b/src/librustc/middle/trans/value.rs index 2db6a87a9dc..dfa4ae6b285 100644 --- a/src/librustc/middle/trans/value.rs +++ b/src/librustc/middle/trans/value.rs @@ -55,7 +55,7 @@ impl Value { /// This only performs a search for a trivially dominating store. The store /// must be the only user of this value, and there must not be any conditional /// branches between the store and the given block. - pub fn get_dominating_store(self, bcx: &Block) -> Option<Value> { + pub fn get_dominating_store(self, bcx: Block) -> Option<Value> { match self.get_single_user().and_then(|user| user.as_store_inst()) { Some(store) => { store.get_parent().and_then(|store_bb| { |
