@@ -2,8 +2,8 @@ use std::borrow::Cow;
22use std:: cmp:: min;
33
44use 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 } ;
77use syntax:: { ast, ptr} ;
88
99use crate :: chains:: rewrite_chain;
@@ -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,
@@ -252,7 +252,7 @@ pub(crate) fn format_expr(
252252 fn needs_space_before_range ( context : & RewriteContext < ' _ > , lhs : & ast:: Expr ) -> bool {
253253 match lhs. kind {
254254 ast:: ExprKind :: Lit ( ref lit) => match lit. kind {
255- ast:: LitKind :: FloatUnsuffixed ( .. ) => {
255+ ast:: LitKind :: Float ( _ , ast :: LitFloatType :: Unsuffixed ) => {
256256 context. snippet ( lit. span ) . ends_with ( '.' )
257257 }
258258 _ => false ,
@@ -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, _)
@@ -1335,8 +1335,12 @@ pub(crate) fn can_be_overflowed_expr(
13351335 || ( context. use_block_indent ( ) && args_len == 1 )
13361336 }
13371337 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 ,
13401344 _ => context. use_block_indent ( ) && args_len == 1 ,
13411345 }
13421346 }
@@ -1347,7 +1351,7 @@ pub(crate) fn can_be_overflowed_expr(
13471351 }
13481352
13491353 // Handle unary-like expressions
1350- ast:: ExprKind :: AddrOf ( _, ref expr)
1354+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
13511355 | ast:: ExprKind :: Box ( ref expr)
13521356 | ast:: ExprKind :: Try ( ref expr)
13531357 | ast:: ExprKind :: Unary ( _, ref expr)
@@ -1359,7 +1363,7 @@ pub(crate) fn can_be_overflowed_expr(
13591363pub ( crate ) fn is_nested_call ( expr : & ast:: Expr ) -> bool {
13601364 match expr. kind {
13611365 ast:: ExprKind :: Call ( ..) | ast:: ExprKind :: Mac ( ..) => true ,
1362- ast:: ExprKind :: AddrOf ( _, ref expr)
1366+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
13631367 | ast:: ExprKind :: Box ( ref expr)
13641368 | ast:: ExprKind :: Try ( ref expr)
13651369 | ast:: ExprKind :: Unary ( _, ref expr)
@@ -2035,21 +2039,22 @@ pub(crate) fn prefer_next_line(
20352039
20362040fn rewrite_expr_addrof (
20372041 context : & RewriteContext < ' _ > ,
2042+ _borrow_kind : ast:: BorrowKind ,
20382043 mutability : ast:: Mutability ,
20392044 expr : & ast:: Expr ,
20402045 shape : Shape ,
20412046) -> Option < String > {
20422047 let operator_str = match mutability {
2043- ast:: Mutability :: Immutable => "&" ,
2044- ast:: Mutability :: Mutable => "&mut " ,
2048+ ast:: Mutability :: Not => "&" ,
2049+ ast:: Mutability :: Mut => "&mut " ,
20452050 } ;
20462051 rewrite_unary_prefix ( context, operator_str, expr, shape)
20472052}
20482053
20492054pub ( crate ) fn is_method_call ( expr : & ast:: Expr ) -> bool {
20502055 match expr. kind {
20512056 ast:: ExprKind :: MethodCall ( ..) => true ,
2052- ast:: ExprKind :: AddrOf ( _, ref expr)
2057+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
20532058 | ast:: ExprKind :: Box ( ref expr)
20542059 | ast:: ExprKind :: Cast ( ref expr, _)
20552060 | ast:: ExprKind :: Try ( ref expr)
0 commit comments