]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/expr_use_visitor.rs
Rollup merge of #68222 - alexcrichton:update-wasi-libc, r=kennytm
[rust.git] / src / librustc_typeck / expr_use_visitor.rs
index f3f5e54edd1954bb8dae0f8b6530ec909c1bb7f9..be00c57763a4efb0777ce298cedf691f05157b3a 100644 (file)
@@ -8,15 +8,15 @@
 // Export these here so that Clippy can use them.
 pub use mc::{Place, PlaceBase, Projection};
 
-use rustc::hir::def::Res;
-use rustc::hir::def_id::DefId;
-use rustc::hir::ptr::P;
-use rustc::hir::{self, PatKind};
 use rustc::infer::InferCtxt;
 use rustc::ty::{self, adjustment, TyCtxt};
+use rustc_hir as hir;
+use rustc_hir::def::Res;
+use rustc_hir::def_id::DefId;
+use rustc_hir::PatKind;
 
 use crate::mem_categorization as mc;
-use syntax_pos::Span;
+use rustc_span::Span;
 
 ///////////////////////////////////////////////////////////////////////////
 // The Delegate trait
@@ -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);
@@ -193,7 +193,7 @@ pub fn walk_expr(&mut self, expr: &hir::Expr) {
 
             hir::ExprKind::Type(ref subexpr, _) => self.walk_expr(subexpr),
 
-            hir::ExprKind::Unary(hir::UnDeref, ref base) => {
+            hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base) => {
                 // *base
                 self.select_from_expr(base);
             }
@@ -228,7 +228,7 @@ pub fn walk_expr(&mut self, expr: &hir::Expr) {
                 self.consume_exprs(exprs);
             }
 
-            hir::ExprKind::Match(ref discr, ref arms, _) => {
+            hir::ExprKind::Match(ref discr, arms, _) => {
                 let discr_place = return_if_err!(self.mc.cat_expr(&discr));
                 self.borrow_expr(&discr, ty::ImmBorrow);
 
@@ -251,7 +251,7 @@ pub fn walk_expr(&mut self, expr: &hir::Expr) {
             }
 
             hir::ExprKind::InlineAsm(ref ia) => {
-                for (o, output) in ia.inner.outputs.iter().zip(&ia.outputs_exprs) {
+                for (o, output) in ia.inner.outputs.iter().zip(ia.outputs_exprs) {
                     if o.is_indirect {
                         self.consume_expr(output);
                     } else {
@@ -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,10 +385,10 @@ 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 {
+        for stmt in blk.stmts {
             self.walk_stmt(stmt);
         }
 
@@ -397,7 +397,11 @@ 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<&'hir hir::Expr<'_>>,
+    ) {
         // Consume the expressions supplying values for each field.
         for field in fields {
             self.consume_expr(&field.expr);
@@ -450,7 +454,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 +491,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 +513,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 +525,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 +569,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);