diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 11918eccfd076..538b76be7b045 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -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>>, } @@ -510,7 +510,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { }) } - pub fn enter(&'tcx mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R { + pub fn enter(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R { let InferCtxtBuilder { global_tcx, ref fresh_tables, diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index b5bab1585342a..749cd6fc8bf1e 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -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, diff --git a/src/librustc_mir/build/expr/as_constant.rs b/src/librustc_mir/build/expr/as_constant.rs index 614668170d5be..5197981a85cb8 100644 --- a/src/librustc_mir/build/expr/as_constant.rs +++ b/src/librustc_mir/build/expr/as_constant.rs @@ -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(&mut self, expr: M) -> Constant<'tcx> diff --git a/src/librustc_mir/build/expr/as_operand.rs b/src/librustc_mir/build/expr/as_operand.rs index ed80cb1a16369..dd78e7e869a8f 100644 --- a/src/librustc_mir/build/expr/as_operand.rs +++ b/src/librustc_mir/build/expr/as_operand.rs @@ -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. /// diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index a956eacb0699f..51808ef7ebdee 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -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(&mut self, block: BasicBlock, expr: M) -> BlockAnd> where diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 87e2118094caf..6d6e5de4761ab 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -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(&mut self, block: BasicBlock, expr: M) -> BlockAnd> where diff --git a/src/librustc_mir/build/expr/as_temp.rs b/src/librustc_mir/build/expr/as_temp.rs index 85423955ce545..9d907c6ec04ab 100644 --- a/src/librustc_mir/build/expr/as_temp.rs +++ b/src/librustc_mir/build/expr/as_temp.rs @@ -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( diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 7bdfdf0b0895f..a3976238fbe82 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -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( diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index ac690f89264bf..74338de67759e 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -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 diff --git a/src/librustc_mir/build/into.rs b/src/librustc_mir/build/into.rs index 67b6540febea8..077840c9ccf17 100644 --- a/src/librustc_mir/build/into.rs +++ b/src/librustc_mir/build/into.rs @@ -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(&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) } } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 0aabebcf9dc2c..4f73c92be504e 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -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 diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index 2e4f53023f409..b1b5233fbc875 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -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 diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index c767fff925322..f4755477e96ea 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -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. diff --git a/src/librustc_mir/build/matches/util.rs b/src/librustc_mir/build/matches/util.rs index 3b90ff7884f01..100c03046d1b3 100644 --- a/src/librustc_mir/build/matches/util.rs +++ b/src/librustc_mir/build/matches/util.rs @@ -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>]) diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index daf59d7a1353c..ad891b1c1ea0a 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -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`. /// diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 579a403f3aca7..e8b0def0a54ed 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -9,13 +9,10 @@ use rustc::hir::Node; use rustc::hir::def_id::DefId; use rustc::middle::region; use rustc::mir::*; -use rustc::mir::visit::{MutVisitor, TyContext}; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::subst::SubstsRef; use rustc::util::nodemap::HirIdMap; use rustc_target::spec::PanicStrategy; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -use std::mem; use std::u32; use rustc_target::spec::abi::Abi; use syntax::attr::{self, UnwindAttr}; @@ -66,7 +63,7 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> { tcx.infer_ctxt().enter(|infcx| { let cx = Cx::new(&infcx, id); - let mut body = if cx.tables().tainted_by_errors { + let body = if cx.tables().tainted_by_errors { build::construct_error(cx, body_id) } else if cx.body_owner_kind.is_fn_or_closure() { // fetch the fully liberated fn signature (that is, all bound @@ -162,16 +159,6 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> { build::construct_const(cx, body_id, return_ty, return_ty_span) }; - // Convert the `mir::Body` to global types. - let mut globalizer = GlobalizeMir { - tcx, - span: body.span - }; - globalizer.visit_body(&mut body); - let body = unsafe { - mem::transmute::, Body<'tcx>>(body) - }; - mir_util::dump_mir(tcx, None, "mir_map", &0, MirSource::item(def_id), &body, |_, _| Ok(()) ); @@ -181,61 +168,11 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> { }) } -/// A pass to lift all the types and substitutions in a MIR -/// to the global tcx. Sadly, we don't have a "folder" that -/// can change `'tcx` so we have to transmute afterwards. -struct GlobalizeMir<'gcx> { - tcx: TyCtxt<'gcx, 'gcx>, - span: Span, -} - -impl<'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'gcx> { - fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) { - if let Some(lifted) = self.tcx.lift(ty) { - *ty = lifted; - } else { - span_bug!(self.span, - "found type `{:?}` with inference types/regions in MIR", - ty); - } - } - - fn visit_region(&mut self, region: &mut ty::Region<'tcx>, _: Location) { - if let Some(lifted) = self.tcx.lift(region) { - *region = lifted; - } else { - span_bug!(self.span, - "found region `{:?}` with inference types/regions in MIR", - region); - } - } - - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) { - if let Some(lifted) = self.tcx.lift(constant) { - *constant = lifted; - } else { - span_bug!(self.span, - "found constant `{:?}` with inference types/regions in MIR", - constant); - } - } - - fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) { - if let Some(lifted) = self.tcx.lift(substs) { - *substs = lifted; - } else { - span_bug!(self.span, - "found substs `{:?}` with inference types/regions in MIR", - substs); - } - } -} - /////////////////////////////////////////////////////////////////////////// // BuildMir -- walks a crate, looking for fn items and methods to build MIR from -fn liberated_closure_env_ty<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn liberated_closure_env_ty<'tcx>( + tcx: TyCtxt<'tcx, 'tcx>, closure_expr_id: hir::HirId, body_id: hir::BodyId, ) -> Ty<'tcx> { @@ -304,8 +241,8 @@ impl BlockFrame { #[derive(Debug)] struct BlockContext(Vec); -struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - hir: Cx<'a, 'gcx, 'tcx>, +struct Builder<'a, 'tcx: 'a> { + hir: Cx<'a, 'tcx>, cfg: CFG<'tcx>, fn_span: Span, @@ -370,7 +307,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { cached_unreachable_block: Option, } -impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Builder<'a, 'tcx> { fn is_bound_var_in_guard(&self, id: hir::HirId) -> bool { self.guard_context.iter().any(|frame| frame.locals.iter().any(|local| local.id == id)) } @@ -552,7 +489,7 @@ macro_rules! unpack { }; } -fn should_abort_on_panic<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, fn_def_id: DefId, abi: Abi) -> bool { +fn should_abort_on_panic<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, fn_def_id: DefId, abi: Abi) -> bool { // Not callable from C, so we can safely unwind through these if abi == Abi::Rust || abi == Abi::RustCall { return false; } @@ -580,17 +517,19 @@ fn should_abort_on_panic<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, fn_def_id: DefId, struct ArgInfo<'gcx>(Ty<'gcx>, Option, Option<&'gcx hir::Pat>, Option); -fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, - fn_id: hir::HirId, - arguments: A, - safety: Safety, - abi: Abi, - return_ty: Ty<'gcx>, - yield_ty: Option>, - return_ty_span: Span, - body: &'gcx hir::Body) - -> Body<'tcx> - where A: Iterator> +fn construct_fn<'a, 'tcx, A>( + hir: Cx<'a, 'tcx>, + fn_id: hir::HirId, + arguments: A, + safety: Safety, + abi: Abi, + return_ty: Ty<'tcx>, + yield_ty: Option>, + return_ty_span: Span, + body: &'tcx hir::Body, +) -> Body<'tcx> +where + A: Iterator> { let arguments: Vec<_> = arguments.collect(); @@ -703,8 +642,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, body } -fn construct_const<'a, 'gcx, 'tcx>( - hir: Cx<'a, 'gcx, 'tcx>, +fn construct_const<'a, 'tcx>( + hir: Cx<'a, 'tcx>, body_id: hir::BodyId, const_ty: Ty<'tcx>, const_ty_span: Span, @@ -745,9 +684,10 @@ fn construct_const<'a, 'gcx, 'tcx>( builder.finish(None) } -fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>, - body_id: hir::BodyId) - -> Body<'tcx> { +fn construct_error<'a, 'tcx>( + hir: Cx<'a, 'tcx>, + body_id: hir::BodyId +) -> Body<'tcx> { let owner_id = hir.tcx().hir().body_owner(body_id); let span = hir.tcx().hir().span(owner_id); let ty = hir.tcx().types.err; @@ -757,8 +697,8 @@ fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>, builder.finish(None) } -impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { - fn new(hir: Cx<'a, 'gcx, 'tcx>, +impl<'a, 'tcx> Builder<'a, 'tcx> { + fn new(hir: Cx<'a, 'tcx>, span: Span, arg_count: usize, safety: Safety, @@ -767,7 +707,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { __upvar_debuginfo_codegen_only_do_not_use: Vec, upvar_mutbls: Vec, is_generator: bool) - -> Builder<'a, 'gcx, 'tcx> { + -> Builder<'a, 'tcx> { let lint_level = LintLevel::Explicit(hir.root_lint_level); let mut builder = Builder { hir, @@ -833,9 +773,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn args_and_body(&mut self, mut block: BasicBlock, - arguments: &[ArgInfo<'gcx>], + arguments: &[ArgInfo<'tcx>], argument_scope: region::Scope, - ast_body: &'gcx hir::Expr) + ast_body: &'tcx hir::Expr) -> BlockAnd<()> { // Allocate locals for the function arguments diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index b697b9884367c..db58a709e9f7c 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -257,7 +257,7 @@ impl<'tcx> Scope<'tcx> { } } -impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Builder<'a, 'tcx> { // Adding and removing scopes // ========================== /// Start a breakable scope, which tracks where `continue` and `break` @@ -269,7 +269,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { break_block: BasicBlock, break_destination: Place<'tcx>, f: F) -> R - where F: FnOnce(&mut Builder<'a, 'gcx, 'tcx>) -> R + where F: FnOnce(&mut Builder<'a, 'tcx>) -> R { let region_scope = self.topmost_scope(); let scope = BreakableScope { @@ -289,7 +289,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { opt_scope: Option<(region::Scope, SourceInfo)>, f: F) -> BlockAnd - where F: FnOnce(&mut Builder<'a, 'gcx, 'tcx>) -> BlockAnd + where F: FnOnce(&mut Builder<'a, 'tcx>) -> BlockAnd { debug!("in_opt_scope(opt_scope={:?})", opt_scope); if let Some(region_scope) = opt_scope { self.push_scope(region_scope); } @@ -309,7 +309,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { lint_level: LintLevel, f: F) -> BlockAnd - where F: FnOnce(&mut Builder<'a, 'gcx, 'tcx>) -> BlockAnd + where F: FnOnce(&mut Builder<'a, 'tcx>) -> BlockAnd { debug!("in_scope(region_scope={:?})", region_scope); let source_scope = self.source_scope; diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs index 934baa55a9043..c03ca8e669eb4 100644 --- a/src/librustc_mir/hair/constant.rs +++ b/src/librustc_mir/hair/constant.rs @@ -9,9 +9,9 @@ crate enum LitToConstError { Reported, } -crate fn lit_to_const<'gcx, 'tcx>( +crate fn lit_to_const<'tcx>( lit: &'tcx ast::LitKind, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>, neg: bool, ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 17fab6c5ddcff..63239a36a1753 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -10,7 +10,7 @@ use rustc_data_structures::indexed_vec::Idx; impl<'tcx> Mirror<'tcx> for &'tcx hir::Block { type Output = Block<'tcx>; - fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Block<'tcx> { + fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Block<'tcx> { // We have to eagerly lower the "spine" of the statements // in order to get the lexical scoping correctly. let stmts = mirror_stmts(cx, self.hir_id.local_id, &*self.stmts); @@ -40,10 +40,11 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block { } } -fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - block_id: hir::ItemLocalId, - stmts: &'tcx [hir::Stmt]) - -> Vec> { +fn mirror_stmts<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + block_id: hir::ItemLocalId, + stmts: &'tcx [hir::Stmt], +) -> Vec> { let mut result = vec![]; for (index, stmt) in stmts.iter().enumerate() { let hir_id = stmt.hir_id; @@ -114,9 +115,10 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, return result; } -pub fn to_expr_ref<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - block: &'tcx hir::Block) - -> ExprRef<'tcx> { +pub fn to_expr_ref<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + block: &'tcx hir::Block, +) -> ExprRef<'tcx> { let block_ty = cx.tables().node_type(block.hir_id); let temp_lifetime = cx.region_scope_tree.temporary_scope(block.hir_id.local_id); let expr = Expr { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 5a6b6a7483052..89452b23880c0 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -17,7 +17,7 @@ use syntax_pos::Span; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { type Output = Expr<'tcx>; - fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> { + fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Expr<'tcx> { let temp_lifetime = cx.region_scope_tree.temporary_scope(self.hir_id.local_id); let expr_scope = region::Scope { id: self.hir_id.local_id, @@ -68,11 +68,12 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { } } -fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - hir_expr: &'tcx hir::Expr, - mut expr: Expr<'tcx>, - adjustment: &Adjustment<'tcx>) - -> Expr<'tcx> { +fn apply_adjustment<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + hir_expr: &'tcx hir::Expr, + mut expr: Expr<'tcx>, + adjustment: &Adjustment<'tcx> +) -> Expr<'tcx> { let Expr { temp_lifetime, mut span, .. } = expr; // Adjust the span from the block, to the last expression of the @@ -196,9 +197,10 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } -fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - expr: &'tcx hir::Expr) - -> Expr<'tcx> { +fn make_mirror_unadjusted<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + expr: &'tcx hir::Expr, +) -> Expr<'tcx> { let expr_ty = cx.tables().expr_ty(expr); let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); @@ -774,7 +776,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } fn user_substs_applied_to_res( - cx: &mut Cx<'a, 'gcx, 'tcx>, + cx: &mut Cx<'a, 'tcx>, hir_id: hir::HirId, res: Res, ) -> Option> { @@ -808,8 +810,8 @@ fn user_substs_applied_to_res( user_provided_type } -fn method_callee<'a, 'gcx, 'tcx>( - cx: &mut Cx<'a, 'gcx, 'tcx>, +fn method_callee<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, expr: &hir::Expr, span: Span, overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>, @@ -865,7 +867,7 @@ impl ToBorrowKind for hir::Mutability { } } -fn convert_arm<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> { +fn convert_arm<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> { Arm { patterns: arm.pats.iter().map(|p| cx.pattern_from_hir(p)).collect(), guard: match arm.guard { @@ -882,10 +884,11 @@ fn convert_arm<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, arm: &'tcx hir::Arm) } } -fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - expr: &'tcx hir::Expr, - res: Res) - -> ExprKind<'tcx> { +fn convert_path_expr<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + expr: &'tcx hir::Expr, + res: Res, +) -> ExprKind<'tcx> { let substs = cx.tables().node_substs(expr.hir_id); match res { // A regular function, constructor function or a constant. @@ -967,7 +970,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } fn convert_var( - cx: &mut Cx<'_, '_, 'tcx>, + cx: &mut Cx<'_, 'tcx>, expr: &'tcx hir::Expr, var_hir_id: hir::HirId, ) -> ExprKind<'tcx> { @@ -1117,10 +1120,11 @@ fn bin_op(op: hir::BinOpKind) -> BinOp { } } -fn overloaded_operator<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - expr: &'tcx hir::Expr, - args: Vec>) - -> ExprKind<'tcx> { +fn overloaded_operator<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + expr: &'tcx hir::Expr, + args: Vec> +) -> ExprKind<'tcx> { let fun = method_callee(cx, expr, expr.span, None); ExprKind::Call { ty: fun.ty, @@ -1130,8 +1134,8 @@ fn overloaded_operator<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } -fn overloaded_place<'a, 'gcx, 'tcx>( - cx: &mut Cx<'a, 'gcx, 'tcx>, +fn overloaded_place<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr, place_ty: Ty<'tcx>, overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>, @@ -1178,11 +1182,12 @@ fn overloaded_place<'a, 'gcx, 'tcx>( ExprKind::Deref { arg: ref_expr.to_ref() } } -fn capture_upvar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - closure_expr: &'tcx hir::Expr, - var_hir_id: hir::HirId, - upvar_ty: Ty<'tcx>) - -> ExprRef<'tcx> { +fn capture_upvar<'tcx>( + cx: &mut Cx<'_, 'tcx>, + closure_expr: &'tcx hir::Expr, + var_hir_id: hir::HirId, + upvar_ty: Ty<'tcx> +) -> ExprRef<'tcx> { let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { hir_id: var_hir_id }, closure_expr_id: cx.tcx.hir().local_def_id_from_hir_id(closure_expr.hir_id).to_local(), @@ -1218,9 +1223,10 @@ fn capture_upvar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } /// Converts a list of named fields (i.e., for struct-like struct/enum ADTs) into FieldExprRef. -fn field_refs<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, - fields: &'tcx [hir::Field]) - -> Vec> { +fn field_refs<'a, 'tcx>( + cx: &mut Cx<'a, 'tcx>, + fields: &'tcx [hir::Field] +) -> Vec> { fields.iter() .map(|field| { FieldExprRef { diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index ff3383f6e14c0..434f538cc6de4 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -21,18 +21,18 @@ use rustc::hir; use crate::hair::constant::{lit_to_const, LitToConstError}; #[derive(Clone)] -pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct Cx<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx, 'tcx>, + infcx: &'a InferCtxt<'a, 'tcx, 'tcx>, pub root_lint_level: hir::HirId, - pub param_env: ty::ParamEnv<'gcx>, + pub param_env: ty::ParamEnv<'tcx>, /// Identity `InternalSubsts` for use with const-evaluation. - pub identity_substs: &'gcx InternalSubsts<'gcx>, + pub identity_substs: &'tcx InternalSubsts<'tcx>, - pub region_scope_tree: &'gcx region::ScopeTree, - pub tables: &'a ty::TypeckTables<'gcx>, + pub region_scope_tree: &'tcx region::ScopeTree, + pub tables: &'a ty::TypeckTables<'tcx>, /// This is `Constness::Const` if we are compiling a `static`, /// `const`, or the body of a `const fn`. @@ -51,9 +51,9 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { control_flow_destroyed: Vec<(Span, String)>, } -impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, - src_id: hir::HirId) -> Cx<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Cx<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx, 'tcx>, + src_id: hir::HirId) -> Cx<'a, 'tcx> { let tcx = infcx.tcx; let src_def_id = tcx.hir().local_def_id_from_hir_id(src_id); let tables = tcx.typeck_tables_of(src_def_id); @@ -100,7 +100,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Cx<'a, 'tcx> { /// Normalizes `ast` into the appropriate "mirror" type. pub fn mirror>(&mut self, ast: M) -> M::Output { ast.make_mirror(self) @@ -200,11 +200,11 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { ty.needs_drop(self.tcx.global_tcx(), param_env) } - pub fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + pub fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx } - pub fn tables(&self) -> &'a ty::TypeckTables<'gcx> { + pub fn tables(&self) -> &'a ty::TypeckTables<'tcx> { self.tables } @@ -217,8 +217,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { } } -impl UserAnnotatedTyHelpers<'gcx, 'tcx> for Cx<'_, 'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { +impl UserAnnotatedTyHelpers<'tcx> for Cx<'_, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx() } diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 8e19913f4df26..4694241528b71 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -344,13 +344,13 @@ impl<'tcx> ExprRef<'tcx> { pub trait Mirror<'tcx> { type Output; - fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Self::Output; + fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Self::Output; } impl<'tcx> Mirror<'tcx> for Expr<'tcx> { type Output = Expr<'tcx>; - fn make_mirror<'a, 'gcx>(self, _: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> { + fn make_mirror(self, _: &mut Cx<'_, 'tcx>) -> Expr<'tcx> { self } } @@ -358,7 +358,7 @@ impl<'tcx> Mirror<'tcx> for Expr<'tcx> { impl<'tcx> Mirror<'tcx> for ExprRef<'tcx> { type Output = Expr<'tcx>; - fn make_mirror<'a, 'gcx>(self, hir: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> { + fn make_mirror(self, hir: &mut Cx<'a, 'tcx>) -> Expr<'tcx> { match self { ExprRef::Hair(h) => h.make_mirror(hir), ExprRef::Mirror(m) => *m, @@ -369,7 +369,7 @@ impl<'tcx> Mirror<'tcx> for ExprRef<'tcx> { impl<'tcx> Mirror<'tcx> for Stmt<'tcx> { type Output = Stmt<'tcx>; - fn make_mirror<'a, 'gcx>(self, _: &mut Cx<'a, 'gcx, 'tcx>) -> Stmt<'tcx> { + fn make_mirror(self, _: &mut Cx<'_, 'tcx>) -> Stmt<'tcx> { self } } @@ -377,7 +377,7 @@ impl<'tcx> Mirror<'tcx> for Stmt<'tcx> { impl<'tcx> Mirror<'tcx> for StmtRef<'tcx> { type Output = Stmt<'tcx>; - fn make_mirror<'a, 'gcx>(self, _: &mut Cx<'a, 'gcx, 'tcx>) -> Stmt<'tcx> { + fn make_mirror(self, _: &mut Cx<'_, 'tcx>) -> Stmt<'tcx> { match self { StmtRef::Mirror(m) => *m, } @@ -387,7 +387,7 @@ impl<'tcx> Mirror<'tcx> for StmtRef<'tcx> { impl<'tcx> Mirror<'tcx> for Block<'tcx> { type Output = Block<'tcx>; - fn make_mirror<'a, 'gcx>(self, _: &mut Cx<'a, 'gcx, 'tcx>) -> Block<'tcx> { + fn make_mirror(self, _: &mut Cx<'_, 'tcx>) -> Block<'tcx> { self } } diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 4b6be426e5178..566acccc5a0e6 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -1058,7 +1058,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } -impl UserAnnotatedTyHelpers<'tcx, 'tcx> for PatternContext<'_, 'tcx> { +impl UserAnnotatedTyHelpers<'tcx> for PatternContext<'_, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx } @@ -1246,8 +1246,8 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { } } -pub fn compare_const_vals<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn compare_const_vals<'tcx>( + tcx: TyCtxt<'tcx, 'tcx>, a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, diff --git a/src/librustc_mir/hair/util.rs b/src/librustc_mir/hair/util.rs index 3b52f45519030..5eadb581ba500 100644 --- a/src/librustc_mir/hair/util.rs +++ b/src/librustc_mir/hair/util.rs @@ -1,8 +1,8 @@ use rustc::hir; use rustc::ty::{self, CanonicalUserType, TyCtxt, UserType}; -crate trait UserAnnotatedTyHelpers<'gcx: 'tcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx>; +crate trait UserAnnotatedTyHelpers<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx, 'tcx>; fn tables(&self) -> &ty::TypeckTables<'tcx>;