Skip to content

Commit 2887008

Browse files
committed
Auto merge of #61426 - Zoxc:just-tcx-mir-building, r=eddyb
Use a single lifetime for MIR construction Builds on #57214 r? @eddyb
2 parents 55cee44 + d3e1181 commit 2887008

24 files changed

+147
-196
lines changed

src/librustc/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
465465
/// Helper type of a temporary returned by `tcx.infer_ctxt()`.
466466
/// Necessary because we can't write the following bound:
467467
/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`.
468-
pub struct InferCtxtBuilder<'gcx, 'tcx> {
468+
pub struct InferCtxtBuilder<'gcx: 'tcx, 'tcx> {
469469
global_tcx: TyCtxt<'gcx, 'gcx>,
470470
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
471471
}
@@ -510,7 +510,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
510510
})
511511
}
512512

513-
pub fn enter<R>(&'tcx mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R {
513+
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R {
514514
let InferCtxtBuilder {
515515
global_tcx,
516516
ref fresh_tables,

src/librustc_mir/build/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::mir::*;
66
use rustc::hir;
77
use syntax_pos::Span;
88

9-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
9+
impl<'a, 'tcx> Builder<'a, 'tcx> {
1010
pub fn ast_block(&mut self,
1111
destination: &Place<'tcx>,
1212
block: BasicBlock,

src/librustc_mir/build/expr/as_constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::hair::*;
55
use rustc::mir::*;
66
use rustc::ty::CanonicalUserTypeAnnotation;
77

8-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8+
impl<'a, 'tcx> Builder<'a, 'tcx> {
99
/// Compile `expr`, yielding a compile-time constant. Assumes that
1010
/// `expr` is a valid compile-time constant!
1111
pub fn as_constant<M>(&mut self, expr: M) -> Constant<'tcx>

src/librustc_mir/build/expr/as_operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::hair::*;
66
use rustc::middle::region;
77
use rustc::mir::*;
88

9-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
9+
impl<'a, 'tcx> Builder<'a, 'tcx> {
1010
/// Returns an operand suitable for use until the end of the current
1111
/// scope expression.
1212
///

src/librustc_mir/build/expr/as_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc::ty::{CanonicalUserTypeAnnotation, Variance};
1010

1111
use rustc_data_structures::indexed_vec::Idx;
1212

13-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
13+
impl<'a, 'tcx> Builder<'a, 'tcx> {
1414
/// Compile `expr`, yielding a place that we can move from etc.
1515
pub fn as_place<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Place<'tcx>>
1616
where

src/librustc_mir/build/expr/as_rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc::mir::*;
1212
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
1313
use syntax_pos::Span;
1414

15-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
15+
impl<'a, 'tcx> Builder<'a, 'tcx> {
1616
/// See comment on `as_local_operand`
1717
pub fn as_local_rvalue<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Rvalue<'tcx>>
1818
where

src/librustc_mir/build/expr/as_temp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::hair::*;
66
use rustc::middle::region;
77
use rustc::mir::*;
88

9-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
9+
impl<'a, 'tcx> Builder<'a, 'tcx> {
1010
/// Compile `expr` into a fresh temporary. This is used when building
1111
/// up rvalues so as to freeze the value that will be consumed.
1212
pub fn as_temp<M>(

src/librustc_mir/build/expr/into.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::ty;
88

99
use rustc_target::spec::abi::Abi;
1010

11-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
11+
impl<'a, 'tcx> Builder<'a, 'tcx> {
1212
/// Compile `expr`, storing the result into `destination`, which
1313
/// is assumed to be uninitialized.
1414
pub fn into_expr(

src/librustc_mir/build/expr/stmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
33
use crate::hair::*;
44
use rustc::mir::*;
55

6-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
6+
impl<'a, 'tcx> Builder<'a, 'tcx> {
77
/// Builds a block of MIR statements to evaluate the HAIR `expr`.
88
/// If the original expression was an AST statement,
99
/// (e.g., `some().code(&here());`) then `opt_stmt_span` is the

src/librustc_mir/build/into.rs

+19-16
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ use crate::hair::*;
99
use rustc::mir::*;
1010

1111
pub(in crate::build) trait EvalInto<'tcx> {
12-
fn eval_into<'a, 'gcx>(self,
13-
builder: &mut Builder<'a, 'gcx, 'tcx>,
14-
destination: &Place<'tcx>,
15-
block: BasicBlock)
16-
-> BlockAnd<()>;
12+
fn eval_into(
13+
self,
14+
builder: &mut Builder<'_, 'tcx>,
15+
destination: &Place<'tcx>,
16+
block: BasicBlock,
17+
) -> BlockAnd<()>;
1718
}
1819

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

3132
impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {
32-
fn eval_into<'a, 'gcx>(self,
33-
builder: &mut Builder<'a, 'gcx, 'tcx>,
34-
destination: &Place<'tcx>,
35-
block: BasicBlock)
36-
-> BlockAnd<()> {
33+
fn eval_into(
34+
self,
35+
builder: &mut Builder<'_, 'tcx>,
36+
destination: &Place<'tcx>,
37+
block: BasicBlock,
38+
) -> BlockAnd<()> {
3739
let expr = builder.hir.mirror(self);
3840
builder.into_expr(destination, block, expr)
3941
}
4042
}
4143

4244
impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {
43-
fn eval_into<'a, 'gcx>(self,
44-
builder: &mut Builder<'a, 'gcx, 'tcx>,
45-
destination: &Place<'tcx>,
46-
block: BasicBlock)
47-
-> BlockAnd<()> {
45+
fn eval_into(
46+
self,
47+
builder: &mut Builder<'_, 'tcx>,
48+
destination: &Place<'tcx>,
49+
block: BasicBlock,
50+
) -> BlockAnd<()> {
4851
builder.into_expr(destination, block, self)
4952
}
5053
}

src/librustc_mir/build/matches/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod util;
2727

2828
use std::convert::TryFrom;
2929

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

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

1299-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1299+
impl<'a, 'tcx> Builder<'a, 'tcx> {
13001300
/// Initializes each of the bindings from the candidate by
13011301
/// moving/copying/ref'ing the source as appropriate. Tests the guard, if
13021302
/// any, and then branches to the arm. Returns the block for the case where

src/librustc_mir/build/matches/simplify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc::mir::interpret::truncate;
2323

2424
use std::mem;
2525

26-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
26+
impl<'a, 'tcx> Builder<'a, 'tcx> {
2727
pub fn simplify_candidate<'pat>(&mut self,
2828
candidate: &mut Candidate<'pat, 'tcx>) {
2929
// repeatedly simplify match pairs until fixed point is reached

src/librustc_mir/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::hir::{RangeEnd, Mutability};
1919
use syntax_pos::Span;
2020
use std::cmp::Ordering;
2121

22-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
22+
impl<'a, 'tcx> Builder<'a, 'tcx> {
2323
/// Identifies what test is needed to decide if `match_pair` is applicable.
2424
///
2525
/// It is a bug to call this with a simplifiable pattern.

src/librustc_mir/build/matches/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::mir::*;
55
use std::u32;
66
use std::convert::TryInto;
77

8-
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8+
impl<'a, 'tcx> Builder<'a, 'tcx> {
99
pub fn field_match_pairs<'pat>(&mut self,
1010
place: Place<'tcx>,
1111
subpatterns: &'pat [FieldPattern<'tcx>])

src/librustc_mir/build/misc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::ty::{self, Ty};
88
use rustc::mir::*;
99
use syntax_pos::{Span, DUMMY_SP};
1010

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

0 commit comments

Comments
 (0)