Skip to content

Commit 6064ab5

Browse files
refactor: update some ExprKind variants
1 parent a34d9b1 commit 6064ab5

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

rustfmt-core/rustfmt-lib/src/closures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn rewrite_closure_expr(
184184
| ast::ExprKind::Loop(..)
185185
| ast::ExprKind::Struct(..) => true,
186186

187-
ast::ExprKind::AddrOf(_, ref expr)
187+
ast::ExprKind::AddrOf(_, _, ref expr)
188188
| ast::ExprKind::Box(ref expr)
189189
| ast::ExprKind::Try(ref expr)
190190
| ast::ExprKind::Unary(_, ref expr)
@@ -431,7 +431,7 @@ fn is_block_closure_forced_inner(expr: &ast::Expr) -> bool {
431431
| ast::ExprKind::While(..)
432432
| ast::ExprKind::ForLoop(..)
433433
| ast::ExprKind::Loop(..) => true,
434-
ast::ExprKind::AddrOf(_, ref expr)
434+
ast::ExprKind::AddrOf(_, _, ref expr)
435435
| ast::ExprKind::Box(ref expr)
436436
| ast::ExprKind::Try(ref expr)
437437
| ast::ExprKind::Unary(_, ref expr)

rustfmt-core/rustfmt-lib/src/expr.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub(crate) fn format_expr(
159159
ast::ExprKind::Path(ref qself, ref path) => {
160160
rewrite_path(context, PathContext::Expr, qself.as_ref(), path, shape)
161161
}
162-
ast::ExprKind::Assign(ref lhs, ref rhs) => {
162+
ast::ExprKind::Assign(ref lhs, ref rhs, _) => {
163163
rewrite_assignment(context, lhs, rhs, None, shape)
164164
}
165165
ast::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => {
@@ -213,8 +213,8 @@ pub(crate) fn format_expr(
213213
rewrite_unary_prefix(context, "return ", &**expr, shape)
214214
}
215215
ast::ExprKind::Box(ref expr) => rewrite_unary_prefix(context, "box ", &**expr, shape),
216-
ast::ExprKind::AddrOf(mutability, ref expr) => {
217-
rewrite_expr_addrof(context, mutability, expr, shape)
216+
ast::ExprKind::AddrOf(borrow_kind, mutability, ref expr) => {
217+
rewrite_expr_addrof(context, borrow_kind, mutability, expr, shape)
218218
}
219219
ast::ExprKind::Cast(ref expr, ref ty) => rewrite_pair(
220220
&**expr,
@@ -1289,7 +1289,7 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
12891289
match expr.kind {
12901290
ast::ExprKind::Lit(..) => true,
12911291
ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1,
1292-
ast::ExprKind::AddrOf(_, ref expr)
1292+
ast::ExprKind::AddrOf(_, _, ref expr)
12931293
| ast::ExprKind::Box(ref expr)
12941294
| ast::ExprKind::Cast(ref expr, _)
12951295
| ast::ExprKind::Field(ref expr, _)
@@ -1347,7 +1347,7 @@ pub(crate) fn can_be_overflowed_expr(
13471347
}
13481348

13491349
// Handle unary-like expressions
1350-
ast::ExprKind::AddrOf(_, ref expr)
1350+
ast::ExprKind::AddrOf(_, _, ref expr)
13511351
| ast::ExprKind::Box(ref expr)
13521352
| ast::ExprKind::Try(ref expr)
13531353
| ast::ExprKind::Unary(_, ref expr)
@@ -1359,7 +1359,7 @@ pub(crate) fn can_be_overflowed_expr(
13591359
pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool {
13601360
match expr.kind {
13611361
ast::ExprKind::Call(..) | ast::ExprKind::Mac(..) => true,
1362-
ast::ExprKind::AddrOf(_, ref expr)
1362+
ast::ExprKind::AddrOf(_, _, ref expr)
13631363
| ast::ExprKind::Box(ref expr)
13641364
| ast::ExprKind::Try(ref expr)
13651365
| ast::ExprKind::Unary(_, ref expr)
@@ -2035,6 +2035,7 @@ pub(crate) fn prefer_next_line(
20352035

20362036
fn rewrite_expr_addrof(
20372037
context: &RewriteContext<'_>,
2038+
_borrow_kind: ast::BorrowKind,
20382039
mutability: ast::Mutability,
20392040
expr: &ast::Expr,
20402041
shape: Shape,
@@ -2049,7 +2050,7 @@ fn rewrite_expr_addrof(
20492050
pub(crate) fn is_method_call(expr: &ast::Expr) -> bool {
20502051
match expr.kind {
20512052
ast::ExprKind::MethodCall(..) => true,
2052-
ast::ExprKind::AddrOf(_, ref expr)
2053+
ast::ExprKind::AddrOf(_, _, ref expr)
20532054
| ast::ExprKind::Box(ref expr)
20542055
| ast::ExprKind::Cast(ref expr, _)
20552056
| ast::ExprKind::Try(ref expr)

rustfmt-core/rustfmt-lib/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ fn can_flatten_block_around_this(body: &ast::Expr) -> bool {
575575
| ast::ExprKind::Mac(..)
576576
| ast::ExprKind::Struct(..)
577577
| ast::ExprKind::Tup(..) => true,
578-
ast::ExprKind::AddrOf(_, ref expr)
578+
ast::ExprKind::AddrOf(_, _, ref expr)
579579
| ast::ExprKind::Box(ref expr)
580580
| ast::ExprKind::Try(ref expr)
581581
| ast::ExprKind::Unary(_, ref expr)

rustfmt-core/rustfmt-lib/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ pub(crate) fn left_most_sub_expr(e: &ast::Expr) -> &ast::Expr {
418418
| ast::ExprKind::Binary(_, ref e, _)
419419
| ast::ExprKind::Cast(ref e, _)
420420
| ast::ExprKind::Type(ref e, _)
421-
| ast::ExprKind::Assign(ref e, _)
421+
| ast::ExprKind::Assign(ref e,_, _)
422422
| ast::ExprKind::AssignOp(_, ref e, _)
423423
| ast::ExprKind::Field(ref e, _)
424424
| ast::ExprKind::Index(ref e, _)

0 commit comments

Comments
 (0)