@@ -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 , SourceMap , Span } ;
5
+ use rustc_span :: { source_map :: SourceMap , 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 ,
@@ -1148,10 +1148,10 @@ pub(crate) fn is_simple_block(
1148
1148
attrs : Option < & [ ast:: Attribute ] > ,
1149
1149
source_map : & SourceMap ,
1150
1150
) -> bool {
1151
- ( block. stmts . len ( ) == 1
1151
+ block. stmts . len ( ) == 1
1152
1152
&& stmt_is_expr ( & block. stmts [ 0 ] )
1153
1153
&& !block_contains_comment ( block, source_map)
1154
- && attrs. map_or ( true , |a| a. is_empty ( ) ) )
1154
+ && attrs. map_or ( true , |a| a. is_empty ( ) )
1155
1155
}
1156
1156
1157
1157
/// Checks whether a block contains at most one statement or expression, and no
@@ -1268,7 +1268,7 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
1268
1268
match expr. kind {
1269
1269
ast:: ExprKind :: Lit ( ..) => true ,
1270
1270
ast:: ExprKind :: Path ( ref qself, ref path) => qself. is_none ( ) && path. segments . len ( ) <= 1 ,
1271
- ast:: ExprKind :: AddrOf ( _, ref expr)
1271
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
1272
1272
| ast:: ExprKind :: Box ( ref expr)
1273
1273
| ast:: ExprKind :: Cast ( ref expr, _)
1274
1274
| ast:: ExprKind :: Field ( ref expr, _)
@@ -1314,8 +1314,12 @@ pub(crate) fn can_be_overflowed_expr(
1314
1314
|| ( context. use_block_indent ( ) && args_len == 1 )
1315
1315
}
1316
1316
ast:: ExprKind :: Mac ( ref mac) => {
1317
- match ( mac. delim , context. config . overflow_delimited_expr ( ) ) {
1318
- ( ast:: MacDelimiter :: Bracket , true ) | ( ast:: MacDelimiter :: Brace , true ) => true ,
1317
+ match (
1318
+ syntax:: ast:: MacDelimiter :: from_token ( mac. args . delim ( ) ) ,
1319
+ context. config . overflow_delimited_expr ( ) ,
1320
+ ) {
1321
+ ( Some ( ast:: MacDelimiter :: Bracket ) , true )
1322
+ | ( Some ( ast:: MacDelimiter :: Brace ) , true ) => true ,
1319
1323
_ => context. use_block_indent ( ) && args_len == 1 ,
1320
1324
}
1321
1325
}
@@ -1326,7 +1330,7 @@ pub(crate) fn can_be_overflowed_expr(
1326
1330
}
1327
1331
1328
1332
// Handle unary-like expressions
1329
- ast:: ExprKind :: AddrOf ( _, ref expr)
1333
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
1330
1334
| ast:: ExprKind :: Box ( ref expr)
1331
1335
| ast:: ExprKind :: Try ( ref expr)
1332
1336
| ast:: ExprKind :: Unary ( _, ref expr)
@@ -1338,7 +1342,7 @@ pub(crate) fn can_be_overflowed_expr(
1338
1342
pub ( crate ) fn is_nested_call ( expr : & ast:: Expr ) -> bool {
1339
1343
match expr. kind {
1340
1344
ast:: ExprKind :: Call ( ..) | ast:: ExprKind :: Mac ( ..) => true ,
1341
- ast:: ExprKind :: AddrOf ( _, ref expr)
1345
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
1342
1346
| ast:: ExprKind :: Box ( ref expr)
1343
1347
| ast:: ExprKind :: Try ( ref expr)
1344
1348
| ast:: ExprKind :: Unary ( _, ref expr)
@@ -1985,21 +1989,22 @@ pub(crate) fn prefer_next_line(
1985
1989
1986
1990
fn rewrite_expr_addrof (
1987
1991
context : & RewriteContext < ' _ > ,
1992
+ _borrow_kind : ast:: BorrowKind ,
1988
1993
mutability : ast:: Mutability ,
1989
1994
expr : & ast:: Expr ,
1990
1995
shape : Shape ,
1991
1996
) -> Option < String > {
1992
1997
let operator_str = match mutability {
1993
- ast:: Mutability :: Immutable => "&" ,
1994
- ast:: Mutability :: Mutable => "&mut " ,
1998
+ ast:: Mutability :: Not => "&" ,
1999
+ ast:: Mutability :: Mut => "&mut " ,
1995
2000
} ;
1996
2001
rewrite_unary_prefix ( context, operator_str, expr, shape)
1997
2002
}
1998
2003
1999
2004
pub ( crate ) fn is_method_call ( expr : & ast:: Expr ) -> bool {
2000
2005
match expr. kind {
2001
2006
ast:: ExprKind :: MethodCall ( ..) => true ,
2002
- ast:: ExprKind :: AddrOf ( _, ref expr)
2007
+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
2003
2008
| ast:: ExprKind :: Box ( ref expr)
2004
2009
| ast:: ExprKind :: Cast ( ref expr, _)
2005
2010
| ast:: ExprKind :: Try ( ref expr)
0 commit comments