Skip to content

Commit ddd4500

Browse files
committed
Add span information to ExprKind::Assign
1 parent c740839 commit ddd4500

File tree

25 files changed

+65
-62
lines changed

25 files changed

+65
-62
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10561056
walk_list!(visitor, visit_label, opt_label);
10571057
visitor.visit_block(block);
10581058
}
1059-
ExprKind::Assign(ref left_hand_expression, ref right_hand_expression) => {
1060-
visitor.visit_expr(right_hand_expression);
1061-
visitor.visit_expr(left_hand_expression)
1059+
ExprKind::Assign(ref lhs, ref rhs, _) => {
1060+
visitor.visit_expr(rhs);
1061+
visitor.visit_expr(lhs)
10621062
}
10631063
ExprKind::AssignOp(_, ref left_expression, ref right_expression) => {
10641064
visitor.visit_expr(right_expression);

src/librustc/hir/lowering/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl LoweringContext<'_, '_> {
112112
opt_label.is_some()),
113113
self.lower_label(opt_label))
114114
}
115-
ExprKind::Assign(ref el, ref er) => {
116-
hir::ExprKind::Assign(P(self.lower_expr(el)), P(self.lower_expr(er)))
115+
ExprKind::Assign(ref el, ref er, span) => {
116+
hir::ExprKind::Assign(P(self.lower_expr(el)), P(self.lower_expr(er)), span)
117117
}
118118
ExprKind::AssignOp(op, ref el, ref er) => hir::ExprKind::AssignOp(
119119
self.lower_binop(op),
@@ -1084,7 +1084,7 @@ impl LoweringContext<'_, '_> {
10841084
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat_hid));
10851085
let assign = P(self.expr(
10861086
pat.span,
1087-
hir::ExprKind::Assign(next_expr, val_expr),
1087+
hir::ExprKind::Assign(next_expr, val_expr, pat.span),
10881088
ThinVec::new(),
10891089
));
10901090
let some_pat = self.pat_some(pat.span, val_pat);

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ pub enum ExprKind {
16591659
Block(P<Block>, Option<Label>),
16601660

16611661
/// An assignment (e.g., `a = foo()`).
1662-
Assign(P<Expr>, P<Expr>),
1662+
Assign(P<Expr>, P<Expr>, Span),
16631663
/// An assignment with an operator.
16641664
///
16651665
/// E.g., `a += 1`.

src/librustc/hir/print.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ impl<'a> State<'a> {
13121312
self.ibox(0);
13131313
self.print_block(&blk);
13141314
}
1315-
hir::ExprKind::Assign(ref lhs, ref rhs) => {
1315+
hir::ExprKind::Assign(ref lhs, ref rhs, _) => {
13161316
let prec = AssocOp::Assign.precedence() as i8;
13171317
self.print_expr_maybe_paren(&lhs, prec + 1);
13181318
self.s.space();
@@ -2282,7 +2282,7 @@ fn contains_exterior_struct_lit(value: &hir::Expr) -> bool {
22822282
match value.kind {
22832283
hir::ExprKind::Struct(..) => true,
22842284

2285-
hir::ExprKind::Assign(ref lhs, ref rhs) |
2285+
hir::ExprKind::Assign(ref lhs, ref rhs, _) |
22862286
hir::ExprKind::AssignOp(_, ref lhs, ref rhs) |
22872287
hir::ExprKind::Binary(_, ref lhs, ref rhs) => {
22882288
// `X { y: 1 } + X { y: 2 }`

src/librustc_lint/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ impl EarlyLintPass for UnusedParens {
512512
(value, "`return` value", false, Some(left), None)
513513
}
514514

515-
Assign(_, ref value) => (value, "assigned value", false, None, None),
515+
Assign(_, ref value, _) => (value, "assigned value", false, None, None),
516516
AssignOp(.., ref value) => (value, "assigned value", false, None, None),
517517
// either function/method call, or something this lint doesn't care about
518518
ref call_or_other => {

src/librustc_mir/hair/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
274274

275275
hir::ExprKind::Block(ref blk, _) => ExprKind::Block { body: &blk },
276276

277-
hir::ExprKind::Assign(ref lhs, ref rhs) => {
277+
hir::ExprKind::Assign(ref lhs, ref rhs, _) => {
278278
ExprKind::Assign {
279279
lhs: lhs.to_ref(),
280280
rhs: rhs.to_ref(),

src/librustc_parse/parser/expr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ impl<'a> Parser<'a> {
276276
let binary = self.mk_binary(source_map::respan(cur_op_span, ast_op), lhs, rhs);
277277
self.mk_expr(span, binary, AttrVec::new())
278278
}
279-
AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs), AttrVec::new()),
279+
AssocOp::Assign => {
280+
self.mk_expr(span, ExprKind::Assign(lhs, rhs, cur_op_span), AttrVec::new())
281+
}
280282
AssocOp::AssignOp(k) => {
281283
let aop = match k {
282284
token::Plus => BinOpKind::Add,

src/librustc_passes/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10961096
span_bug!(expr.span, "continue to unknown label"))
10971097
}
10981098

1099-
hir::ExprKind::Assign(ref l, ref r) => {
1099+
hir::ExprKind::Assign(ref l, ref r, _) => {
11001100
// see comment on places in
11011101
// propagate_through_place_components()
11021102
let succ = self.write_place(&l, succ, ACC_WRITE);
@@ -1389,7 +1389,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
13891389

13901390
fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
13911391
match expr.kind {
1392-
hir::ExprKind::Assign(ref l, _) => {
1392+
hir::ExprKind::Assign(ref l, ..) => {
13931393
this.check_place(&l);
13941394
}
13951395

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
11981198
return;
11991199
}
12001200
match expr.kind {
1201-
hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => {
1201+
hir::ExprKind::Assign(_, ref rhs, _) | hir::ExprKind::Match(ref rhs, ..) => {
12021202
// Do not report duplicate errors for `x = y` and `match x { ... }`.
12031203
if self.check_expr_pat_type(rhs.hir_id, rhs.span) {
12041204
return;

src/librustc_typeck/check/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
484484
String::new()
485485
};
486486
if let Some(hir::Node::Expr(hir::Expr {
487-
kind: hir::ExprKind::Assign(left_expr, _),
487+
kind: hir::ExprKind::Assign(left_expr, ..),
488488
..
489489
})) = self.tcx.hir().find(
490490
self.tcx.hir().get_parent_node(expr.hir_id),

0 commit comments

Comments
 (0)