]> git.lizzy.rs Git - rust.git/commitdiff
Syntax for hir::Expr.
authorCamille GILLOT <gillot.camille@gmail.com>
Fri, 29 Nov 2019 12:43:03 +0000 (13:43 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Thu, 26 Dec 2019 22:36:12 +0000 (23:36 +0100)
24 files changed:
src/librustc/arena.rs
src/librustc/hir/check_attr.rs
src/librustc/hir/intravisit.rs
src/librustc/hir/lowering.rs
src/librustc/hir/lowering/expr.rs
src/librustc/hir/lowering/item.rs
src/librustc/hir/map/blocks.rs
src/librustc/hir/map/collector.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/hir/pat_util.rs
src/librustc/hir/print.rs
src/librustc/hir/upvars.rs
src/librustc/ich/impls_hir.rs
src/librustc/infer/error_reporting/need_type_info.rs
src/librustc/infer/error_reporting/nice_region_error/util.rs
src/librustc/lint/context.rs
src/librustc/lint/mod.rs
src/librustc/middle/reachable.rs
src/librustc/middle/region.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/traits/error_reporting.rs
src/librustc/ty/context.rs
src/librustc_typeck/expr_use_visitor.rs

index 3d5bd313f88384adb01c34ac126060f2dc33a549..e93cddf5799043dca80a7b71c886422c730c2c70 100644 (file)
@@ -131,7 +131,7 @@ macro_rules! arena_types {
             [] foreign_item: rustc::hir::ForeignItem<$tcx>,
             [] impl_item_ref: rustc::hir::ImplItemRef,
             [few] macro_def: rustc::hir::MacroDef<$tcx>,
-            [] param: rustc::hir::Param,
+            [] param: rustc::hir::Param<$tcx>,
             [] path: rustc::hir::Path,
             [] struct_field: rustc::hir::StructField<$tcx>,
             [] trait_item_ref: rustc::hir::TraitItemRef,
index 5918ff03d585d6370456a63eace8bcd85938492f..511244ca516f59447d51c5977eb3d779ea8c5900 100644 (file)
@@ -458,7 +458,7 @@ fn emit_repr_error(
             .emit();
     }
 
-    fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
+    fn check_stmt_attributes(&self, stmt: &hir::Stmt<'_>) {
         // When checking statements ignore expressions, they will be checked later
         if let hir::StmtKind::Local(ref l) = stmt.kind {
             for attr in l.attrs.iter() {
@@ -477,7 +477,7 @@ fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
         }
     }
 
-    fn check_expr_attributes(&self, expr: &hir::Expr) {
+    fn check_expr_attributes(&self, expr: &hir::Expr<'_>) {
         let target = match expr.kind {
             hir::ExprKind::Closure(..) => Target::Closure,
             _ => Target::Expression,
@@ -537,12 +537,12 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
         intravisit::walk_impl_item(self, impl_item)
     }
 
-    fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) {
+    fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
         self.check_stmt_attributes(stmt);
         intravisit::walk_stmt(self, stmt)
     }
 
-    fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
+    fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
         self.check_expr_attributes(expr);
         intravisit::walk_expr(self, expr)
     }
index a7a8673d49eb1d020796907592ea9ce0be2299c8..5b8612ede35e1b3885d1fd646aa0f4dc8a058115 100644 (file)
@@ -212,7 +212,7 @@ fn visit_nested_body(&mut self, id: BodyId) {
         }
     }
 
-    fn visit_param(&mut self, param: &'v Param) {
+    fn visit_param(&mut self, param: &'v Param<'v>) {
         walk_param(self, param)
     }
 
@@ -253,25 +253,25 @@ fn visit_mod(&mut self, m: &'v Mod<'v>, _s: Span, n: HirId) {
     fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>) {
         walk_foreign_item(self, i)
     }
-    fn visit_local(&mut self, l: &'v Local) {
+    fn visit_local(&mut self, l: &'v Local<'v>) {
         walk_local(self, l)
     }
-    fn visit_block(&mut self, b: &'v Block) {
+    fn visit_block(&mut self, b: &'v Block<'v>) {
         walk_block(self, b)
     }
-    fn visit_stmt(&mut self, s: &'v Stmt) {
+    fn visit_stmt(&mut self, s: &'v Stmt<'v>) {
         walk_stmt(self, s)
     }
-    fn visit_arm(&mut self, a: &'v Arm) {
+    fn visit_arm(&mut self, a: &'v Arm<'v>) {
         walk_arm(self, a)
     }
-    fn visit_pat(&mut self, p: &'v Pat) {
+    fn visit_pat(&mut self, p: &'v Pat<'v>) {
         walk_pat(self, p)
     }
     fn visit_anon_const(&mut self, c: &'v AnonConst) {
         walk_anon_const(self, c)
     }
-    fn visit_expr(&mut self, ex: &'v Expr) {
+    fn visit_expr(&mut self, ex: &'v Expr<'v>) {
         walk_expr(self, ex)
     }
     fn visit_ty(&mut self, t: &'v Ty) {
@@ -409,7 +409,7 @@ pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
     visitor.visit_expr(&body.value);
 }
 
-pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
+pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local<'v>) {
     // Intentionally visiting the expr first - the initialization expr
     // dominates the local's definition.
     walk_list!(visitor, visit_expr, &local.init);
@@ -462,7 +462,7 @@ pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef)
     visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
 }
 
-pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) {
+pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) {
     visitor.visit_id(param.hir_id);
     visitor.visit_pat(&param.pat);
     walk_list!(visitor, visit_attribute, &param.attrs);
@@ -684,7 +684,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding
     }
 }
 
-pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
+pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
     visitor.visit_id(pattern.hir_id);
     match pattern.kind {
         PatKind::TupleStruct(ref qpath, ref children, _) => {
@@ -955,13 +955,13 @@ pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v
     walk_list!(visitor, visit_attribute, struct_field.attrs);
 }
 
-pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
+pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) {
     visitor.visit_id(block.hir_id);
     walk_list!(visitor, visit_stmt, &block.stmts);
     walk_list!(visitor, visit_expr, &block.expr);
 }
 
-pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
+pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) {
     visitor.visit_id(statement.hir_id);
     match statement.kind {
         StmtKind::Local(ref local) => visitor.visit_local(local),
@@ -977,7 +977,7 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
     visitor.visit_nested_body(constant.body);
 }
 
-pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
+pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
     visitor.visit_id(expression.hir_id);
     walk_list!(visitor, visit_attribute, expression.attrs.iter());
     match expression.kind {
@@ -1087,7 +1087,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
     }
 }
 
-pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
+pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
     visitor.visit_id(arm.hir_id);
     visitor.visit_pat(&arm.pat);
     if let Some(ref g) = arm.guard {
index f6db451d57ead86c101730c3eb197fa5f39cc4f1..4bc41c444e62363890df49b9c56b93b2b356395d 100644 (file)
@@ -2022,7 +2022,7 @@ fn lower_parenthesized_parameter_data(
         })
     }
 
-    fn lower_local(&mut self, l: &Local) -> (hir::Local, SmallVec<[NodeId; 1]>) {
+    fn lower_local(&mut self, l: &Local) -> (hir::Local<'hir>, SmallVec<[NodeId; 1]>) {
         let mut ids = SmallVec::<[NodeId; 1]>::new();
         if self.sess.features_untracked().impl_trait_in_bindings {
             if let Some(ref ty) = l.ty {
@@ -2586,7 +2586,7 @@ fn lower_param_bounds(
         bounds.iter().map(|bound| self.lower_param_bound(bound, itctx.reborrow())).collect()
     }
 
-    fn lower_block(&mut self, b: &Block, targeted_by_break: bool) -> P<hir::Block> {
+    fn lower_block(&mut self, b: &Block, targeted_by_break: bool) -> P<hir::Block<'hir>> {
         let mut stmts = vec![];
         let mut expr = None;
 
@@ -2614,12 +2614,12 @@ fn lower_block(&mut self, b: &Block, targeted_by_break: bool) -> P<hir::Block> {
 
     /// Lowers a block directly to an expression, presuming that it
     /// has no attributes and is not targeted by a `break`.
-    fn lower_block_expr(&mut self, b: &Block) -> hir::Expr {
+    fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
         let block = self.lower_block(b, false);
         self.expr_block(block, AttrVec::new())
     }
 
-    fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
+    fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat<'hir>> {
         let node = match p.kind {
             PatKind::Wild => hir::PatKind::Wild,
             PatKind::Ident(ref binding_mode, ident, ref sub) => {
@@ -2700,7 +2700,7 @@ fn lower_pat_tuple(
         &mut self,
         pats: &[AstP<Pat>],
         ctx: &str,
-    ) -> (HirVec<P<hir::Pat>>, Option<usize>) {
+    ) -> (HirVec<P<hir::Pat<'hir>>>, Option<usize>) {
         let mut elems = Vec::with_capacity(pats.len());
         let mut rest = None;
 
@@ -2737,7 +2737,7 @@ fn lower_pat_tuple(
     /// When encountering `($binding_mode $ident @)? ..` (`slice`),
     /// this is interpreted as a sub-slice pattern semantically.
     /// Patterns that follow, which are not like `slice` -- or an error occurs, are in `after`.
-    fn lower_pat_slice(&mut self, pats: &[AstP<Pat>]) -> hir::PatKind {
+    fn lower_pat_slice(&mut self, pats: &[AstP<Pat>]) -> hir::PatKind<'hir> {
         let mut before = Vec::new();
         let mut after = Vec::new();
         let mut slice = None;
@@ -2796,8 +2796,8 @@ fn lower_pat_ident(
         p: &Pat,
         binding_mode: &BindingMode,
         ident: Ident,
-        lower_sub: impl FnOnce(&mut Self) -> Option<P<hir::Pat>>,
-    ) -> hir::PatKind {
+        lower_sub: impl FnOnce(&mut Self) -> Option<P<hir::Pat<'hir>>>,
+    ) -> hir::PatKind<'hir> {
         match self.resolver.get_partial_res(p.id).map(|d| d.base_res()) {
             // `None` can occur in body-less function signatures
             res @ None | res @ Some(Res::Local(_)) => {
@@ -2824,12 +2824,12 @@ fn lower_pat_ident(
         }
     }
 
-    fn pat_wild_with_node_id_of(&mut self, p: &Pat) -> P<hir::Pat> {
+    fn pat_wild_with_node_id_of(&mut self, p: &Pat) -> P<hir::Pat<'hir>> {
         self.pat_with_node_id_of(p, hir::PatKind::Wild)
     }
 
     /// Construct a `Pat` with the `HirId` of `p.id` lowered.
-    fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind) -> P<hir::Pat> {
+    fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind<'hir>) -> P<hir::Pat<'hir>> {
         P(hir::Pat { hir_id: self.lower_node_id(p.id), kind, span: p.span })
     }
 
@@ -2843,7 +2843,7 @@ fn ban_extra_rest_pat(&self, sp: Span, prev_sp: Span, ctx: &str) {
     }
 
     /// Used to ban the `..` pattern in places it shouldn't be semantically.
-    fn ban_illegal_rest_pat(&self, sp: Span) -> hir::PatKind {
+    fn ban_illegal_rest_pat(&self, sp: Span) -> hir::PatKind<'hir> {
         self.diagnostic()
             .struct_span_err(sp, "`..` patterns are not allowed here")
             .note("only allowed in tuple, tuple struct, and slice patterns")
@@ -2869,11 +2869,11 @@ fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
         })
     }
 
-    fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> {
+    fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt<'hir>; 1]> {
         let kind = match s.kind {
             StmtKind::Local(ref l) => {
                 let (l, item_ids) = self.lower_local(l);
-                let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
+                let mut ids: SmallVec<[hir::Stmt<'hir>; 1]> = item_ids
                     .into_iter()
                     .map(|item_id| {
                         let item_id = hir::ItemId { id: self.lower_node_id(item_id) };
@@ -2944,11 +2944,11 @@ fn lower_trait_bound_modifier(&mut self, f: TraitBoundModifier) -> hir::TraitBou
 
     // Helper methods for building HIR.
 
-    fn stmt(&mut self, span: Span, kind: hir::StmtKind) -> hir::Stmt {
+    fn stmt(&mut self, span: Span, kind: hir::StmtKind<'hir>) -> hir::Stmt<'hir> {
         hir::Stmt { span, kind, hir_id: self.next_id() }
     }
 
-    fn stmt_expr(&mut self, span: Span, expr: hir::Expr) -> hir::Stmt {
+    fn stmt_expr(&mut self, span: Span, expr: hir::Expr<'hir>) -> hir::Stmt<'hir> {
         self.stmt(span, hir::StmtKind::Expr(P(expr)))
     }
 
@@ -2956,24 +2956,24 @@ fn stmt_let_pat(
         &mut self,
         attrs: AttrVec,
         span: Span,
-        init: Option<P<hir::Expr>>,
-        pat: P<hir::Pat>,
+        init: Option<P<hir::Expr<'hir>>>,
+        pat: P<hir::Pat<'hir>>,
         source: hir::LocalSource,
-    ) -> hir::Stmt {
+    ) -> hir::Stmt<'hir> {
         let local = hir::Local { attrs, hir_id: self.next_id(), init, pat, source, span, ty: None };
         self.stmt(span, hir::StmtKind::Local(P(local)))
     }
 
-    fn block_expr(&mut self, expr: P<hir::Expr>) -> hir::Block {
+    fn block_expr(&mut self, expr: P<hir::Expr<'hir>>) -> hir::Block<'hir> {
         self.block_all(expr.span, hir::HirVec::new(), Some(expr))
     }
 
     fn block_all(
         &mut self,
         span: Span,
-        stmts: hir::HirVec<hir::Stmt>,
-        expr: Option<P<hir::Expr>>,
-    ) -> hir::Block {
+        stmts: hir::HirVec<hir::Stmt<'hir>>,
+        expr: Option<P<hir::Expr<'hir>>>,
+    ) -> hir::Block<'hir> {
         hir::Block {
             stmts,
             expr,
@@ -2985,24 +2985,24 @@ fn block_all(
     }
 
     /// Constructs a `true` or `false` literal pattern.
-    fn pat_bool(&mut self, span: Span, val: bool) -> P<hir::Pat> {
+    fn pat_bool(&mut self, span: Span, val: bool) -> P<hir::Pat<'hir>> {
         let expr = self.expr_bool(span, val);
         self.pat(span, hir::PatKind::Lit(P(expr)))
     }
 
-    fn pat_ok(&mut self, span: Span, pat: P<hir::Pat>) -> P<hir::Pat> {
+    fn pat_ok(&mut self, span: Span, pat: P<hir::Pat<'hir>>) -> P<hir::Pat<'hir>> {
         self.pat_std_enum(span, &[sym::result, sym::Result, sym::Ok], hir_vec![pat])
     }
 
-    fn pat_err(&mut self, span: Span, pat: P<hir::Pat>) -> P<hir::Pat> {
+    fn pat_err(&mut self, span: Span, pat: P<hir::Pat<'hir>>) -> P<hir::Pat<'hir>> {
         self.pat_std_enum(span, &[sym::result, sym::Result, sym::Err], hir_vec![pat])
     }
 
-    fn pat_some(&mut self, span: Span, pat: P<hir::Pat>) -> P<hir::Pat> {
+    fn pat_some(&mut self, span: Span, pat: P<hir::Pat<'hir>>) -> P<hir::Pat<'hir>> {
         self.pat_std_enum(span, &[sym::option, sym::Option, sym::Some], hir_vec![pat])
     }
 
-    fn pat_none(&mut self, span: Span) -> P<hir::Pat> {
+    fn pat_none(&mut self, span: Span) -> P<hir::Pat<'hir>> {
         self.pat_std_enum(span, &[sym::option, sym::Option, sym::None], hir_vec![])
     }
 
@@ -3010,8 +3010,8 @@ fn pat_std_enum(
         &mut self,
         span: Span,
         components: &[Symbol],
-        subpats: hir::HirVec<P<hir::Pat>>,
-    ) -> P<hir::Pat> {
+        subpats: hir::HirVec<P<hir::Pat<'hir>>>,
+    ) -> P<hir::Pat<'hir>> {
         let path = self.std_path(span, components, None, true);
         let qpath = hir::QPath::Resolved(None, P(path));
         let pt = if subpats.is_empty() {
@@ -3022,7 +3022,7 @@ fn pat_std_enum(
         self.pat(span, pt)
     }
 
-    fn pat_ident(&mut self, span: Span, ident: Ident) -> (P<hir::Pat>, hir::HirId) {
+    fn pat_ident(&mut self, span: Span, ident: Ident) -> (P<hir::Pat<'hir>>, hir::HirId) {
         self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::Unannotated)
     }
 
@@ -3031,7 +3031,7 @@ fn pat_ident_binding_mode(
         span: Span,
         ident: Ident,
         bm: hir::BindingAnnotation,
-    ) -> (P<hir::Pat>, hir::HirId) {
+    ) -> (P<hir::Pat<'hir>>, hir::HirId) {
         let hir_id = self.next_id();
 
         (
@@ -3044,11 +3044,11 @@ fn pat_ident_binding_mode(
         )
     }
 
-    fn pat_wild(&mut self, span: Span) -> P<hir::Pat> {
+    fn pat_wild(&mut self, span: Span) -> P<hir::Pat<'hir>> {
         self.pat(span, hir::PatKind::Wild)
     }
 
-    fn pat(&mut self, span: Span, kind: hir::PatKind) -> P<hir::Pat> {
+    fn pat(&mut self, span: Span, kind: hir::PatKind<'hir>) -> P<hir::Pat<'hir>> {
         P(hir::Pat { hir_id: self.next_id(), kind, span })
     }
 
index 8311b9168e4553b0c6ac84381c7903ac1599b469..19a732a864a640b0c33cb5ab30e703fb82e8d7e4 100644 (file)
 
 use rustc_error_codes::*;
 
-impl LoweringContext<'_, '_> {
-    fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> HirVec<hir::Expr> {
+impl<'hir> LoweringContext<'_, 'hir> {
+    fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> HirVec<hir::Expr<'hir>> {
         exprs.iter().map(|x| self.lower_expr(x)).collect()
     }
 
-    pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
+    pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr<'hir> {
         let kind = match e.kind {
             ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))),
             ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
@@ -237,7 +237,7 @@ fn lower_binop(&mut self, b: BinOp) -> hir::BinOp {
     /// ```rust
     /// match scrutinee { pats => true, _ => false }
     /// ```
-    fn lower_expr_let(&mut self, span: Span, pat: &Pat, scrutinee: &Expr) -> hir::ExprKind {
+    fn lower_expr_let(&mut self, span: Span, pat: &Pat, scrutinee: &Expr) -> hir::ExprKind<'hir> {
         // If we got here, the `let` expression is not allowed.
 
         if self.sess.opts.unstable_features.is_nightly_build() {
@@ -286,7 +286,7 @@ fn lower_expr_if(
         cond: &Expr,
         then: &Block,
         else_opt: Option<&Expr>,
-    ) -> hir::ExprKind {
+    ) -> hir::ExprKind<'hir> {
         // FIXME(#53667): handle lowering of && and parens.
 
         // `_ => else_block` where `else_block` is `{}` if there's `None`:
@@ -331,7 +331,7 @@ fn lower_expr_while_in_loop_scope(
         cond: &Expr,
         body: &Block,
         opt_label: Option<Label>,
-    ) -> hir::ExprKind {
+    ) -> hir::ExprKind<'hir> {
         // FIXME(#53667): handle lowering of && and parens.
 
         // Note that the block AND the condition are evaluated in the loop scope.
@@ -398,7 +398,7 @@ fn lower_expr_while_in_loop_scope(
     /// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_ok(<expr>) }`,
     /// `try { <stmts>; }` into `{ <stmts>; ::std::ops::Try::from_ok(()) }`
     /// and save the block id to use it as a break target for desugaring of the `?` operator.
-    fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind {
+    fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind<'hir> {
         self.with_catch_scope(body.id, |this| {
             let mut block = this.lower_block(body, true).into_inner();
 
@@ -411,7 +411,7 @@ fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind {
             // Final expression of the block (if present) or `()` with span at the end of block
             let tail_expr = block.expr.take().map_or_else(
                 || this.expr_unit(this.sess.source_map().end_point(try_span)),
-                |x: P<hir::Expr>| x.into_inner(),
+                |x: P<hir::Expr<'hir>>| x.into_inner(),
             );
 
             let ok_wrapped_span =
@@ -433,15 +433,15 @@ fn wrap_in_try_constructor(
         &mut self,
         method: Symbol,
         method_span: Span,
-        expr: hir::Expr,
+        expr: hir::Expr<'hir>,
         overall_span: Span,
-    ) -> P<hir::Expr> {
+    ) -> P<hir::Expr<'hir>> {
         let path = &[sym::ops, sym::Try, method];
         let constructor = P(self.expr_std_path(method_span, path, None, ThinVec::new()));
         P(self.expr_call(overall_span, constructor, hir_vec![expr]))
     }
 
-    fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
+    fn lower_arm(&mut self, arm: &Arm) -> hir::Arm<'hir> {
         hir::Arm {
             hir_id: self.next_id(),
             attrs: self.lower_attrs(&arm.attrs),
@@ -462,8 +462,8 @@ pub(super) fn make_async_expr(
         ret_ty: Option<AstP<Ty>>,
         span: Span,
         async_gen_kind: hir::AsyncGeneratorKind,
-        body: impl FnOnce(&mut LoweringContext<'_, '_>) -> hir::Expr,
-    ) -> hir::ExprKind {
+        body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
+    ) -> hir::ExprKind<'hir> {
         let output = match ret_ty {
             Some(ty) => FunctionRetTy::Ty(ty),
             None => FunctionRetTy::Default(span),
@@ -518,7 +518,7 @@ pub(super) fn make_async_expr(
     ///     }
     /// }
     /// ```
-    fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind {
+    fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
         match self.generator_kind {
             Some(hir::GeneratorKind::Async(_)) => {}
             Some(hir::GeneratorKind::Gen) | None => {
@@ -641,7 +641,7 @@ fn lower_expr_closure(
         decl: &FnDecl,
         body: &Expr,
         fn_decl_span: Span,
-    ) -> hir::ExprKind {
+    ) -> hir::ExprKind<'hir> {
         // Lower outside new scope to preserve `is_in_loop_condition`.
         let fn_decl = self.lower_fn_decl(decl, None, false, None);
 
@@ -699,7 +699,7 @@ fn lower_expr_async_closure(
         decl: &FnDecl,
         body: &Expr,
         fn_decl_span: Span,
-    ) -> hir::ExprKind {
+    ) -> hir::ExprKind<'hir> {
         let outer_decl =
             FnDecl { inputs: decl.inputs.clone(), output: FunctionRetTy::Default(fn_decl_span) };
         // We need to lower the declaration outside the new scope, because we
@@ -743,7 +743,7 @@ fn lower_expr_async_closure(
     }
 
     /// Desugar `<start>..=<end>` into `std::ops::RangeInclusive::new(<start>, <end>)`.
-    fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind {
+    fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
         let id = self.next_id();
         let e1 = self.lower_expr(e1);
         let e2 = self.lower_expr(e2);
@@ -762,7 +762,7 @@ fn lower_expr_range(
         e1: Option<&Expr>,
         e2: Option<&Expr>,
         lims: RangeLimits,
-    ) -> hir::ExprKind {
+    ) -> hir::ExprKind<'hir> {
         use syntax::ast::RangeLimits::*;
 
         let path = match (e1, e2, lims) {
@@ -786,7 +786,7 @@ fn lower_expr_range(
                 let ident = Ident::new(Symbol::intern(s), e.span);
                 self.field(ident, expr, e.span)
             })
-            .collect::<P<[hir::Field]>>();
+            .collect::<P<[hir::Field<'hir>]>>();
 
         let is_unit = fields.is_empty();
         let struct_path = [sym::ops, path];
@@ -893,7 +893,7 @@ fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T
         result
     }
 
-    fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
+    fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind<'hir> {
         let inner = hir::InlineAsmInner {
             inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
             outputs: asm
@@ -921,7 +921,7 @@ fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
         hir::ExprKind::InlineAsm(P(hir_asm))
     }
 
-    fn lower_field(&mut self, f: &Field) -> hir::Field {
+    fn lower_field(&mut self, f: &Field) -> hir::Field<'hir> {
         hir::Field {
             hir_id: self.next_id(),
             ident: f.ident,
@@ -931,7 +931,7 @@ fn lower_field(&mut self, f: &Field) -> hir::Field {
         }
     }
 
-    fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind {
+    fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
         match self.generator_kind {
             Some(hir::GeneratorKind::Gen) => {}
             Some(hir::GeneratorKind::Async(_)) => {
@@ -973,7 +973,7 @@ fn lower_expr_for(
         head: &Expr,
         body: &Block,
         opt_label: Option<Label>,
-    ) -> hir::Expr {
+    ) -> hir::Expr<'hir> {
         // expand <head>
         let mut head = self.lower_expr(head);
         let desugared_span = self.mark_span_with_reason(DesugaringKind::ForLoop, head.span, None);
@@ -1102,7 +1102,7 @@ fn lower_expr_for(
     ///                 return Try::from_error(From::from(err)),
     /// }
     /// ```
-    fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind {
+    fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind<'hir> {
         let unstable_span = self.mark_span_with_reason(
             DesugaringKind::QuestionMark,
             span,
@@ -1191,7 +1191,7 @@ fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind {
     // =========================================================================
 
     /// Constructs a `true` or `false` literal expression.
-    pub(super) fn expr_bool(&mut self, span: Span, val: bool) -> hir::Expr {
+    pub(super) fn expr_bool(&mut self, span: Span, val: bool) -> hir::Expr<'hir> {
         let lit = Spanned { span, node: LitKind::Bool(val) };
         self.expr(span, hir::ExprKind::Lit(lit), ThinVec::new())
     }
@@ -1205,28 +1205,28 @@ pub(super) fn expr_bool(&mut self, span: Span, val: bool) -> hir::Expr {
     pub(super) fn expr_drop_temps(
         &mut self,
         span: Span,
-        expr: P<hir::Expr>,
+        expr: P<hir::Expr<'hir>>,
         attrs: AttrVec,
-    ) -> hir::Expr {
+    ) -> hir::Expr<'hir> {
         self.expr(span, hir::ExprKind::DropTemps(expr), attrs)
     }
 
     fn expr_match(
         &mut self,
         span: Span,
-        arg: P<hir::Expr>,
-        arms: hir::HirVec<hir::Arm>,
+        arg: P<hir::Expr<'hir>>,
+        arms: hir::HirVec<hir::Arm<'hir>>,
         source: hir::MatchSource,
-    ) -> hir::Expr {
+    ) -> hir::Expr<'hir> {
         self.expr(span, hir::ExprKind::Match(arg, arms, source), ThinVec::new())
     }
 
-    fn expr_break(&mut self, span: Span, attrs: AttrVec) -> P<hir::Expr> {
+    fn expr_break(&mut self, span: Span, attrs: AttrVec) -> P<hir::Expr<'hir>> {
         let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None);
         P(self.expr(span, expr_break, attrs))
     }
 
-    fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr>) -> hir::Expr {
+    fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr<'_>>) -> hir::Expr<'_> {
         self.expr(
             span,
             hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mut, e),
@@ -1234,20 +1234,20 @@ fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr>) -> hir::Expr {
         )
     }
 
-    fn expr_unit(&mut self, sp: Span) -> hir::Expr {
+    fn expr_unit(&mut self, sp: Span) -> hir::Expr<'hir> {
         self.expr_tuple(sp, hir_vec![])
     }
 
-    fn expr_tuple(&mut self, sp: Span, exprs: hir::HirVec<hir::Expr>) -> hir::Expr {
+    fn expr_tuple(&mut self, sp: Span, exprs: hir::HirVec<hir::Expr<'hir>>) -> hir::Expr<'hir> {
         self.expr(sp, hir::ExprKind::Tup(exprs), ThinVec::new())
     }
 
     fn expr_call(
         &mut self,
         span: Span,
-        e: P<hir::Expr>,
-        args: hir::HirVec<hir::Expr>,
-    ) -> hir::Expr {
+        e: P<hir::Expr<'hir>>,
+        args: hir::HirVec<hir::Expr<'hir>>,
+    ) -> hir::Expr<'hir> {
         self.expr(span, hir::ExprKind::Call(e, args), ThinVec::new())
     }
 
@@ -1256,8 +1256,8 @@ fn expr_call_std_path(
         &mut self,
         span: Span,
         path_components: &[Symbol],
-        args: hir::HirVec<hir::Expr>,
-    ) -> hir::Expr {
+        args: hir::HirVec<hir::Expr<'hir>>,
+    ) -> hir::Expr<'hir> {
         let path = P(self.expr_std_path(span, path_components, None, ThinVec::new()));
         self.expr_call(span, path, args)
     }
@@ -1277,8 +1277,8 @@ fn expr_call_std_assoc_fn(
         span: Span,
         ty_path_components: &[Symbol],
         assoc_fn_name: &str,
-        args: hir::HirVec<hir::Expr>,
-    ) -> hir::ExprKind {
+        args: hir::HirVec<hir::Expr<'hir>>,
+    ) -> hir::ExprKind<'hir> {
         let ty_path = P(self.std_path(span, ty_path_components, None, false));
         let ty = P(self.ty_path(ty_path_id, span, hir::QPath::Resolved(None, ty_path)));
         let fn_seg = P(hir::PathSegment::from_ident(Ident::from_str(assoc_fn_name)));
@@ -1293,12 +1293,17 @@ fn expr_std_path(
         components: &[Symbol],
         params: Option<P<hir::GenericArgs>>,
         attrs: AttrVec,
-    ) -> hir::Expr {
+    ) -> hir::Expr<'hir> {
         let path = self.std_path(span, components, params, true);
         self.expr(span, hir::ExprKind::Path(hir::QPath::Resolved(None, P(path))), attrs)
     }
 
-    pub(super) fn expr_ident(&mut self, sp: Span, ident: Ident, binding: hir::HirId) -> hir::Expr {
+    pub(super) fn expr_ident(
+        &mut self,
+        sp: Span,
+        ident: Ident,
+        binding: hir::HirId,
+    ) -> hir::Expr<'hir> {
         self.expr_ident_with_attrs(sp, ident, binding, ThinVec::new())
     }
 
@@ -1308,7 +1313,7 @@ fn expr_ident_with_attrs(
         ident: Ident,
         binding: hir::HirId,
         attrs: AttrVec,
-    ) -> hir::Expr {
+    ) -> hir::Expr<'hir> {
         let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
             None,
             P(hir::Path {
@@ -1321,7 +1326,7 @@ fn expr_ident_with_attrs(
         self.expr(span, expr_path, attrs)
     }
 
-    fn expr_unsafe(&mut self, expr: P<hir::Expr>) -> hir::Expr {
+    fn expr_unsafe(&mut self, expr: P<hir::Expr<'hir>>) -> hir::Expr<'hir> {
         let hir_id = self.next_id();
         let span = expr.span;
         self.expr(
@@ -1341,24 +1346,29 @@ fn expr_unsafe(&mut self, expr: P<hir::Expr>) -> hir::Expr {
         )
     }
 
-    fn expr_block_empty(&mut self, span: Span) -> hir::Expr {
+    fn expr_block_empty(&mut self, span: Span) -> hir::Expr<'hir> {
         let blk = self.block_all(span, hir_vec![], None);
         self.expr_block(P(blk), ThinVec::new())
     }
 
-    pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: AttrVec) -> hir::Expr {
+    pub(super) fn expr_block(&mut self, b: P<hir::Block<'hir>>, attrs: AttrVec) -> hir::Expr<'hir> {
         self.expr(b.span, hir::ExprKind::Block(b, None), attrs)
     }
 
-    pub(super) fn expr(&mut self, span: Span, kind: hir::ExprKind, attrs: AttrVec) -> hir::Expr {
+    pub(super) fn expr(
+        &mut self,
+        span: Span,
+        kind: hir::ExprKind<'hir>,
+        attrs: AttrVec,
+    ) -> hir::Expr<'hir> {
         hir::Expr { hir_id: self.next_id(), kind, span, attrs }
     }
 
-    fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {
+    fn field(&mut self, ident: Ident, expr: P<hir::Expr<'hir>>, span: Span) -> hir::Field<'hir> {
         hir::Field { hir_id: self.next_id(), ident, span, expr, is_shorthand: false }
     }
 
-    fn arm(&mut self, pat: P<hir::Pat>, expr: P<hir::Expr>) -> hir::Arm {
+    fn arm(&mut self, pat: P<hir::Pat<'hir>>, expr: P<hir::Expr<'hir>>) -> hir::Arm<'hir> {
         hir::Arm {
             hir_id: self.next_id(),
             attrs: hir_vec![],
index 04ebe3e8a72baa15416de8b015a7f67493225432..8016ab5c592c53cc8bb5c87703409b6f0976ad3e 100644 (file)
@@ -840,7 +840,7 @@ fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
     }
 
     /// Construct `ExprKind::Err` for the given `span`.
-    fn expr_err(&mut self, span: Span) -> hir::Expr {
+    fn expr_err(&mut self, span: Span) -> hir::Expr<'hir> {
         self.expr(span, hir::ExprKind::Err, AttrVec::new())
     }
 
@@ -981,7 +981,11 @@ fn lower_defaultness(&self, d: Defaultness, has_value: bool) -> hir::Defaultness
         }
     }
 
-    fn record_body(&mut self, params: &'hir [hir::Param], value: hir::Expr) -> hir::BodyId {
+    fn record_body(
+        &mut self,
+        params: &'hir [hir::Param<'hir>],
+        value: hir::Expr<'hir>,
+    ) -> hir::BodyId {
         let body = hir::Body { generator_kind: self.generator_kind, params, value };
         let id = body.id();
         self.bodies.insert(id, body);
@@ -990,7 +994,7 @@ fn record_body(&mut self, params: &'hir [hir::Param], value: hir::Expr) -> hir::
 
     fn lower_body(
         &mut self,
-        f: impl FnOnce(&mut Self) -> (&'hir [hir::Param], hir::Expr),
+        f: impl FnOnce(&mut Self) -> (&'hir [hir::Param<'hir>], hir::Expr<'hir>),
     ) -> hir::BodyId {
         let prev_gen_kind = self.generator_kind.take();
         let (parameters, result) = f(self);
@@ -999,7 +1003,7 @@ fn lower_body(
         body_id
     }
 
-    fn lower_param(&mut self, param: &Param) -> hir::Param {
+    fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> {
         hir::Param {
             attrs: self.lower_attrs(&param.attrs),
             hir_id: self.lower_node_id(param.id),
@@ -1011,7 +1015,7 @@ fn lower_param(&mut self, param: &Param) -> hir::Param {
     pub(super) fn lower_fn_body(
         &mut self,
         decl: &FnDecl,
-        body: impl FnOnce(&mut LoweringContext<'_, '_>) -> hir::Expr,
+        body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
     ) -> hir::BodyId {
         self.lower_body(|this| {
             (
@@ -1030,7 +1034,7 @@ fn lower_fn_body_block(
         self.lower_fn_body(decl, |this| this.lower_block_expr_opt(span, body))
     }
 
-    fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Expr {
+    fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Expr<'hir> {
         match block {
             Some(block) => self.lower_block_expr(block),
             None => self.expr_err(span),
@@ -1062,8 +1066,8 @@ fn lower_maybe_async_body(
         };
 
         self.lower_body(|this| {
-            let mut parameters: Vec<hir::Param> = Vec::new();
-            let mut statements: Vec<hir::Stmt> = Vec::new();
+            let mut parameters: Vec<hir::Param<'hir>> = Vec::new();
+            let mut statements: Vec<hir::Stmt<'hir>> = Vec::new();
 
             // Async function parameters are lowered into the closure body so that they are
             // captured and so that the drop order matches the equivalent non-async functions.
index 880e6d6dcf4cc5f83fbaa9750a9295a99fd95a97..7701c33f9162a5352951381faaaace60e542faf2 100644 (file)
@@ -66,7 +66,7 @@ fn is_fn_like(&self) -> bool {
     }
 }
 
-impl MaybeFnLike for ast::Expr {
+impl MaybeFnLike for ast::Expr<'_> {
     fn is_fn_like(&self) -> bool {
         match self.kind {
             ast::ExprKind::Closure(..) => true,
@@ -81,7 +81,7 @@ fn is_fn_like(&self) -> bool {
 #[derive(Copy, Clone)]
 pub enum Code<'a> {
     FnLike(FnLikeNode<'a>),
-    Expr(&'a Expr),
+    Expr(&'a Expr<'a>),
 }
 
 impl<'a> Code<'a> {
index feab7cdac1e5eb2cb317d5e8c4d38ca7e8487f94..610be0a0753f05aed1831e49d6135147d61fa4f6 100644 (file)
@@ -365,7 +365,7 @@ fn visit_nested_body(&mut self, id: BodyId) {
         self.currently_in_body = prev_in_body;
     }
 
-    fn visit_param(&mut self, param: &'hir Param) {
+    fn visit_param(&mut self, param: &'hir Param<'hir>) {
         let node = Node::Param(param);
         self.insert(param.pat.span, param.hir_id, node);
         self.with_parent(param.hir_id, |this| {
@@ -434,7 +434,7 @@ fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
         });
     }
 
-    fn visit_pat(&mut self, pat: &'hir Pat) {
+    fn visit_pat(&mut self, pat: &'hir Pat<'hir>) {
         let node =
             if let PatKind::Binding(..) = pat.kind { Node::Binding(pat) } else { Node::Pat(pat) };
         self.insert(pat.span, pat.hir_id, node);
@@ -444,7 +444,7 @@ fn visit_pat(&mut self, pat: &'hir Pat) {
         });
     }
 
-    fn visit_arm(&mut self, arm: &'hir Arm) {
+    fn visit_arm(&mut self, arm: &'hir Arm<'hir>) {
         let node = Node::Arm(arm);
 
         self.insert(arm.span, arm.hir_id, node);
@@ -462,7 +462,7 @@ fn visit_anon_const(&mut self, constant: &'hir AnonConst) {
         });
     }
 
-    fn visit_expr(&mut self, expr: &'hir Expr) {
+    fn visit_expr(&mut self, expr: &'hir Expr<'hir>) {
         self.insert(expr.span, expr.hir_id, Node::Expr(expr));
 
         self.with_parent(expr.hir_id, |this| {
@@ -470,7 +470,7 @@ fn visit_expr(&mut self, expr: &'hir Expr) {
         });
     }
 
-    fn visit_stmt(&mut self, stmt: &'hir Stmt) {
+    fn visit_stmt(&mut self, stmt: &'hir Stmt<'hir>) {
         self.insert(stmt.span, stmt.hir_id, Node::Stmt(stmt));
 
         self.with_parent(stmt.hir_id, |this| {
@@ -513,14 +513,14 @@ fn visit_fn(
         intravisit::walk_fn(self, fk, fd, b, s, id);
     }
 
-    fn visit_block(&mut self, block: &'hir Block) {
+    fn visit_block(&mut self, block: &'hir Block<'hir>) {
         self.insert(block.span, block.hir_id, Node::Block(block));
         self.with_parent(block.hir_id, |this| {
             intravisit::walk_block(this, block);
         });
     }
 
-    fn visit_local(&mut self, l: &'hir Local) {
+    fn visit_local(&mut self, l: &'hir Local<'hir>) {
         self.insert(l.span, l.hir_id, Node::Local(l));
         self.with_parent(l.hir_id, |this| intravisit::walk_local(this, l))
     }
index f3be7e32ceabf88015680dc3936f5e9ef6954de1..96ea602c30181bf6c9c6985ee22ef5fed91f5baa 100644 (file)
@@ -782,7 +782,7 @@ pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
     ///
     /// Used by error reporting when there's a type error in a match arm caused by the `match`
     /// expression needing to be unit.
-    pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&Expr> {
+    pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&Expr<'hir>> {
         for (_, node) in ParentHirIterator::new(hir_id, &self) {
             match node {
                 Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) | Node::ImplItem(_) => {
@@ -925,7 +925,7 @@ pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem<'hir> {
         }
     }
 
-    pub fn expect_expr(&self, id: HirId) -> &'hir Expr {
+    pub fn expect_expr(&self, id: HirId) -> &'hir Expr<'hir> {
         match self.find(id) {
             // read recorded by find
             Some(Node::Expr(expr)) => expr,
index e955b7058e355c232b34eb19f00a3f3e758057c3..4f3dec00e3c83f7fb9d1b55a09d71d51479514d5 100644 (file)
@@ -832,12 +832,12 @@ pub struct MacroDef<'hir> {
 /// `targeted_by_break` field will be `true`) and may be `unsafe` by means of
 /// the `rules` being anything but `DefaultBlock`.
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct Block {
+pub struct Block<'hir> {
     /// Statements in a block.
-    pub stmts: HirVec<Stmt>,
+    pub stmts: &'hir [Stmt<'hir>],
     /// An expression at the end of the block
     /// without a semicolon, if any.
-    pub expr: Option<P<Expr>>,
+    pub expr: Option<&'hir Expr<'hir>>,
     #[stable_hasher(ignore)]
     pub hir_id: HirId,
     /// Distinguishes between `unsafe { ... }` and `{ ... }`.
@@ -850,14 +850,14 @@ pub struct Block {
 }
 
 #[derive(RustcEncodable, RustcDecodable, HashStable)]
-pub struct Pat {
+pub struct Pat<'hir> {
     #[stable_hasher(ignore)]
     pub hir_id: HirId,
-    pub kind: PatKind,
+    pub kind: PatKind<'hir>,
     pub span: Span,
 }
 
-impl fmt::Debug for Pat {
+impl fmt::Debug for Pat<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
@@ -868,9 +868,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
-impl Pat {
+impl Pat<'_> {
     // FIXME(#19596) this is a workaround, but there should be a better way
-    fn walk_short_(&self, it: &mut impl FnMut(&Pat) -> bool) -> bool {
+    fn walk_short_(&self, it: &mut impl FnMut(&Pat<'_>) -> bool) -> bool {
         if !it(self) {
             return false;
         }
@@ -893,12 +893,12 @@ fn walk_short_(&self, it: &mut impl FnMut(&Pat) -> bool) -> bool {
     /// Note that when visiting e.g. `Tuple(ps)`,
     /// if visiting `ps[0]` returns `false`,
     /// then `ps[1]` will not be visited.
-    pub fn walk_short(&self, mut it: impl FnMut(&Pat) -> bool) -> bool {
+    pub fn walk_short(&self, mut it: impl FnMut(&Pat<'_>) -> bool) -> bool {
         self.walk_short_(&mut it)
     }
 
     // FIXME(#19596) this is a workaround, but there should be a better way
-    fn walk_(&self, it: &mut impl FnMut(&Pat) -> bool) {
+    fn walk_(&self, it: &mut impl FnMut(&Pat<'_>) -> bool) {
         if !it(self) {
             return;
         }
@@ -918,14 +918,14 @@ fn walk_(&self, it: &mut impl FnMut(&Pat) -> bool) {
     /// Walk the pattern in left-to-right order.
     ///
     /// If `it(pat)` returns `false`, the children are not visited.
-    pub fn walk(&self, mut it: impl FnMut(&Pat) -> bool) {
+    pub fn walk(&self, mut it: impl FnMut(&Pat<'_>) -> bool) {
         self.walk_(&mut it)
     }
 
     /// Walk the pattern in left-to-right order.
     ///
     /// If you always want to recurse, prefer this method over `walk`.
-    pub fn walk_always(&self, mut it: impl FnMut(&Pat)) {
+    pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
         self.walk(|p| {
             it(p);
             true
@@ -939,14 +939,14 @@ pub fn walk_always(&self, mut it: impl FnMut(&Pat)) {
 /// are treated the same as` x: x, y: ref y, z: ref mut z`,
 /// except `is_shorthand` is true.
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct FieldPat {
+pub struct FieldPat<'hir> {
     #[stable_hasher(ignore)]
     pub hir_id: HirId,
     /// The identifier for the field.
     #[stable_hasher(project(name))]
     pub ident: Ident,
     /// The pattern the field is destructured to.
-    pub pat: P<Pat>,
+    pub pat: &'hir Pat<'hir>,
     pub is_shorthand: bool,
     pub span: Span,
 }
@@ -991,7 +991,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub enum PatKind {
+pub enum PatKind<'hir> {
     /// Represents a wildcard pattern (i.e., `_`).
     Wild,
 
@@ -999,20 +999,20 @@ pub enum PatKind {
     /// The `HirId` is the canonical ID for the variable being bound,
     /// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID),
     /// which is the pattern ID of the first `x`.
-    Binding(BindingAnnotation, HirId, Ident, Option<P<Pat>>),
+    Binding(BindingAnnotation, HirId, Ident, Option<&'hir Pat<'hir>>),
 
     /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
     /// The `bool` is `true` in the presence of a `..`.
-    Struct(QPath, HirVec<FieldPat>, bool),
+    Struct(QPath, &'hir [FieldPat<'hir>], bool),
 
     /// A tuple struct/variant pattern `Variant(x, y, .., z)`.
     /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
     /// `0 <= position <= subpats.len()`
-    TupleStruct(QPath, HirVec<P<Pat>>, Option<usize>),
+    TupleStruct(QPath, &'hir [&'hir Pat<'hir>], Option<usize>),
 
     /// An or-pattern `A | B | C`.
     /// Invariant: `pats.len() >= 2`.
-    Or(HirVec<P<Pat>>),
+    Or(&'hir [&'hir Pat<'hir>]),
 
     /// A path pattern for an unit struct/variant or a (maybe-associated) constant.
     Path(QPath),
@@ -1020,19 +1020,19 @@ pub enum PatKind {
     /// A tuple pattern (e.g., `(a, b)`).
     /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
     /// `0 <= position <= subpats.len()`
-    Tuple(HirVec<P<Pat>>, Option<usize>),
+    Tuple(&'hir [&'hir Pat<'hir>], Option<usize>),
 
     /// A `box` pattern.
-    Box(P<Pat>),
+    Box(&'hir Pat<'hir>),
 
     /// A reference pattern (e.g., `&mut (a, b)`).
-    Ref(P<Pat>, Mutability),
+    Ref(&'hir Pat<'hir>, Mutability),
 
     /// A literal.
-    Lit(P<Expr>),
+    Lit(&'hir Expr<'hir>),
 
     /// A range pattern (e.g., `1..=2` or `1..2`).
-    Range(P<Expr>, P<Expr>, RangeEnd),
+    Range(&'hir Expr<'hir>, &'hir Expr<'hir>, RangeEnd),
 
     /// A slice pattern, `[before_0, ..., before_n, (slice, after_0, ..., after_n)?]`.
     ///
@@ -1043,7 +1043,7 @@ pub enum PatKind {
     /// ```
     /// PatKind::Slice([Binding(a), Binding(b)], Some(Wild), [Binding(c), Binding(d)])
     /// ```
-    Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
+    Slice(&'hir [&'hir Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [&'hir Pat<'hir>]),
 }
 
 #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
@@ -1210,13 +1210,13 @@ pub fn is_by_value(self) -> bool {
 
 /// A statement.
 #[derive(RustcEncodable, RustcDecodable, HashStable)]
-pub struct Stmt {
+pub struct Stmt<'hir> {
     pub hir_id: HirId,
-    pub kind: StmtKind,
+    pub kind: StmtKind<'hir>,
     pub span: Span,
 }
 
-impl fmt::Debug for Stmt {
+impl fmt::Debug for Stmt<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
@@ -1229,22 +1229,22 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
 /// The contents of a statement.
 #[derive(RustcEncodable, RustcDecodable, HashStable)]
-pub enum StmtKind {
+pub enum StmtKind<'hir> {
     /// A local (`let`) binding.
-    Local(P<Local>),
+    Local(&'hir Local<'hir>),
 
     /// An item binding.
     Item(ItemId),
 
     /// An expression without a trailing semi-colon (must have unit type).
-    Expr(P<Expr>),
+    Expr(&'hir Expr<'hir>),
 
     /// An expression with a trailing semi-colon (may have any type).
-    Semi(P<Expr>),
+    Semi(&'hir Expr<'hir>),
 }
 
-impl StmtKind {
-    pub fn attrs(&self) -> &[Attribute] {
+impl StmtKind<'hir> {
+    pub fn attrs(&self) -> &'hir [Attribute] {
         match *self {
             StmtKind::Local(ref l) => &l.attrs,
             StmtKind::Item(_) => &[],
@@ -1255,12 +1255,12 @@ pub fn attrs(&self) -> &[Attribute] {
 
 /// Represents a `let` statement (i.e., `let <pat>:<ty> = <expr>;`).
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct Local {
-    pub pat: P<Pat>,
+pub struct Local<'hir> {
+    pub pat: &'hir Pat<'hir>,
     /// Type annotation, if any (otherwise the type will be inferred).
-    pub ty: Option<P<Ty>>,
+    pub ty: Option<&'hir Ty>,
     /// Initializer expression to set the value, if any.
-    pub init: Option<P<Expr>>,
+    pub init: Option<&'hir Expr<'hir>>,
     pub hir_id: HirId,
     pub span: Span,
     pub attrs: AttrVec,
@@ -1272,30 +1272,30 @@ pub struct Local {
 /// Represents a single arm of a `match` expression, e.g.
 /// `<pat> (if <guard>) => <body>`.
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct Arm {
+pub struct Arm<'hir> {
     #[stable_hasher(ignore)]
     pub hir_id: HirId,
     pub span: Span,
-    pub attrs: HirVec<Attribute>,
+    pub attrs: &'hir [Attribute],
     /// If this pattern and the optional guard matches, then `body` is evaluated.
-    pub pat: P<Pat>,
+    pub pat: &'hir Pat<'hir>,
     /// Optional guard clause.
-    pub guard: Option<Guard>,
+    pub guard: Option<Guard<'hir>>,
     /// The expression the arm evaluates to if this arm matches.
-    pub body: P<Expr>,
+    pub body: &'hir Expr<'hir>,
 }
 
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub enum Guard {
-    If(P<Expr>),
+pub enum Guard<'hir> {
+    If(&'hir Expr<'hir>),
 }
 
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct Field {
+pub struct Field<'hir> {
     #[stable_hasher(ignore)]
     pub hir_id: HirId,
     pub ident: Ident,
-    pub expr: P<Expr>,
+    pub expr: &'hir Expr<'hir>,
     pub span: Span,
     pub is_shorthand: bool,
 }
@@ -1342,8 +1342,8 @@ pub struct BodyId {
 /// map using `body_owner_def_id()`.
 #[derive(RustcEncodable, RustcDecodable, Debug)]
 pub struct Body<'hir> {
-    pub params: &'hir [Param],
-    pub value: Expr,
+    pub params: &'hir [Param<'hir>],
+    pub value: Expr<'hir>,
     pub generator_kind: Option<GeneratorKind>,
 }
 
@@ -1443,18 +1443,18 @@ pub struct AnonConst {
 
 /// An expression.
 #[derive(RustcEncodable, RustcDecodable)]
-pub struct Expr {
+pub struct Expr<'hir> {
     pub hir_id: HirId,
-    pub kind: ExprKind,
+    pub kind: ExprKind<'hir>,
     pub attrs: AttrVec,
     pub span: Span,
 }
 
 // `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
 #[cfg(target_arch = "x86_64")]
-static_assert_size!(Expr, 64);
+static_assert_size!(Expr<'static>, 64);
 
-impl Expr {
+impl Expr<'_> {
     pub fn precedence(&self) -> ExprPrecedence {
         match self.kind {
             ExprKind::Box(_) => ExprPrecedence::Box,
@@ -1563,7 +1563,7 @@ pub fn peel_drop_temps(&self) -> &Self {
     }
 }
 
-impl fmt::Debug for Expr {
+impl fmt::Debug for Expr<'_> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
@@ -1579,7 +1579,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///
 /// FIXME(#60607): This function is a hack. If and when we have `QPath::Lang(...)`,
 /// we can use that instead as simpler, more reliable mechanism, as opposed to using `SourceMap`.
-pub fn is_range_literal(sm: &SourceMap, expr: &Expr) -> bool {
+pub fn is_range_literal(sm: &SourceMap, expr: &Expr<'_>) -> bool {
     // Returns whether the given path represents a (desugared) range,
     // either in std or core, i.e. has either a `::std::ops::Range` or
     // `::core::ops::Range` prefix.
@@ -1637,18 +1637,18 @@ fn is_lit(sm: &SourceMap, span: &Span) -> bool {
 }
 
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub enum ExprKind {
+pub enum ExprKind<'hir> {
     /// A `box x` expression.
-    Box(P<Expr>),
+    Box(&'hir Expr<'hir>),
     /// An array (e.g., `[a, b, c, d]`).
-    Array(HirVec<Expr>),
+    Array(&'hir [Expr<'hir>]),
     /// A function call.
     ///
     /// The first field resolves to the function itself (usually an `ExprKind::Path`),
     /// and the second field is the list of arguments.
     /// This also represents calling the constructor of
     /// tuple-like ADTs such as tuple structs and enum variants.
-    Call(P<Expr>, HirVec<Expr>),
+    Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
     /// A method call (e.g., `x.foo::<'static, Bar, Baz>(a, b, c, d)`).
     ///
     /// The `PathSegment`/`Span` represent the method name and its generic arguments
@@ -1663,83 +1663,82 @@ pub enum ExprKind {
     /// the `hir_id` of the `MethodCall` node itself.
     ///
     /// [`type_dependent_def_id`]: ../ty/struct.TypeckTables.html#method.type_dependent_def_id
-    MethodCall(P<PathSegment>, Span, HirVec<Expr>),
+    MethodCall(&'hir PathSegment, Span, &'hir [Expr<'hir>]),
     /// A tuple (e.g., `(a, b, c, d)`).
-    Tup(HirVec<Expr>),
+    Tup(&'hir [Expr<'hir>]),
     /// A binary operation (e.g., `a + b`, `a * b`).
-    Binary(BinOp, P<Expr>, P<Expr>),
+    Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
     /// A unary operation (e.g., `!x`, `*x`).
-    Unary(UnOp, P<Expr>),
+    Unary(UnOp, &'hir Expr<'hir>),
     /// A literal (e.g., `1`, `"foo"`).
     Lit(Lit),
     /// A cast (e.g., `foo as f64`).
-    Cast(P<Expr>, P<Ty>),
+    Cast(&'hir Expr<'hir>, &'hir Ty),
     /// A type reference (e.g., `Foo`).
-    Type(P<Expr>, P<Ty>),
+    Type(&'hir Expr<'hir>, &'hir Ty),
     /// Wraps the expression in a terminating scope.
     /// This makes it semantically equivalent to `{ let _t = expr; _t }`.
     ///
     /// This construct only exists to tweak the drop order in HIR lowering.
     /// An example of that is the desugaring of `for` loops.
-    DropTemps(P<Expr>),
+    DropTemps(&'hir Expr<'hir>),
     /// A conditionless loop (can be exited with `break`, `continue`, or `return`).
     ///
     /// I.e., `'label: loop { <block> }`.
-    Loop(P<Block>, Option<Label>, LoopSource),
+    Loop(&'hir Block<'hir>, Option<Label>, LoopSource),
     /// A `match` block, with a source that indicates whether or not it is
     /// the result of a desugaring, and if so, which kind.
-    Match(P<Expr>, HirVec<Arm>, MatchSource),
+    Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
     /// A closure (e.g., `move |a, b, c| {a + b + c}`).
     ///
     /// The `Span` is the argument block `|...|`.
     ///
     /// This may also be a generator literal or an `async block` as indicated by the
     /// `Option<Movability>`.
-    Closure(CaptureBy, P<FnDecl>, BodyId, Span, Option<Movability>),
+    Closure(CaptureBy, &'hir FnDecl, BodyId, Span, Option<Movability>),
     /// A block (e.g., `'label: { ... }`).
-    Block(P<Block>, Option<Label>),
+    Block(&'hir Block<'hir>, Option<Label>),
 
     /// An assignment (e.g., `a = foo()`).
-    /// The `Span` argument is the span of the `=` token.
-    Assign(P<Expr>, P<Expr>, Span),
+    Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
     /// An assignment with an operator.
     ///
     /// E.g., `a += 1`.
-    AssignOp(BinOp, P<Expr>, P<Expr>),
+    AssignOp(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
     /// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct or tuple field.
-    Field(P<Expr>, Ident),
+    Field(&'hir Expr<'hir>, Ident),
     /// An indexing operation (`foo[2]`).
-    Index(P<Expr>, P<Expr>),
+    Index(&'hir Expr<'hir>, &'hir Expr<'hir>),
 
     /// Path to a definition, possibly containing lifetime or type parameters.
     Path(QPath),
 
-    /// A referencing operation (i.e., `&a`, `&mut a`, `&raw const a`, or `&raw mut a`).
-    AddrOf(BorrowKind, Mutability, P<Expr>),
+    /// A referencing operation (i.e., `&a` or `&mut a`).
+    AddrOf(BorrowKind, &'hir Expr<'hir>),
     /// A `break`, with an optional label to break.
-    Break(Destination, Option<P<Expr>>),
+    Break(Destination, Option<&'hir Expr<'hir>>),
     /// A `continue`, with an optional label.
     Continue(Destination),
     /// A `return`, with an optional value to be returned.
-    Ret(Option<P<Expr>>),
+    Ret(Option<&'hir Expr<'hir>>),
 
     /// Inline assembly (from `asm!`), with its outputs and inputs.
-    InlineAsm(P<InlineAsm>),
+    InlineAsm(&'hir InlineAsm<'hir>),
 
     /// A struct or struct-like variant literal expression.
     ///
     /// E.g., `Foo {x: 1, y: 2}`, or `Foo {x: 1, .. base}`,
     /// where `base` is the `Option<Expr>`.
-    Struct(P<QPath>, HirVec<Field>, Option<P<Expr>>),
+    Struct(&'hir QPath, &'hir [Field<'hir>], Option<&'hir Expr<'hir>>),
 
     /// An array literal constructed from one repeated element.
     ///
     /// E.g., `[1; 5]`. The first expression is the element
     /// to be repeated; the second is the number of times to repeat it.
-    Repeat(P<Expr>, AnonConst),
+    Repeat(&'hir Expr<'hir>, AnonConst),
 
     /// A suspension point for generators (i.e., `yield <expr>`).
-    Yield(P<Expr>, YieldSource),
+    Yield(&'hir Expr<'hir>, YieldSource),
 
     /// A placeholder for an expression that wasn't syntactically well formed in some way.
     Err,
@@ -2159,18 +2158,18 @@ pub struct InlineAsmInner {
 }
 
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct InlineAsm {
+pub struct InlineAsm<'hir> {
     pub inner: InlineAsmInner,
-    pub outputs_exprs: HirVec<Expr>,
-    pub inputs_exprs: HirVec<Expr>,
+    pub outputs_exprs: &'hir [Expr<'hir>],
+    pub inputs_exprs: &'hir [Expr<'hir>],
 }
 
 /// Represents a parameter in a function header.
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct Param {
-    pub attrs: HirVec<Attribute>,
+pub struct Param<'hir> {
+    pub attrs: &'hir [Attribute],
     pub hir_id: HirId,
-    pub pat: P<Pat>,
+    pub pat: &'hir Pat<'hir>,
     pub span: Span,
 }
 
@@ -2828,7 +2827,7 @@ pub fn contains_extern_indicator(&self) -> bool {
 
 #[derive(Copy, Clone, Debug)]
 pub enum Node<'hir> {
-    Param(&'hir Param),
+    Param(&'hir Param<'hir>),
     Item(&'hir Item<'hir>),
     ForeignItem(&'hir ForeignItem<'hir>),
     TraitItem(&'hir TraitItem<'hir>),
@@ -2836,16 +2835,16 @@ pub enum Node<'hir> {
     Variant(&'hir Variant<'hir>),
     Field(&'hir StructField<'hir>),
     AnonConst(&'hir AnonConst),
-    Expr(&'hir Expr),
-    Stmt(&'hir Stmt),
+    Expr(&'hir Expr<'hir>),
+    Stmt(&'hir Stmt<'hir>),
     PathSegment(&'hir PathSegment),
     Ty(&'hir Ty),
     TraitRef(&'hir TraitRef),
-    Binding(&'hir Pat),
-    Pat(&'hir Pat),
-    Arm(&'hir Arm),
-    Block(&'hir Block),
-    Local(&'hir Local),
+    Binding(&'hir Pat<'hir>),
+    Pat(&'hir Pat<'hir>),
+    Arm(&'hir Arm<'hir>),
+    Block(&'hir Block<'hir>),
+    Local(&'hir Local<'hir>),
     MacroDef(&'hir MacroDef<'hir>),
 
     /// `Ctor` refers to the constructor of an enum variant or struct. Only tuple or unit variants
index 8d3b464a8ffa1e6d67d71559dfabe53eaa83f58b..75daf04dfc137d4bd900450ff71a304d0f7a3f4b 100644 (file)
@@ -57,7 +57,7 @@ fn enumerate_and_adjust(
     }
 }
 
-impl hir::Pat {
+impl hir::Pat<'_> {
     pub fn is_refutable(&self) -> bool {
         match self.kind {
             PatKind::Lit(_)
index 2f3b6f82ee5ee206e22cf3b2a3453c26fefd7668..7bff72314745073ec97c8b5aa940774ed4234bc5 100644 (file)
 
 pub enum AnnNode<'a> {
     Name(&'a ast::Name),
-    Block(&'a hir::Block),
+    Block(&'a hir::Block<'a>),
     Item(&'a hir::Item<'a>),
     SubItem(hir::HirId),
-    Expr(&'a hir::Expr),
-    Pat(&'a hir::Pat),
-    Arm(&'a hir::Arm),
+    Expr(&'a hir::Expr<'a>),
+    Pat(&'a hir::Pat<'a>),
+    Arm(&'a hir::Arm<'a>),
 }
 
 pub enum Nested {
@@ -242,7 +242,7 @@ pub fn commasep_cmnt<T, F, G>(&mut self, b: Breaks, elts: &[T], mut op: F, mut g
         self.end();
     }
 
-    pub fn commasep_exprs(&mut self, b: Breaks, exprs: &[hir::Expr]) {
+    pub fn commasep_exprs(&mut self, b: Breaks, exprs: &[hir::Expr<'_>]) {
         self.commasep_cmnt(b, exprs, |s, e| s.print_expr(&e), |e| e.span)
     }
 
@@ -902,7 +902,7 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem<'_>) {
         self.ann.post(self, AnnNode::SubItem(ii.hir_id))
     }
 
-    pub fn print_local(&mut self, init: Option<&hir::Expr>, decl: impl Fn(&mut Self)) {
+    pub fn print_local(&mut self, init: Option<&hir::Expr<'_>>, decl: impl Fn(&mut Self)) {
         self.space_if_not_bol();
         self.ibox(INDENT_UNIT);
         self.word_nbsp("let");
@@ -919,7 +919,7 @@ pub fn print_local(&mut self, init: Option<&hir::Expr>, decl: impl Fn(&mut Self)
         self.end()
     }
 
-    pub fn print_stmt(&mut self, st: &hir::Stmt) {
+    pub fn print_stmt(&mut self, st: &hir::Stmt<'_>) {
         self.maybe_print_comment(st.span.lo());
         match st.kind {
             hir::StmtKind::Local(ref loc) => {
@@ -942,21 +942,21 @@ pub fn print_stmt(&mut self, st: &hir::Stmt) {
         self.maybe_print_trailing_comment(st.span, None)
     }
 
-    pub fn print_block(&mut self, blk: &hir::Block) {
+    pub fn print_block(&mut self, blk: &hir::Block<'_>) {
         self.print_block_with_attrs(blk, &[])
     }
 
-    pub fn print_block_unclosed(&mut self, blk: &hir::Block) {
+    pub fn print_block_unclosed(&mut self, blk: &hir::Block<'_>) {
         self.print_block_maybe_unclosed(blk, &[], false)
     }
 
-    pub fn print_block_with_attrs(&mut self, blk: &hir::Block, attrs: &[ast::Attribute]) {
+    pub fn print_block_with_attrs(&mut self, blk: &hir::Block<'_>, attrs: &[ast::Attribute]) {
         self.print_block_maybe_unclosed(blk, attrs, true)
     }
 
     pub fn print_block_maybe_unclosed(
         &mut self,
-        blk: &hir::Block,
+        blk: &hir::Block<'_>,
         attrs: &[ast::Attribute],
         close_box: bool,
     ) {
@@ -988,13 +988,13 @@ pub fn print_anon_const(&mut self, constant: &hir::AnonConst) {
         self.ann.nested(self, Nested::Body(constant.body))
     }
 
-    fn print_call_post(&mut self, args: &[hir::Expr]) {
+    fn print_call_post(&mut self, args: &[hir::Expr<'_>]) {
         self.popen();
         self.commasep_exprs(Inconsistent, args);
         self.pclose()
     }
 
-    pub fn print_expr_maybe_paren(&mut self, expr: &hir::Expr, prec: i8) {
+    pub fn print_expr_maybe_paren(&mut self, expr: &hir::Expr<'_>, prec: i8) {
         let needs_par = expr.precedence().order() < prec;
         if needs_par {
             self.popen();
@@ -1007,7 +1007,7 @@ pub fn print_expr_maybe_paren(&mut self, expr: &hir::Expr, prec: i8) {
 
     /// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in
     /// `if cond { ... }`.
-    pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) {
+    pub fn print_expr_as_cond(&mut self, expr: &hir::Expr<'_>) {
         let needs_par = match expr.kind {
             // These cases need parens due to the parse error observed in #26461: `if return {}`
             // parses as the erroneous construct `if (return {})`, not `if (return) {}`.
@@ -1025,7 +1025,7 @@ pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) {
         }
     }
 
-    fn print_expr_vec(&mut self, exprs: &[hir::Expr]) {
+    fn print_expr_vec(&mut self, exprs: &[hir::Expr<'_>]) {
         self.ibox(INDENT_UNIT);
         self.s.word("[");
         self.commasep_exprs(Inconsistent, exprs);
@@ -1033,7 +1033,7 @@ fn print_expr_vec(&mut self, exprs: &[hir::Expr]) {
         self.end()
     }
 
-    fn print_expr_repeat(&mut self, element: &hir::Expr, count: &hir::AnonConst) {
+    fn print_expr_repeat(&mut self, element: &hir::Expr<'_>, count: &hir::AnonConst) {
         self.ibox(INDENT_UNIT);
         self.s.word("[");
         self.print_expr(element);
@@ -1046,8 +1046,8 @@ fn print_expr_repeat(&mut self, element: &hir::Expr, count: &hir::AnonConst) {
     fn print_expr_struct(
         &mut self,
         qpath: &hir::QPath,
-        fields: &[hir::Field],
-        wth: &Option<P<hir::Expr>>,
+        fields: &[hir::Field<'_>],
+        wth: &Option<P<hir::Expr<'_>>>,
     ) {
         self.print_qpath(qpath, true);
         self.s.word("{");
@@ -1085,7 +1085,7 @@ fn print_expr_struct(
         self.s.word("}");
     }
 
-    fn print_expr_tup(&mut self, exprs: &[hir::Expr]) {
+    fn print_expr_tup(&mut self, exprs: &[hir::Expr<'_>]) {
         self.popen();
         self.commasep_exprs(Inconsistent, exprs);
         if exprs.len() == 1 {
@@ -1094,7 +1094,7 @@ fn print_expr_tup(&mut self, exprs: &[hir::Expr]) {
         self.pclose()
     }
 
-    fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) {
+    fn print_expr_call(&mut self, func: &hir::Expr<'_>, args: &[hir::Expr<'_>]) {
         let prec = match func.kind {
             hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
             _ => parser::PREC_POSTFIX,
@@ -1104,7 +1104,7 @@ fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) {
         self.print_call_post(args)
     }
 
-    fn print_expr_method_call(&mut self, segment: &hir::PathSegment, args: &[hir::Expr]) {
+    fn print_expr_method_call(&mut self, segment: &hir::PathSegment, args: &[hir::Expr<'_>]) {
         let base_args = &args[1..];
         self.print_expr_maybe_paren(&args[0], parser::PREC_POSTFIX);
         self.s.word(".");
@@ -1118,7 +1118,7 @@ fn print_expr_method_call(&mut self, segment: &hir::PathSegment, args: &[hir::Ex
         self.print_call_post(base_args)
     }
 
-    fn print_expr_binary(&mut self, op: hir::BinOp, lhs: &hir::Expr, rhs: &hir::Expr) {
+    fn print_expr_binary(&mut self, op: hir::BinOp, lhs: &hir::Expr<'_>, rhs: &hir::Expr<'_>) {
         let assoc_op = bin_op_to_assoc_op(op.node);
         let prec = assoc_op.precedence() as i8;
         let fixity = assoc_op.fixity();
@@ -1144,7 +1144,7 @@ fn print_expr_binary(&mut self, op: hir::BinOp, lhs: &hir::Expr, rhs: &hir::Expr
         self.print_expr_maybe_paren(rhs, right_prec)
     }
 
-    fn print_expr_unary(&mut self, op: hir::UnOp, expr: &hir::Expr) {
+    fn print_expr_unary(&mut self, op: hir::UnOp, expr: &hir::Expr<'_>) {
         self.s.word(op.as_str());
         self.print_expr_maybe_paren(expr, parser::PREC_PREFIX)
     }
@@ -1153,7 +1153,7 @@ fn print_expr_addr_of(
         &mut self,
         kind: hir::BorrowKind,
         mutability: hir::Mutability,
-        expr: &hir::Expr,
+        expr: &hir::Expr<'_>,
     ) {
         self.s.word("&");
         match kind {
@@ -1171,7 +1171,7 @@ fn print_literal(&mut self, lit: &hir::Lit) {
         self.word(lit.node.to_lit_token().to_string())
     }
 
-    pub fn print_expr(&mut self, expr: &hir::Expr) {
+    pub fn print_expr(&mut self, expr: &hir::Expr<'_>) {
         self.maybe_print_comment(expr.span.lo());
         self.print_outer_attributes(&expr.attrs);
         self.ibox(INDENT_UNIT);
@@ -1418,7 +1418,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr) {
         self.end()
     }
 
-    pub fn print_local_decl(&mut self, loc: &hir::Local) {
+    pub fn print_local_decl(&mut self, loc: &hir::Local<'_>) {
         self.print_pat(&loc.pat);
         if let Some(ref ty) = loc.ty {
             self.word_space(":");
@@ -1434,7 +1434,7 @@ pub fn print_name(&mut self, name: ast::Name) {
         self.print_ident(ast::Ident::with_dummy_span(name))
     }
 
-    pub fn print_for_decl(&mut self, loc: &hir::Local, coll: &hir::Expr) {
+    pub fn print_for_decl(&mut self, loc: &hir::Local<'_>, coll: &hir::Expr<'_>) {
         self.print_local_decl(loc);
         self.s.space();
         self.word_space("in");
@@ -1599,7 +1599,7 @@ fn print_generic_args(
         }
     }
 
-    pub fn print_pat(&mut self, pat: &hir::Pat) {
+    pub fn print_pat(&mut self, pat: &hir::Pat<'_>) {
         self.maybe_print_comment(pat.span.lo());
         self.ann.pre(self, AnnNode::Pat(pat));
         // Pat isn't normalized, but the beauty of it
@@ -1761,12 +1761,12 @@ pub fn print_pat(&mut self, pat: &hir::Pat) {
         self.ann.post(self, AnnNode::Pat(pat))
     }
 
-    pub fn print_param(&mut self, arg: &hir::Param) {
+    pub fn print_param(&mut self, arg: &hir::Param<'_>) {
         self.print_outer_attributes(&arg.attrs);
         self.print_pat(&arg.pat);
     }
 
-    pub fn print_arm(&mut self, arm: &hir::Arm) {
+    pub fn print_arm(&mut self, arm: &hir::Arm<'_>) {
         // I have no idea why this check is necessary, but here it
         // is :(
         if arm.attrs.is_empty() {
@@ -2212,7 +2212,7 @@ pub fn print_is_auto(&mut self, s: hir::IsAuto) {
 /// isn't parsed as (if true {...} else {...} | x) | 5
 //
 // Duplicated from `parse::classify`, but adapted for the HIR.
-fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
+fn expr_requires_semi_to_be_stmt(e: &hir::Expr<'_>) -> bool {
     match e.kind {
         hir::ExprKind::Match(..) | hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) => false,
         _ => true,
@@ -2222,7 +2222,7 @@ fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
 /// This statement requires a semicolon after it.
 /// note that in one case (stmt_semi), we've already
 /// seen the semicolon, and thus don't need another.
-fn stmt_ends_with_semi(stmt: &hir::StmtKind) -> bool {
+fn stmt_ends_with_semi(stmt: &hir::StmtKind<'_>) -> bool {
     match *stmt {
         hir::StmtKind::Local(_) => true,
         hir::StmtKind::Item(_) => false,
@@ -2261,7 +2261,7 @@ fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp {
 /// Expressions that syntactically contain an "exterior" struct literal, i.e., not surrounded by any
 /// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
 /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
-fn contains_exterior_struct_lit(value: &hir::Expr) -> bool {
+fn contains_exterior_struct_lit(value: &hir::Expr<'_>) -> bool {
     match value.kind {
         hir::ExprKind::Struct(..) => true,
 
index 2df7a38693af63e3477dfff47a37a93ba179b2a6..d7de226df59ec17778bb9324160b5314c0f812f0 100644 (file)
@@ -46,7 +46,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
         NestedVisitorMap::None
     }
 
-    fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
+    fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
         if let hir::PatKind::Binding(_, hir_id, ..) = pat.kind {
             self.locals.insert(hir_id);
         }
@@ -81,7 +81,7 @@ fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
         intravisit::walk_path(self, path);
     }
 
-    fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
+    fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
         if let hir::ExprKind::Closure(..) = expr.kind {
             let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
             if let Some(upvars) = self.tcx.upvars(closure_def_id) {
index 360fa99c6208f019639236a4a13b5f4475eae2b7..31d4f8513b2aa4aa9d3b579279f04f1b53baa30b 100644 (file)
@@ -117,7 +117,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
     }
 }
 
-impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
+impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr<'_> {
     fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
         hcx.while_hashing_hir_bodies(true, |hcx| {
             let hir::Expr { hir_id: _, ref span, ref kind, ref attrs } = *self;
index 9954c35433c313963e0072fde17b63b6427eb81b..cb3d16b633d2d9ad783c79ac71e1bdf5cd547943 100644 (file)
@@ -17,11 +17,11 @@ struct FindLocalByTypeVisitor<'a, 'tcx> {
     infcx: &'a InferCtxt<'a, 'tcx>,
     target_ty: Ty<'tcx>,
     hir_map: &'a hir::map::Map<'tcx>,
-    found_local_pattern: Option<&'tcx Pat>,
-    found_arg_pattern: Option<&'tcx Pat>,
+    found_local_pattern: Option<&'tcx Pat<'tcx>>,
+    found_arg_pattern: Option<&'tcx Pat<'tcx>>,
     found_ty: Option<Ty<'tcx>>,
-    found_closure: Option<&'tcx ExprKind>,
-    found_method_call: Option<&'tcx Expr>,
+    found_closure: Option<&'tcx ExprKind<'tcx>>,
+    found_method_call: Option<&'tcx Expr<'tcx>>,
 }
 
 impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> {
@@ -72,7 +72,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
         NestedVisitorMap::OnlyBodies(&self.hir_map)
     }
 
-    fn visit_local(&mut self, local: &'tcx Local) {
+    fn visit_local(&mut self, local: &'tcx Local<'tcx>) {
         if let (None, Some(ty)) = (self.found_local_pattern, self.node_matches_type(local.hir_id)) {
             self.found_local_pattern = Some(&*local.pat);
             self.found_ty = Some(ty);
@@ -91,7 +91,7 @@ fn visit_body(&mut self, body: &'tcx Body<'tcx>) {
         intravisit::walk_body(self, body);
     }
 
-    fn visit_expr(&mut self, expr: &'tcx Expr) {
+    fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
         if self.node_matches_type(expr.hir_id).is_some() {
             match expr.kind {
                 ExprKind::Closure(..) => self.found_closure = Some(&expr.kind),
@@ -461,7 +461,7 @@ pub fn need_type_info_err(
     fn annotate_method_call(
         &self,
         segment: &hir::ptr::P<hir::PathSegment>,
-        e: &Expr,
+        e: &Expr<'_>,
         err: &mut DiagnosticBuilder<'_>,
     ) {
         if let (Ok(snippet), Some(tables), None) = (
index 36e91fa3e37a9d989b749ce3736df95ca519e6a0..638c8f5200719e9454250597eb4fd888f471ba0a 100644 (file)
@@ -12,7 +12,7 @@
 #[derive(Debug)]
 pub(super) struct AnonymousParamInfo<'tcx> {
     // the parameter corresponding to the anonymous region
-    pub param: &'tcx hir::Param,
+    pub param: &'tcx hir::Param<'tcx>,
     // the type corresponding to the anonymopus region parameter
     pub param_ty: Ty<'tcx>,
     // the ty::BoundRegion corresponding to the anonymous region
index 113084e7b7e0eafbe3efb95d5b99f8daadd82303..4e1e62512acd26dafffc8e2b36d4b95f64d84578 100644 (file)
@@ -894,7 +894,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
         self.context.tables = old_tables;
     }
 
-    fn visit_param(&mut self, param: &'tcx hir::Param) {
+    fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
         self.with_lint_attrs(param.hir_id, &param.attrs, |cx| {
             lint_callback!(cx, check_param, param);
             hir_visit::walk_param(cx, param);
@@ -930,12 +930,12 @@ fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) {
         })
     }
 
-    fn visit_pat(&mut self, p: &'tcx hir::Pat) {
+    fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
         lint_callback!(self, check_pat, p);
         hir_visit::walk_pat(self, p);
     }
 
-    fn visit_expr(&mut self, e: &'tcx hir::Expr) {
+    fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
         self.with_lint_attrs(e.hir_id, &e.attrs, |cx| {
             lint_callback!(cx, check_expr, e);
             hir_visit::walk_expr(cx, e);
@@ -943,7 +943,7 @@ fn visit_expr(&mut self, e: &'tcx hir::Expr) {
         })
     }
 
-    fn visit_stmt(&mut self, s: &'tcx hir::Stmt) {
+    fn visit_stmt(&mut self, s: &'tcx hir::Stmt<'tcx>) {
         // statement attributes are actually just attributes on one of
         // - item
         // - local
@@ -1020,20 +1020,20 @@ fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
         }
     }
 
-    fn visit_local(&mut self, l: &'tcx hir::Local) {
+    fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
         self.with_lint_attrs(l.hir_id, &l.attrs, |cx| {
             lint_callback!(cx, check_local, l);
             hir_visit::walk_local(cx, l);
         })
     }
 
-    fn visit_block(&mut self, b: &'tcx hir::Block) {
+    fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) {
         lint_callback!(self, check_block, b);
         hir_visit::walk_block(self, b);
         lint_callback!(self, check_block_post, b);
     }
 
-    fn visit_arm(&mut self, a: &'tcx hir::Arm) {
+    fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) {
         lint_callback!(self, check_arm, a);
         hir_visit::walk_arm(self, a);
     }
index 6900ed4f47565f6b5edc2a22a605a7fb4bca9f56..97b38db4165979ab226e02fdf880606f5c1fb426 100644 (file)
@@ -87,7 +87,7 @@ macro_rules! declare_lint_pass {
 macro_rules! late_lint_methods {
     ($macro:path, $args:tt, [$hir:tt]) => (
         $macro!($args, [$hir], [
-            fn check_param(a: &$hir hir::Param);
+            fn check_param(a: &$hir hir::Param<$hir>);
             fn check_body(a: &$hir hir::Body<$hir>);
             fn check_body_post(a: &$hir hir::Body<$hir>);
             fn check_name(a: Span, b: ast::Name);
@@ -99,14 +99,14 @@ macro_rules! late_lint_methods {
             fn check_foreign_item_post(a: &$hir hir::ForeignItem<$hir>);
             fn check_item(a: &$hir hir::Item<$hir>);
             fn check_item_post(a: &$hir hir::Item<$hir>);
-            fn check_local(a: &$hir hir::Local);
-            fn check_block(a: &$hir hir::Block);
-            fn check_block_post(a: &$hir hir::Block);
-            fn check_stmt(a: &$hir hir::Stmt);
-            fn check_arm(a: &$hir hir::Arm);
-            fn check_pat(a: &$hir hir::Pat);
-            fn check_expr(a: &$hir hir::Expr);
-            fn check_expr_post(a: &$hir hir::Expr);
+            fn check_local(a: &$hir hir::Local<$hir>);
+            fn check_block(a: &$hir hir::Block<$hir>);
+            fn check_block_post(a: &$hir hir::Block<$hir>);
+            fn check_stmt(a: &$hir hir::Stmt<$hir>);
+            fn check_arm(a: &$hir hir::Arm<$hir>);
+            fn check_pat(a: &$hir hir::Pat<$hir>);
+            fn check_expr(a: &$hir hir::Expr<$hir>);
+            fn check_expr_post(a: &$hir hir::Expr<$hir>);
             fn check_ty(a: &$hir hir::Ty);
             fn check_generic_param(a: &$hir hir::GenericParam);
             fn check_generics(a: &$hir hir::Generics);
@@ -610,7 +610,7 @@ fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'thi
         intravisit::NestedVisitorMap::All(&self.tcx.hir())
     }
 
-    fn visit_param(&mut self, param: &'tcx hir::Param) {
+    fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
         self.with_lint_attrs(param.hir_id, &param.attrs, |builder| {
             intravisit::walk_param(builder, param);
         });
@@ -628,7 +628,7 @@ fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) {
         })
     }
 
-    fn visit_expr(&mut self, e: &'tcx hir::Expr) {
+    fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
         self.with_lint_attrs(e.hir_id, &e.attrs, |builder| {
             intravisit::walk_expr(builder, e);
         })
@@ -651,13 +651,13 @@ fn visit_variant(
         })
     }
 
-    fn visit_local(&mut self, l: &'tcx hir::Local) {
+    fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
         self.with_lint_attrs(l.hir_id, &l.attrs, |builder| {
             intravisit::walk_local(builder, l);
         })
     }
 
-    fn visit_arm(&mut self, a: &'tcx hir::Arm) {
+    fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) {
         self.with_lint_attrs(a.hir_id, &a.attrs, |builder| {
             intravisit::walk_arm(builder, a);
         })
index 22af74c1361b2aeb464a52bc53c8124daeef1154..c6598f2d328bf47f5b9819bf17afa4d3af8008d3 100644 (file)
@@ -96,7 +96,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
         self.tables = old_tables;
     }
 
-    fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
+    fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
         let res = match expr.kind {
             hir::ExprKind::Path(ref qpath) => Some(self.tables.qpath_res(qpath, expr.hir_id)),
             hir::ExprKind::MethodCall(..) => self
index 3e97beb7bce23c4217e9cb57e3f387e12df0878e..5479a7046b6c895101b3ad0263486d8580b2eacf 100644 (file)
@@ -432,7 +432,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
         NestedVisitorMap::None
     }
 
-    fn visit_pat(&mut self, pat: &'tcx Pat) {
+    fn visit_pat(&mut self, pat: &'tcx Pat<'tcx>) {
         intravisit::walk_pat(self, pat);
 
         self.expr_and_pat_count += 1;
@@ -442,7 +442,7 @@ fn visit_pat(&mut self, pat: &'tcx Pat) {
         }
     }
 
-    fn visit_expr(&mut self, expr: &'tcx Expr) {
+    fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
         debug!("ExprLocatorVisitor - pre-increment {} expr = {:?}", self.expr_and_pat_count, expr);
 
         intravisit::walk_expr(self, expr);
@@ -773,7 +773,7 @@ fn record_var_lifetime(
     }
 }
 
-fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx hir::Block) {
+fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx hir::Block<'tcx>) {
     debug!("resolve_block(blk.hir_id={:?})", blk.hir_id);
 
     let prev_cx = visitor.cx;
@@ -837,7 +837,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
     visitor.cx = prev_cx;
 }
 
-fn resolve_arm<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, arm: &'tcx hir::Arm) {
+fn resolve_arm<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, arm: &'tcx hir::Arm<'tcx>) {
     let prev_cx = visitor.cx;
 
     visitor.enter_scope(Scope { id: arm.hir_id.local_id, data: ScopeData::Node });
@@ -854,7 +854,7 @@ fn resolve_arm<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, arm: &'tcx hir
     visitor.cx = prev_cx;
 }
 
-fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir::Pat) {
+fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir::Pat<'tcx>) {
     visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node });
 
     // If this is a binding then record the lifetime of that binding.
@@ -871,7 +871,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir
     debug!("resolve_pat - post-increment {} pat = {:?}", visitor.expr_and_pat_count, pat);
 }
 
-fn resolve_stmt<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, stmt: &'tcx hir::Stmt) {
+fn resolve_stmt<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, stmt: &'tcx hir::Stmt<'tcx>) {
     let stmt_id = stmt.hir_id.local_id;
     debug!("resolve_stmt(stmt.id={:?})", stmt_id);
 
@@ -890,7 +890,7 @@ fn resolve_stmt<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, stmt: &'tcx h
     visitor.cx.parent = prev_parent;
 }
 
-fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx hir::Expr) {
+fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
     debug!("resolve_expr - pre-increment {} expr = {:?}", visitor.expr_and_pat_count, expr);
 
     let prev_cx = visitor.cx;
@@ -1107,8 +1107,8 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
 
 fn resolve_local<'tcx>(
     visitor: &mut RegionResolutionVisitor<'tcx>,
-    pat: Option<&'tcx hir::Pat>,
-    init: Option<&'tcx hir::Expr>,
+    pat: Option<&'tcx hir::Pat<'tcx>>,
+    init: Option<&'tcx hir::Expr<'tcx>>,
 ) {
     debug!("resolve_local(pat={:?}, init={:?})", pat, init);
 
@@ -1197,7 +1197,7 @@ fn resolve_local<'tcx>(
     ///        | ( ..., P&, ... )
     ///        | ... "|" P& "|" ...
     ///        | box P&
-    fn is_binding_pat(pat: &hir::Pat) -> bool {
+    fn is_binding_pat(pat: &hir::Pat<'_>) -> bool {
         // Note that the code below looks for *explicit* refs only, that is, it won't
         // know about *implicit* refs as introduced in #42640.
         //
@@ -1263,7 +1263,7 @@ fn is_binding_pat(pat: &hir::Pat) -> bool {
     ///        | ( E& )
     fn record_rvalue_scope_if_borrow_expr<'tcx>(
         visitor: &mut RegionResolutionVisitor<'tcx>,
-        expr: &hir::Expr,
+        expr: &hir::Expr<'_>,
         blk_id: Option<Scope>,
     ) {
         match expr.kind {
@@ -1310,7 +1310,7 @@ fn record_rvalue_scope_if_borrow_expr<'tcx>(
     /// Note: ET is intended to match "rvalues or places based on rvalues".
     fn record_rvalue_scope<'tcx>(
         visitor: &mut RegionResolutionVisitor<'tcx>,
-        expr: &hir::Expr,
+        expr: &hir::Expr<'_>,
         blk_scope: Option<Scope>,
     ) {
         let mut expr = expr;
@@ -1372,7 +1372,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
         NestedVisitorMap::None
     }
 
-    fn visit_block(&mut self, b: &'tcx Block) {
+    fn visit_block(&mut self, b: &'tcx Block<'tcx>) {
         resolve_block(self, b);
     }
 
@@ -1444,19 +1444,19 @@ fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
         self.terminating_scopes = outer_ts;
     }
 
-    fn visit_arm(&mut self, a: &'tcx Arm) {
+    fn visit_arm(&mut self, a: &'tcx Arm<'tcx>) {
         resolve_arm(self, a);
     }
-    fn visit_pat(&mut self, p: &'tcx Pat) {
+    fn visit_pat(&mut self, p: &'tcx Pat<'tcx>) {
         resolve_pat(self, p);
     }
-    fn visit_stmt(&mut self, s: &'tcx Stmt) {
+    fn visit_stmt(&mut self, s: &'tcx Stmt<'tcx>) {
         resolve_stmt(self, s);
     }
-    fn visit_expr(&mut self, ex: &'tcx Expr) {
+    fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
         resolve_expr(self, ex);
     }
-    fn visit_local(&mut self, l: &'tcx Local) {
+    fn visit_local(&mut self, l: &'tcx Local<'tcx>) {
         resolve_local(self, Some(&l.pat), l.init.as_ref().map(|e| &**e));
     }
 }
index 67630a75768d0ff13a5ccb8d69fd8f5a169c6a1a..7950ff421b4a58d784a2b5129dad55870e71024f 100644 (file)
@@ -1133,7 +1133,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
             NestedVisitorMap::None
         }
 
-        fn visit_expr(&mut self, ex: &hir::Expr) {
+        fn visit_expr(&mut self, ex: &hir::Expr<'_>) {
             if let Some(label) = expression_label(ex) {
                 for prior_label in &self.labels_in_fn[..] {
                     // FIXME (#24278): non-hygienic comparison
@@ -1155,7 +1155,7 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
         }
     }
 
-    fn expression_label(ex: &hir::Expr) -> Option<ast::Ident> {
+    fn expression_label(ex: &hir::Expr<'_>) -> Option<ast::Ident> {
         if let hir::ExprKind::Loop(_, Some(label), _) = ex.kind { Some(label.ident) } else { None }
     }
 
index 42db64c79151897087d0d18c91b0ed91ac061e61..f7d9cb34fa9252091b60d0a9c16e912915f3b7cc 100644 (file)
@@ -1331,19 +1331,20 @@ fn get_closure_name(
         err: &mut DiagnosticBuilder<'_>,
         msg: &str,
     ) -> Option<String> {
-        let get_name = |err: &mut DiagnosticBuilder<'_>, kind: &hir::PatKind| -> Option<String> {
-            // Get the local name of this closure. This can be inaccurate because
-            // of the possibility of reassignment, but this should be good enough.
-            match &kind {
-                hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
-                    Some(format!("{}", name))
-                }
-                _ => {
-                    err.note(&msg);
-                    None
+        let get_name =
+            |err: &mut DiagnosticBuilder<'_>, kind: &hir::PatKind<'_>| -> Option<String> {
+                // Get the local name of this closure. This can be inaccurate because
+                // of the possibility of reassignment, but this should be good enough.
+                match &kind {
+                    hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
+                        Some(format!("{}", name))
+                    }
+                    _ => {
+                        err.note(&msg);
+                        None
+                    }
                 }
-            }
-        };
+            };
 
         let hir = self.tcx.hir();
         let hir_id = hir.as_local_hir_id(def_id)?;
index e99e00a366d378ffb719888bb157db7acbb741d5..2659caf030b0c6dc64bd31f9cdba27bd075bec60 100644 (file)
@@ -553,11 +553,11 @@ pub fn node_substs_opt(&self, id: hir::HirId) -> Option<SubstsRef<'tcx>> {
 
     // Returns the type of a pattern as a monotype. Like @expr_ty, this function
     // doesn't provide type parameter substitutions.
-    pub fn pat_ty(&self, pat: &hir::Pat) -> Ty<'tcx> {
+    pub fn pat_ty(&self, pat: &hir::Pat<'_>) -> Ty<'tcx> {
         self.node_type(pat.hir_id)
     }
 
-    pub fn pat_ty_opt(&self, pat: &hir::Pat) -> Option<Ty<'tcx>> {
+    pub fn pat_ty_opt(&self, pat: &hir::Pat<'_>) -> Option<Ty<'tcx>> {
         self.node_type_opt(pat.hir_id)
     }
 
@@ -571,11 +571,11 @@ pub fn pat_ty_opt(&self, pat: &hir::Pat) -> Option<Ty<'tcx>> {
     // NB (2): This type doesn't provide type parameter substitutions; e.g., if you
     // ask for the type of "id" in "id(3)", it will return "fn(&isize) -> isize"
     // instead of "fn(ty) -> T with T = isize".
-    pub fn expr_ty(&self, expr: &hir::Expr) -> Ty<'tcx> {
+    pub fn expr_ty(&self, expr: &hir::Expr<'_>) -> Ty<'tcx> {
         self.node_type(expr.hir_id)
     }
 
-    pub fn expr_ty_opt(&self, expr: &hir::Expr) -> Option<Ty<'tcx>> {
+    pub fn expr_ty_opt(&self, expr: &hir::Expr<'_>) -> Option<Ty<'tcx>> {
         self.node_type_opt(expr.hir_id)
     }
 
@@ -589,22 +589,22 @@ pub fn adjustments_mut(
         LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.adjustments }
     }
 
-    pub fn expr_adjustments(&self, expr: &hir::Expr) -> &[ty::adjustment::Adjustment<'tcx>] {
+    pub fn expr_adjustments(&self, expr: &hir::Expr<'_>) -> &[ty::adjustment::Adjustment<'tcx>] {
         validate_hir_id_for_typeck_tables(self.local_id_root, expr.hir_id, false);
         self.adjustments.get(&expr.hir_id.local_id).map_or(&[], |a| &a[..])
     }
 
     /// Returns the type of `expr`, considering any `Adjustment`
     /// entry recorded for that expression.
-    pub fn expr_ty_adjusted(&self, expr: &hir::Expr) -> Ty<'tcx> {
+    pub fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> Ty<'tcx> {
         self.expr_adjustments(expr).last().map_or_else(|| self.expr_ty(expr), |adj| adj.target)
     }
 
-    pub fn expr_ty_adjusted_opt(&self, expr: &hir::Expr) -> Option<Ty<'tcx>> {
+    pub fn expr_ty_adjusted_opt(&self, expr: &hir::Expr<'_>) -> Option<Ty<'tcx>> {
         self.expr_adjustments(expr).last().map(|adj| adj.target).or_else(|| self.expr_ty_opt(expr))
     }
 
-    pub fn is_method_call(&self, expr: &hir::Expr) -> bool {
+    pub fn is_method_call(&self, expr: &hir::Expr<'_>) -> bool {
         // Only paths and method calls/overloaded operators have
         // entries in type_dependent_defs, ignore the former here.
         if let hir::ExprKind::Path(_) = expr.kind {
index f3f5e54edd1954bb8dae0f8b6530ec909c1bb7f9..7110ab40328450ef78b036612fbc3819c38aea8b 100644 (file)
@@ -150,13 +150,13 @@ fn delegate_consume(&mut self, place: &Place<'tcx>) {
         self.delegate.consume(place, mode);
     }
 
-    fn consume_exprs(&mut self, exprs: &[hir::Expr]) {
+    fn consume_exprs(&mut self, exprs: &[hir::Expr<'_>]) {
         for expr in exprs {
             self.consume_expr(&expr);
         }
     }
 
-    pub fn consume_expr(&mut self, expr: &hir::Expr) {
+    pub fn consume_expr(&mut self, expr: &hir::Expr<'_>) {
         debug!("consume_expr(expr={:?})", expr);
 
         let place = return_if_err!(self.mc.cat_expr(expr));
@@ -164,13 +164,13 @@ pub fn consume_expr(&mut self, expr: &hir::Expr) {
         self.walk_expr(expr);
     }
 
-    fn mutate_expr(&mut self, expr: &hir::Expr) {
+    fn mutate_expr(&mut self, expr: &hir::Expr<'_>) {
         let place = return_if_err!(self.mc.cat_expr(expr));
         self.delegate.mutate(&place);
         self.walk_expr(expr);
     }
 
-    fn borrow_expr(&mut self, expr: &hir::Expr, bk: ty::BorrowKind) {
+    fn borrow_expr(&mut self, expr: &hir::Expr<'_>, bk: ty::BorrowKind) {
         debug!("borrow_expr(expr={:?}, bk={:?})", expr, bk);
 
         let place = return_if_err!(self.mc.cat_expr(expr));
@@ -179,11 +179,11 @@ fn borrow_expr(&mut self, expr: &hir::Expr, bk: ty::BorrowKind) {
         self.walk_expr(expr)
     }
 
-    fn select_from_expr(&mut self, expr: &hir::Expr) {
+    fn select_from_expr(&mut self, expr: &hir::Expr<'_>) {
         self.walk_expr(expr)
     }
 
-    pub fn walk_expr(&mut self, expr: &hir::Expr) {
+    pub fn walk_expr(&mut self, expr: &hir::Expr<'_>) {
         debug!("walk_expr(expr={:?})", expr);
 
         self.walk_adjustment(expr);
@@ -326,7 +326,7 @@ pub fn walk_expr(&mut self, expr: &hir::Expr) {
         }
     }
 
-    fn walk_callee(&mut self, call: &hir::Expr, callee: &hir::Expr) {
+    fn walk_callee(&mut self, call: &hir::Expr<'_>, callee: &hir::Expr<'_>) {
         let callee_ty = return_if_err!(self.mc.expr_ty_adjusted(callee));
         debug!("walk_callee: callee={:?} callee_ty={:?}", callee, callee_ty);
         match callee_ty.kind {
@@ -354,7 +354,7 @@ fn walk_callee(&mut self, call: &hir::Expr, callee: &hir::Expr) {
         }
     }
 
-    fn walk_stmt(&mut self, stmt: &hir::Stmt) {
+    fn walk_stmt(&mut self, stmt: &hir::Stmt<'_>) {
         match stmt.kind {
             hir::StmtKind::Local(ref local) => {
                 self.walk_local(&local);
@@ -371,7 +371,7 @@ fn walk_stmt(&mut self, stmt: &hir::Stmt) {
         }
     }
 
-    fn walk_local(&mut self, local: &hir::Local) {
+    fn walk_local(&mut self, local: &hir::Local<'_>) {
         if let Some(ref expr) = local.init {
             // Variable declarations with
             // initializers are considered
@@ -385,7 +385,7 @@ fn walk_local(&mut self, local: &hir::Local) {
 
     /// Indicates that the value of `blk` will be consumed, meaning either copied or moved
     /// depending on its type.
-    fn walk_block(&mut self, blk: &hir::Block) {
+    fn walk_block(&mut self, blk: &hir::Block<'_>) {
         debug!("walk_block(blk.hir_id={})", blk.hir_id);
 
         for stmt in &blk.stmts {
@@ -397,7 +397,7 @@ fn walk_block(&mut self, blk: &hir::Block) {
         }
     }
 
-    fn walk_struct_expr(&mut self, fields: &[hir::Field], opt_with: &Option<P<hir::Expr>>) {
+    fn walk_struct_expr(&mut self, fields: &[hir::Field<'_>], opt_with: &Option<P<hir::Expr<'_>>>) {
         // Consume the expressions supplying values for each field.
         for field in fields {
             self.consume_expr(&field.expr);
@@ -450,7 +450,7 @@ fn walk_struct_expr(&mut self, fields: &[hir::Field], opt_with: &Option<P<hir::E
     // Invoke the appropriate delegate calls for anything that gets
     // consumed or borrowed as part of the automatic adjustment
     // process.
-    fn walk_adjustment(&mut self, expr: &hir::Expr) {
+    fn walk_adjustment(&mut self, expr: &hir::Expr<'_>) {
         let adjustments = self.mc.tables.expr_adjustments(expr);
         let mut place = return_if_err!(self.mc.cat_expr_unadjusted(expr));
         for adjustment in adjustments {
@@ -487,7 +487,7 @@ fn walk_adjustment(&mut self, expr: &hir::Expr) {
     /// after all relevant autoderefs have occurred.
     fn walk_autoref(
         &mut self,
-        expr: &hir::Expr,
+        expr: &hir::Expr<'_>,
         base_place: &mc::Place<'tcx>,
         autoref: &adjustment::AutoBorrow<'tcx>,
     ) {
@@ -509,7 +509,7 @@ fn walk_autoref(
         }
     }
 
-    fn walk_arm(&mut self, discr_place: &Place<'tcx>, arm: &hir::Arm) {
+    fn walk_arm(&mut self, discr_place: &Place<'tcx>, arm: &hir::Arm<'_>) {
         self.walk_pat(discr_place, &arm.pat);
 
         if let Some(hir::Guard::If(ref e)) = arm.guard {
@@ -521,12 +521,12 @@ fn walk_arm(&mut self, discr_place: &Place<'tcx>, arm: &hir::Arm) {
 
     /// Walks a pat that occurs in isolation (i.e., top-level of fn argument or
     /// let binding, and *not* a match arm or nested pat.)
-    fn walk_irrefutable_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat) {
+    fn walk_irrefutable_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat<'_>) {
         self.walk_pat(discr_place, pat);
     }
 
     /// The core driver for walking a pattern
-    fn walk_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat) {
+    fn walk_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat<'_>) {
         debug!("walk_pat(discr_place={:?}, pat={:?})", discr_place, pat);
 
         let tcx = self.tcx();
@@ -565,7 +565,7 @@ fn walk_pat(&mut self, discr_place: &Place<'tcx>, pat: &hir::Pat) {
         }));
     }
 
-    fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
+    fn walk_captures(&mut self, closure_expr: &hir::Expr<'_>, fn_decl_span: Span) {
         debug!("walk_captures({:?})", closure_expr);
 
         let closure_def_id = self.tcx().hir().local_def_id(closure_expr.hir_id);