Skip to content

Commit 52e9825

Browse files
committed
Visit for hir::Expr.
1 parent 2b1cfe5 commit 52e9825

File tree

8 files changed

+41
-38
lines changed

8 files changed

+41
-38
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ where
465465
pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) {
466466
visitor.visit_id(param.hir_id);
467467
visitor.visit_pat(&param.pat);
468-
walk_list!(visitor, visit_attribute, &param.attrs);
468+
walk_list!(visitor, visit_attribute, param.attrs);
469469
}
470470

471471
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
@@ -687,23 +687,23 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding
687687
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
688688
visitor.visit_id(pattern.hir_id);
689689
match pattern.kind {
690-
PatKind::TupleStruct(ref qpath, ref children, _) => {
690+
PatKind::TupleStruct(ref qpath, children, _) => {
691691
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
692692
walk_list!(visitor, visit_pat, children);
693693
}
694694
PatKind::Path(ref qpath) => {
695695
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
696696
}
697-
PatKind::Struct(ref qpath, ref fields, _) => {
697+
PatKind::Struct(ref qpath, fields, _) => {
698698
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
699699
for field in fields {
700700
visitor.visit_id(field.hir_id);
701701
visitor.visit_ident(field.ident);
702702
visitor.visit_pat(&field.pat)
703703
}
704704
}
705-
PatKind::Or(ref pats) => walk_list!(visitor, visit_pat, pats),
706-
PatKind::Tuple(ref tuple_elements, _) => {
705+
PatKind::Or(pats) => walk_list!(visitor, visit_pat, pats),
706+
PatKind::Tuple(tuple_elements, _) => {
707707
walk_list!(visitor, visit_pat, tuple_elements);
708708
}
709709
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>) {
719719
visitor.visit_expr(upper_bound)
720720
}
721721
PatKind::Wild => (),
722-
PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
722+
PatKind::Slice(prepatterns, ref slice_pattern, postpatterns) => {
723723
walk_list!(visitor, visit_pat, prepatterns);
724724
walk_list!(visitor, visit_pat, slice_pattern);
725725
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
957957

958958
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) {
959959
visitor.visit_id(block.hir_id);
960-
walk_list!(visitor, visit_stmt, &block.stmts);
960+
walk_list!(visitor, visit_stmt, block.stmts);
961961
walk_list!(visitor, visit_expr, &block.expr);
962962
}
963963

@@ -982,14 +982,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
982982
walk_list!(visitor, visit_attribute, expression.attrs.iter());
983983
match expression.kind {
984984
ExprKind::Box(ref subexpression) => visitor.visit_expr(subexpression),
985-
ExprKind::Array(ref subexpressions) => {
985+
ExprKind::Array(subexpressions) => {
986986
walk_list!(visitor, visit_expr, subexpressions);
987987
}
988988
ExprKind::Repeat(ref element, ref count) => {
989989
visitor.visit_expr(element);
990990
visitor.visit_anon_const(count)
991991
}
992-
ExprKind::Struct(ref qpath, ref fields, ref optional_base) => {
992+
ExprKind::Struct(ref qpath, fields, ref optional_base) => {
993993
visitor.visit_qpath(qpath, expression.hir_id, expression.span);
994994
for field in fields {
995995
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>)
998998
}
999999
walk_list!(visitor, visit_expr, optional_base);
10001000
}
1001-
ExprKind::Tup(ref subexpressions) => {
1001+
ExprKind::Tup(subexpressions) => {
10021002
walk_list!(visitor, visit_expr, subexpressions);
10031003
}
1004-
ExprKind::Call(ref callee_expression, ref arguments) => {
1004+
ExprKind::Call(ref callee_expression, arguments) => {
10051005
visitor.visit_expr(callee_expression);
10061006
walk_list!(visitor, visit_expr, arguments);
10071007
}
1008-
ExprKind::MethodCall(ref segment, _, ref arguments) => {
1008+
ExprKind::MethodCall(ref segment, _, arguments) => {
10091009
visitor.visit_path_segment(expression.span, segment);
10101010
walk_list!(visitor, visit_expr, arguments);
10111011
}
@@ -1027,7 +1027,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
10271027
walk_list!(visitor, visit_label, opt_label);
10281028
visitor.visit_block(block);
10291029
}
1030-
ExprKind::Match(ref subexpression, ref arms, _) => {
1030+
ExprKind::Match(ref subexpression, arms, _) => {
10311031
visitor.visit_expr(subexpression);
10321032
walk_list!(visitor, visit_arm, arms);
10331033
}
@@ -1077,8 +1077,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
10771077
walk_list!(visitor, visit_expr, optional_expression);
10781078
}
10791079
ExprKind::InlineAsm(ref asm) => {
1080-
walk_list!(visitor, visit_expr, &asm.outputs_exprs);
1081-
walk_list!(visitor, visit_expr, &asm.inputs_exprs);
1080+
walk_list!(visitor, visit_expr, asm.outputs_exprs);
1081+
walk_list!(visitor, visit_expr, asm.inputs_exprs);
10821082
}
10831083
ExprKind::Yield(ref subexpression, _) => {
10841084
visitor.visit_expr(subexpression);
@@ -1096,7 +1096,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
10961096
}
10971097
}
10981098
visitor.visit_expr(&arm.body);
1099-
walk_list!(visitor, visit_attribute, &arm.attrs);
1099+
walk_list!(visitor, visit_attribute, arm.attrs);
11001100
}
11011101

11021102
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {

src/librustc/hir/map/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,19 @@ pub struct Map<'hir> {
180180
hir_to_node_id: FxHashMap<HirId, NodeId>,
181181
}
182182

183-
struct ParentHirIterator<'map> {
183+
struct ParentHirIterator<'map, 'hir> {
184184
current_id: HirId,
185-
map: &'map Map<'map>,
185+
map: &'map Map<'hir>,
186186
}
187187

188-
impl<'map> ParentHirIterator<'map> {
189-
fn new(current_id: HirId, map: &'map Map<'map>) -> ParentHirIterator<'map> {
188+
impl<'map, 'hir> ParentHirIterator<'map, 'hir> {
189+
fn new(current_id: HirId, map: &'map Map<'hir>) -> ParentHirIterator<'map, 'hir> {
190190
ParentHirIterator { current_id, map }
191191
}
192192
}
193193

194-
impl<'map> Iterator for ParentHirIterator<'map> {
195-
type Item = (HirId, Node<'map>);
194+
impl<'map, 'hir> Iterator for ParentHirIterator<'map, 'hir> {
195+
type Item = (HirId, Node<'hir>);
196196

197197
fn next(&mut self) -> Option<Self::Item> {
198198
if self.current_id == CRATE_HIR_ID {
@@ -782,7 +782,7 @@ impl<'hir> Map<'hir> {
782782
///
783783
/// Used by error reporting when there's a type error in a match arm caused by the `match`
784784
/// expression needing to be unit.
785-
pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&Expr<'hir>> {
785+
pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>> {
786786
for (_, node) in ParentHirIterator::new(hir_id, &self) {
787787
match node {
788788
Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) | Node::ImplItem(_) => {

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ pub enum ExprKind<'hir> {
17141714
Path(QPath),
17151715

17161716
/// A referencing operation (i.e., `&a` or `&mut a`).
1717-
AddrOf(BorrowKind, &'hir Expr<'hir>),
1717+
AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
17181718
/// A `break`, with an optional label to break.
17191719
Break(Destination, Option<&'hir Expr<'hir>>),
17201720
/// A `continue`, with an optional label.

src/librustc/hir/pat_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl hir::Pat<'_> {
126126
}
127127

128128
/// Checks if the pattern satisfies the given predicate on some sub-pattern.
129-
fn satisfies(&self, pred: impl Fn(&Self) -> bool) -> bool {
129+
fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool {
130130
let mut satisfies = false;
131131
self.walk_short(|p| {
132132
if pred(p) {

src/librustc/hir/print.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use syntax::util::parser::{self, AssocOp, Fixity};
1010
use syntax_pos::{self, BytePos, FileName};
1111

1212
use crate::hir;
13-
use crate::hir::ptr::P;
1413
use crate::hir::{GenericArg, GenericParam, GenericParamKind};
1514
use crate::hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
1615

@@ -972,7 +971,7 @@ impl<'a> State<'a> {
972971

973972
self.print_inner_attributes(attrs);
974973

975-
for st in &blk.stmts {
974+
for st in blk.stmts {
976975
self.print_stmt(st);
977976
}
978977
if let Some(ref expr) = blk.expr {
@@ -1047,7 +1046,7 @@ impl<'a> State<'a> {
10471046
&mut self,
10481047
qpath: &hir::QPath,
10491048
fields: &[hir::Field<'_>],
1050-
wth: &Option<P<hir::Expr<'_>>>,
1049+
wth: &Option<&'hir hir::Expr<'_>>,
10511050
) {
10521051
self.print_qpath(qpath, true);
10531052
self.s.word("{");
@@ -1187,8 +1186,8 @@ impl<'a> State<'a> {
11871186
hir::ExprKind::Repeat(ref element, ref count) => {
11881187
self.print_expr_repeat(&element, count);
11891188
}
1190-
hir::ExprKind::Struct(ref qpath, ref fields, ref wth) => {
1191-
self.print_expr_struct(qpath, &fields[..], wth);
1189+
hir::ExprKind::Struct(ref qpath, fields, ref wth) => {
1190+
self.print_expr_struct(qpath, fields, wth);
11921191
}
11931192
hir::ExprKind::Tup(ref exprs) => {
11941193
self.print_expr_tup(exprs);
@@ -1251,7 +1250,7 @@ impl<'a> State<'a> {
12511250
self.s.space();
12521251
self.print_block(&blk);
12531252
}
1254-
hir::ExprKind::Match(ref expr, ref arms, _) => {
1253+
hir::ExprKind::Match(ref expr, arms, _) => {
12551254
self.cbox(INDENT_UNIT);
12561255
self.ibox(INDENT_UNIT);
12571256
self.word_nbsp("match");

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
460460
/// needed, suggest annotating the call, otherwise point out the resulting type of the call.
461461
fn annotate_method_call(
462462
&self,
463-
segment: &hir::ptr::P<hir::PathSegment>,
463+
segment: &hir::PathSegment,
464464
e: &Expr<'_>,
465465
err: &mut DiagnosticBuilder<'_>,
466466
) {

src/librustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,12 +1271,12 @@ fn resolve_local<'tcx>(
12711271
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
12721272
record_rvalue_scope(visitor, &subexpr, blk_id);
12731273
}
1274-
hir::ExprKind::Struct(_, ref fields, _) => {
1274+
hir::ExprKind::Struct(_, fields, _) => {
12751275
for field in fields {
12761276
record_rvalue_scope_if_borrow_expr(visitor, &field.expr, blk_id);
12771277
}
12781278
}
1279-
hir::ExprKind::Array(ref subexprs) | hir::ExprKind::Tup(ref subexprs) => {
1279+
hir::ExprKind::Array(subexprs) | hir::ExprKind::Tup(subexprs) => {
12801280
for subexpr in subexprs {
12811281
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
12821282
}

src/librustc_typeck/expr_use_visitor.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
228228
self.consume_exprs(exprs);
229229
}
230230

231-
hir::ExprKind::Match(ref discr, ref arms, _) => {
231+
hir::ExprKind::Match(ref discr, arms, _) => {
232232
let discr_place = return_if_err!(self.mc.cat_expr(&discr));
233233
self.borrow_expr(&discr, ty::ImmBorrow);
234234

@@ -251,7 +251,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
251251
}
252252

253253
hir::ExprKind::InlineAsm(ref ia) => {
254-
for (o, output) in ia.inner.outputs.iter().zip(&ia.outputs_exprs) {
254+
for (o, output) in ia.inner.outputs.iter().zip(ia.outputs_exprs) {
255255
if o.is_indirect {
256256
self.consume_expr(output);
257257
} else {
@@ -388,7 +388,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
388388
fn walk_block(&mut self, blk: &hir::Block<'_>) {
389389
debug!("walk_block(blk.hir_id={})", blk.hir_id);
390390

391-
for stmt in &blk.stmts {
391+
for stmt in blk.stmts {
392392
self.walk_stmt(stmt);
393393
}
394394

@@ -397,7 +397,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
397397
}
398398
}
399399

400-
fn walk_struct_expr(&mut self, fields: &[hir::Field<'_>], opt_with: &Option<P<hir::Expr<'_>>>) {
400+
fn walk_struct_expr(
401+
&mut self,
402+
fields: &[hir::Field<'_>],
403+
opt_with: &Option<&'hir hir::Expr<'_>>,
404+
) {
401405
// Consume the expressions supplying values for each field.
402406
for field in fields {
403407
self.consume_expr(&field.expr);

0 commit comments

Comments
 (0)