@@ -2,8 +2,8 @@ use std::borrow::Cow;
2
2
use std:: cmp:: min;
3
3
4
4
use itertools:: Itertools ;
5
- use syntax :: parse :: token :: { DelimToken , LitKind } ;
6
- use syntax:: source_map :: { BytePos , Span } ;
5
+ use rustc_span :: { BytePos , Span } ;
6
+ use syntax:: token :: { DelimToken , LitKind } ;
7
7
use syntax:: { ast, ptr} ;
8
8
9
9
use crate :: chains:: rewrite_chain;
@@ -159,7 +159,7 @@ pub(crate) fn format_expr(
159
159
ast:: ExprKind :: Path ( ref qself, ref path) => {
160
160
rewrite_path ( context, PathContext :: Expr , qself. as_ref ( ) , path, shape)
161
161
}
162
- ast:: ExprKind :: Assign ( ref lhs, ref rhs) => {
162
+ ast:: ExprKind :: Assign ( ref lhs, ref rhs, _ ) => {
163
163
rewrite_assignment ( context, lhs, rhs, None , shape)
164
164
}
165
165
ast:: ExprKind :: AssignOp ( ref op, ref lhs, ref rhs) => {
@@ -213,8 +213,8 @@ pub(crate) fn format_expr(
213
213
rewrite_unary_prefix ( context, "return " , & * * expr, shape)
214
214
}
215
215
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)
218
218
}
219
219
ast:: ExprKind :: Cast ( ref expr, ref ty) => rewrite_pair (
220
220
& * * expr,
@@ -252,7 +252,7 @@ pub(crate) fn format_expr(
252
252
fn needs_space_before_range ( context : & RewriteContext < ' _ > , lhs : & ast:: Expr ) -> bool {
253
253
match lhs. kind {
254
254
ast:: ExprKind :: Lit ( ref lit) => match lit. kind {
255
- ast:: LitKind :: FloatUnsuffixed ( .. ) => {
255
+ ast:: LitKind :: Float ( _ , ast :: LitFloatType :: Unsuffixed ) => {
256
256
context. snippet ( lit. span ) . ends_with ( '.' )
257
257
}
258
258
_ => false ,
@@ -1289,7 +1289,7 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
1289
1289
match expr. kind {
1290
1290
ast:: ExprKind :: Lit ( ..) => true ,
1291
1291
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)
1293
1293
| ast:: ExprKind :: Box ( ref expr)
1294
1294
| ast:: ExprKind :: Cast ( ref expr, _)
1295
1295
| ast:: ExprKind :: Field ( ref expr, _)
@@ -1335,8 +1335,12 @@ pub(crate) fn can_be_overflowed_expr(
1335
1335
|| ( context. use_block_indent ( ) && args_len == 1 )
1336
1336
}
1337
1337
ast:: ExprKind :: Mac ( ref mac) => {
1338
- match ( mac. delim , context. config . overflow_delimited_expr ( ) ) {
1339
- ( ast:: MacDelimiter :: Bracket , true ) | ( ast:: MacDelimiter :: Brace , true ) => true ,
1338
+ match (
1339
+ syntax:: ast:: MacDelimiter :: from_token ( mac. args . delim ( ) ) ,
1340
+ context. config . overflow_delimited_expr ( ) ,
1341
+ ) {
1342
+ ( Some ( ast:: MacDelimiter :: Bracket ) , true )
1343
+ | ( Some ( ast:: MacDelimiter :: Brace ) , true ) => true ,
1340
1344
_ => context. use_block_indent ( ) && args_len == 1 ,
1341
1345
}
1342
1346
}
@@ -1347,7 +1351,7 @@ pub(crate) fn can_be_overflowed_expr(
1347
1351
}
1348
1352
1349
1353
// Handle unary-like expressions
1350
- ast:: ExprKind :: AddrOf ( _, ref expr)
1354
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
1351
1355
| ast:: ExprKind :: Box ( ref expr)
1352
1356
| ast:: ExprKind :: Try ( ref expr)
1353
1357
| ast:: ExprKind :: Unary ( _, ref expr)
@@ -1359,7 +1363,7 @@ pub(crate) fn can_be_overflowed_expr(
1359
1363
pub ( crate ) fn is_nested_call ( expr : & ast:: Expr ) -> bool {
1360
1364
match expr. kind {
1361
1365
ast:: ExprKind :: Call ( ..) | ast:: ExprKind :: Mac ( ..) => true ,
1362
- ast:: ExprKind :: AddrOf ( _, ref expr)
1366
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
1363
1367
| ast:: ExprKind :: Box ( ref expr)
1364
1368
| ast:: ExprKind :: Try ( ref expr)
1365
1369
| ast:: ExprKind :: Unary ( _, ref expr)
@@ -2035,21 +2039,22 @@ pub(crate) fn prefer_next_line(
2035
2039
2036
2040
fn rewrite_expr_addrof (
2037
2041
context : & RewriteContext < ' _ > ,
2042
+ _borrow_kind : ast:: BorrowKind ,
2038
2043
mutability : ast:: Mutability ,
2039
2044
expr : & ast:: Expr ,
2040
2045
shape : Shape ,
2041
2046
) -> Option < String > {
2042
2047
let operator_str = match mutability {
2043
- ast:: Mutability :: Immutable => "&" ,
2044
- ast:: Mutability :: Mutable => "&mut " ,
2048
+ ast:: Mutability :: Not => "&" ,
2049
+ ast:: Mutability :: Mut => "&mut " ,
2045
2050
} ;
2046
2051
rewrite_unary_prefix ( context, operator_str, expr, shape)
2047
2052
}
2048
2053
2049
2054
pub ( crate ) fn is_method_call ( expr : & ast:: Expr ) -> bool {
2050
2055
match expr. kind {
2051
2056
ast:: ExprKind :: MethodCall ( ..) => true ,
2052
- ast:: ExprKind :: AddrOf ( _, ref expr)
2057
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
2053
2058
| ast:: ExprKind :: Box ( ref expr)
2054
2059
| ast:: ExprKind :: Cast ( ref expr, _)
2055
2060
| ast:: ExprKind :: Try ( ref expr)
0 commit comments