]> git.lizzy.rs Git - rust.git/commitdiff
Visit for hir::Expr.
authorCamille GILLOT <gillot.camille@gmail.com>
Fri, 29 Nov 2019 13:08:03 +0000 (14:08 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Thu, 26 Dec 2019 22:36:12 +0000 (23:36 +0100)
src/librustc/hir/intravisit.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/infer/error_reporting/need_type_info.rs
src/librustc/middle/region.rs
src/librustc_typeck/expr_use_visitor.rs

index 5b8612ede35e1b3885d1fd646aa0f4dc8a058115..659bfc4e63c6b9dcbd23c95cb6ab9fe2a226e961 100644 (file)
@@ -465,7 +465,7 @@ pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef)
 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);
+    walk_list!(visitor, visit_attribute, param.attrs);
 }
 
 pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
@@ -687,14 +687,14 @@ 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<'v>) {
     visitor.visit_id(pattern.hir_id);
     match pattern.kind {
-        PatKind::TupleStruct(ref qpath, ref children, _) => {
+        PatKind::TupleStruct(ref qpath, children, _) => {
             visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
             walk_list!(visitor, visit_pat, children);
         }
         PatKind::Path(ref qpath) => {
             visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
         }
-        PatKind::Struct(ref qpath, ref fields, _) => {
+        PatKind::Struct(ref qpath, fields, _) => {
             visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
             for field in fields {
                 visitor.visit_id(field.hir_id);
@@ -702,8 +702,8 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
                 visitor.visit_pat(&field.pat)
             }
         }
-        PatKind::Or(ref pats) => walk_list!(visitor, visit_pat, pats),
-        PatKind::Tuple(ref tuple_elements, _) => {
+        PatKind::Or(pats) => walk_list!(visitor, visit_pat, pats),
+        PatKind::Tuple(tuple_elements, _) => {
             walk_list!(visitor, visit_pat, tuple_elements);
         }
         PatKind::Box(ref subpattern) | PatKind::Ref(ref subpattern, _) => {
@@ -719,7 +719,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
             visitor.visit_expr(upper_bound)
         }
         PatKind::Wild => (),
-        PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
+        PatKind::Slice(prepatterns, ref slice_pattern, postpatterns) => {
             walk_list!(visitor, visit_pat, prepatterns);
             walk_list!(visitor, visit_pat, slice_pattern);
             walk_list!(visitor, visit_pat, postpatterns);
@@ -957,7 +957,7 @@ pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v
 
 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_stmt, block.stmts);
     walk_list!(visitor, visit_expr, &block.expr);
 }
 
@@ -982,14 +982,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
     walk_list!(visitor, visit_attribute, expression.attrs.iter());
     match expression.kind {
         ExprKind::Box(ref subexpression) => visitor.visit_expr(subexpression),
-        ExprKind::Array(ref subexpressions) => {
+        ExprKind::Array(subexpressions) => {
             walk_list!(visitor, visit_expr, subexpressions);
         }
         ExprKind::Repeat(ref element, ref count) => {
             visitor.visit_expr(element);
             visitor.visit_anon_const(count)
         }
-        ExprKind::Struct(ref qpath, ref fields, ref optional_base) => {
+        ExprKind::Struct(ref qpath, fields, ref optional_base) => {
             visitor.visit_qpath(qpath, expression.hir_id, expression.span);
             for field in fields {
                 visitor.visit_id(field.hir_id);
@@ -998,14 +998,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
             }
             walk_list!(visitor, visit_expr, optional_base);
         }
-        ExprKind::Tup(ref subexpressions) => {
+        ExprKind::Tup(subexpressions) => {
             walk_list!(visitor, visit_expr, subexpressions);
         }
-        ExprKind::Call(ref callee_expression, ref arguments) => {
+        ExprKind::Call(ref callee_expression, arguments) => {
             visitor.visit_expr(callee_expression);
             walk_list!(visitor, visit_expr, arguments);
         }
-        ExprKind::MethodCall(ref segment, _, ref arguments) => {
+        ExprKind::MethodCall(ref segment, _, arguments) => {
             visitor.visit_path_segment(expression.span, segment);
             walk_list!(visitor, visit_expr, arguments);
         }
@@ -1027,7 +1027,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
             walk_list!(visitor, visit_label, opt_label);
             visitor.visit_block(block);
         }
-        ExprKind::Match(ref subexpression, ref arms, _) => {
+        ExprKind::Match(ref subexpression, arms, _) => {
             visitor.visit_expr(subexpression);
             walk_list!(visitor, visit_arm, arms);
         }
@@ -1077,8 +1077,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
             walk_list!(visitor, visit_expr, optional_expression);
         }
         ExprKind::InlineAsm(ref asm) => {
-            walk_list!(visitor, visit_expr, &asm.outputs_exprs);
-            walk_list!(visitor, visit_expr, &asm.inputs_exprs);
+            walk_list!(visitor, visit_expr, asm.outputs_exprs);
+            walk_list!(visitor, visit_expr, asm.inputs_exprs);
         }
         ExprKind::Yield(ref subexpression, _) => {
             visitor.visit_expr(subexpression);
@@ -1096,7 +1096,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
         }
     }
     visitor.visit_expr(&arm.body);
-    walk_list!(visitor, visit_attribute, &arm.attrs);
+    walk_list!(visitor, visit_attribute, arm.attrs);
 }
 
 pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
index 96ea602c30181bf6c9c6985ee22ef5fed91f5baa..cc5cb58173fd69c54026a73d2012b1f7426a5c9b 100644 (file)
@@ -180,19 +180,19 @@ pub struct Map<'hir> {
     hir_to_node_id: FxHashMap<HirId, NodeId>,
 }
 
-struct ParentHirIterator<'map> {
+struct ParentHirIterator<'map, 'hir> {
     current_id: HirId,
-    map: &'map Map<'map>,
+    map: &'map Map<'hir>,
 }
 
-impl<'map> ParentHirIterator<'map> {
-    fn new(current_id: HirId, map: &'map Map<'map>) -> ParentHirIterator<'map> {
+impl<'map, 'hir> ParentHirIterator<'map, 'hir> {
+    fn new(current_id: HirId, map: &'map Map<'hir>) -> ParentHirIterator<'map, 'hir> {
         ParentHirIterator { current_id, map }
     }
 }
 
-impl<'map> Iterator for ParentHirIterator<'map> {
-    type Item = (HirId, Node<'map>);
+impl<'map, 'hir> Iterator for ParentHirIterator<'map, 'hir> {
+    type Item = (HirId, Node<'hir>);
 
     fn next(&mut self) -> Option<Self::Item> {
         if self.current_id == CRATE_HIR_ID {
@@ -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<'hir>> {
+    pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>> {
         for (_, node) in ParentHirIterator::new(hir_id, &self) {
             match node {
                 Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) | Node::ImplItem(_) => {
index 4f3dec00e3c83f7fb9d1b55a09d71d51479514d5..8a450cf167a369e42ea4d133adc48b2be2945378 100644 (file)
@@ -1714,7 +1714,7 @@ pub enum ExprKind<'hir> {
     Path(QPath),
 
     /// A referencing operation (i.e., `&a` or `&mut a`).
-    AddrOf(BorrowKind, &'hir Expr<'hir>),
+    AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
     /// A `break`, with an optional label to break.
     Break(Destination, Option<&'hir Expr<'hir>>),
     /// A `continue`, with an optional label.
index 75daf04dfc137d4bd900450ff71a304d0f7a3f4b..0831f5403db5499f4025a71bccdba6f7a731ad07 100644 (file)
@@ -126,7 +126,7 @@ pub fn contains_bindings_or_wild(&self) -> bool {
     }
 
     /// Checks if the pattern satisfies the given predicate on some sub-pattern.
-    fn satisfies(&self, pred: impl Fn(&Self) -> bool) -> bool {
+    fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool {
         let mut satisfies = false;
         self.walk_short(|p| {
             if pred(p) {
index 7bff72314745073ec97c8b5aa940774ed4234bc5..11a596a8317773f03b71b78e7101a779f3d85226 100644 (file)
@@ -10,7 +10,6 @@
 use syntax_pos::{self, BytePos, FileName};
 
 use crate::hir;
-use crate::hir::ptr::P;
 use crate::hir::{GenericArg, GenericParam, GenericParamKind};
 use crate::hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
 
@@ -972,7 +971,7 @@ pub fn print_block_maybe_unclosed(
 
         self.print_inner_attributes(attrs);
 
-        for st in &blk.stmts {
+        for st in blk.stmts {
             self.print_stmt(st);
         }
         if let Some(ref expr) = blk.expr {
@@ -1047,7 +1046,7 @@ fn print_expr_struct(
         &mut self,
         qpath: &hir::QPath,
         fields: &[hir::Field<'_>],
-        wth: &Option<P<hir::Expr<'_>>>,
+        wth: &Option<&'hir hir::Expr<'_>>,
     ) {
         self.print_qpath(qpath, true);
         self.s.word("{");
@@ -1187,8 +1186,8 @@ pub fn print_expr(&mut self, expr: &hir::Expr<'_>) {
             hir::ExprKind::Repeat(ref element, ref count) => {
                 self.print_expr_repeat(&element, count);
             }
-            hir::ExprKind::Struct(ref qpath, ref fields, ref wth) => {
-                self.print_expr_struct(qpath, &fields[..], wth);
+            hir::ExprKind::Struct(ref qpath, fields, ref wth) => {
+                self.print_expr_struct(qpath, fields, wth);
             }
             hir::ExprKind::Tup(ref exprs) => {
                 self.print_expr_tup(exprs);
@@ -1251,7 +1250,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr<'_>) {
                 self.s.space();
                 self.print_block(&blk);
             }
-            hir::ExprKind::Match(ref expr, ref arms, _) => {
+            hir::ExprKind::Match(ref expr, arms, _) => {
                 self.cbox(INDENT_UNIT);
                 self.ibox(INDENT_UNIT);
                 self.word_nbsp("match");
index cb3d16b633d2d9ad783c79ac71e1bdf5cd547943..6b977393806ee8d0993b8cacb467eb6257ee6d59 100644 (file)
@@ -460,7 +460,7 @@ pub fn need_type_info_err(
     /// needed, suggest annotating the call, otherwise point out the resulting type of the call.
     fn annotate_method_call(
         &self,
-        segment: &hir::ptr::P<hir::PathSegment>,
+        segment: &hir::PathSegment,
         e: &Expr<'_>,
         err: &mut DiagnosticBuilder<'_>,
     ) {
index 5479a7046b6c895101b3ad0263486d8580b2eacf..5126d3f7fdefe68e85f649465ced9c0992b6f70b 100644 (file)
@@ -1271,12 +1271,12 @@ fn record_rvalue_scope_if_borrow_expr<'tcx>(
                 record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
                 record_rvalue_scope(visitor, &subexpr, blk_id);
             }
-            hir::ExprKind::Struct(_, ref fields, _) => {
+            hir::ExprKind::Struct(_, fields, _) => {
                 for field in fields {
                     record_rvalue_scope_if_borrow_expr(visitor, &field.expr, blk_id);
                 }
             }
-            hir::ExprKind::Array(ref subexprs) | hir::ExprKind::Tup(ref subexprs) => {
+            hir::ExprKind::Array(subexprs) | hir::ExprKind::Tup(subexprs) => {
                 for subexpr in subexprs {
                     record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
                 }
index 7110ab40328450ef78b036612fbc3819c38aea8b..4215348f24cf58608824ff32c9ff47bad61d0871 100644 (file)
@@ -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 {
@@ -388,7 +388,7 @@ fn walk_local(&mut self, local: &hir::Local<'_>) {
     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);