Skip to content
Permalink
Browse files

Use a single lifetime for MIR construction

  • Loading branch information...
Zoxc committed Jun 1, 2019
1 parent 24ddd16 commit d3e1181b1cabb45388b0141974b01ca3ec36c8b9
@@ -465,7 +465,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
/// Helper type of a temporary returned by `tcx.infer_ctxt()`.
/// Necessary because we can't write the following bound:
/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`.
pub struct InferCtxtBuilder<'gcx, 'tcx> {
pub struct InferCtxtBuilder<'gcx: 'tcx, 'tcx> {
global_tcx: TyCtxt<'gcx, 'gcx>,
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
}
@@ -510,7 +510,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
})
}

pub fn enter<R>(&'tcx mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R {
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R {
let InferCtxtBuilder {
global_tcx,
ref fresh_tables,
@@ -6,7 +6,7 @@ use rustc::mir::*;
use rustc::hir;
use syntax_pos::Span;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn ast_block(&mut self,
destination: &Place<'tcx>,
block: BasicBlock,
@@ -5,7 +5,7 @@ use crate::hair::*;
use rustc::mir::*;
use rustc::ty::CanonicalUserTypeAnnotation;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Compile `expr`, yielding a compile-time constant. Assumes that
/// `expr` is a valid compile-time constant!
pub fn as_constant<M>(&mut self, expr: M) -> Constant<'tcx>
@@ -6,7 +6,7 @@ use crate::hair::*;
use rustc::middle::region;
use rustc::mir::*;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Returns an operand suitable for use until the end of the current
/// scope expression.
///
@@ -10,7 +10,7 @@ use rustc::ty::{CanonicalUserTypeAnnotation, Variance};

use rustc_data_structures::indexed_vec::Idx;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Compile `expr`, yielding a place that we can move from etc.
pub fn as_place<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Place<'tcx>>
where
@@ -12,7 +12,7 @@ use rustc::mir::*;
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
use syntax_pos::Span;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// See comment on `as_local_operand`
pub fn as_local_rvalue<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Rvalue<'tcx>>
where
@@ -6,7 +6,7 @@ use crate::hair::*;
use rustc::middle::region;
use rustc::mir::*;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Compile `expr` into a fresh temporary. This is used when building
/// up rvalues so as to freeze the value that will be consumed.
pub fn as_temp<M>(
@@ -8,7 +8,7 @@ use rustc::ty;

use rustc_target::spec::abi::Abi;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Compile `expr`, storing the result into `destination`, which
/// is assumed to be uninitialized.
pub fn into_expr(
@@ -3,7 +3,7 @@ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use rustc::mir::*;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Builds a block of MIR statements to evaluate the HAIR `expr`.
/// If the original expression was an AST statement,
/// (e.g., `some().code(&here());`) then `opt_stmt_span` is the
@@ -9,14 +9,15 @@ use crate::hair::*;
use rustc::mir::*;

pub(in crate::build) trait EvalInto<'tcx> {
fn eval_into<'a, 'gcx>(self,
builder: &mut Builder<'a, 'gcx, 'tcx>,
destination: &Place<'tcx>,
block: BasicBlock)
-> BlockAnd<()>;
fn eval_into(
self,
builder: &mut Builder<'_, 'tcx>,
destination: &Place<'tcx>,
block: BasicBlock,
) -> BlockAnd<()>;
}

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn into<E>(&mut self,
destination: &Place<'tcx>,
block: BasicBlock,
@@ -29,22 +30,24 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
}

impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {
fn eval_into<'a, 'gcx>(self,
builder: &mut Builder<'a, 'gcx, 'tcx>,
destination: &Place<'tcx>,
block: BasicBlock)
-> BlockAnd<()> {
fn eval_into(
self,
builder: &mut Builder<'_, 'tcx>,
destination: &Place<'tcx>,
block: BasicBlock,
) -> BlockAnd<()> {
let expr = builder.hir.mirror(self);
builder.into_expr(destination, block, expr)
}
}

impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {
fn eval_into<'a, 'gcx>(self,
builder: &mut Builder<'a, 'gcx, 'tcx>,
destination: &Place<'tcx>,
block: BasicBlock)
-> BlockAnd<()> {
fn eval_into(
self,
builder: &mut Builder<'_, 'tcx>,
destination: &Place<'tcx>,
block: BasicBlock,
) -> BlockAnd<()> {
builder.into_expr(destination, block, self)
}
}
@@ -27,7 +27,7 @@ mod util;

use std::convert::TryFrom;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Generates MIR for a `match` expression.
///
/// The MIR that we generate for a match looks like this.
@@ -768,7 +768,7 @@ pub(crate) struct ArmHasGuard(pub bool);
///////////////////////////////////////////////////////////////////////////
// Main matching algorithm

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// The main match algorithm. It begins with a set of candidates
/// `candidates` and has the job of generating code to determine
/// which of these candidates, if any, is the correct one. The
@@ -1296,7 +1296,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
///////////////////////////////////////////////////////////////////////////
// Pattern binding - used for `let` and function parameters as well.

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Initializes each of the bindings from the candidate by
/// moving/copying/ref'ing the source as appropriate. Tests the guard, if
/// any, and then branches to the arm. Returns the block for the case where
@@ -23,7 +23,7 @@ use rustc::mir::interpret::truncate;

use std::mem;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn simplify_candidate<'pat>(&mut self,
candidate: &mut Candidate<'pat, 'tcx>) {
// repeatedly simplify match pairs until fixed point is reached
@@ -19,7 +19,7 @@ use rustc::hir::{RangeEnd, Mutability};
use syntax_pos::Span;
use std::cmp::Ordering;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Identifies what test is needed to decide if `match_pair` is applicable.
///
/// It is a bug to call this with a simplifiable pattern.
@@ -5,7 +5,7 @@ use rustc::mir::*;
use std::u32;
use std::convert::TryInto;

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn field_match_pairs<'pat>(&mut self,
place: Place<'tcx>,
subpatterns: &'pat [FieldPattern<'tcx>])
@@ -8,7 +8,7 @@ use rustc::ty::{self, Ty};
use rustc::mir::*;
use syntax_pos::{Span, DUMMY_SP};

impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Adds a new temporary value of type `ty` storing the result of
/// evaluating `expr`.
///

0 comments on commit d3e1181

Please sign in to comment.
You can’t perform that action at this time.