@@ -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 , SourceMap , Span } ;
5+ use rustc_span :: { source_map :: SourceMap , 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 ,
@@ -1148,10 +1148,10 @@ pub(crate) fn is_simple_block(
11481148 attrs : Option < & [ ast:: Attribute ] > ,
11491149 source_map : & SourceMap ,
11501150) -> bool {
1151- ( block. stmts . len ( ) == 1
1151+ block. stmts . len ( ) == 1
11521152 && stmt_is_expr ( & block. stmts [ 0 ] )
11531153 && !block_contains_comment ( block, source_map)
1154- && attrs. map_or ( true , |a| a. is_empty ( ) ) )
1154+ && attrs. map_or ( true , |a| a. is_empty ( ) )
11551155}
11561156
11571157/// 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 {
12681268 match expr. kind {
12691269 ast:: ExprKind :: Lit ( ..) => true ,
12701270 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)
12721272 | ast:: ExprKind :: Box ( ref expr)
12731273 | ast:: ExprKind :: Cast ( ref expr, _)
12741274 | ast:: ExprKind :: Field ( ref expr, _)
@@ -1314,8 +1314,12 @@ pub(crate) fn can_be_overflowed_expr(
13141314 || ( context. use_block_indent ( ) && args_len == 1 )
13151315 }
13161316 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 ,
13191323 _ => context. use_block_indent ( ) && args_len == 1 ,
13201324 }
13211325 }
@@ -1326,7 +1330,7 @@ pub(crate) fn can_be_overflowed_expr(
13261330 }
13271331
13281332 // Handle unary-like expressions
1329- ast:: ExprKind :: AddrOf ( _, ref expr)
1333+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
13301334 | ast:: ExprKind :: Box ( ref expr)
13311335 | ast:: ExprKind :: Try ( ref expr)
13321336 | ast:: ExprKind :: Unary ( _, ref expr)
@@ -1338,7 +1342,7 @@ pub(crate) fn can_be_overflowed_expr(
13381342pub ( crate ) fn is_nested_call ( expr : & ast:: Expr ) -> bool {
13391343 match expr. kind {
13401344 ast:: ExprKind :: Call ( ..) | ast:: ExprKind :: Mac ( ..) => true ,
1341- ast:: ExprKind :: AddrOf ( _, ref expr)
1345+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
13421346 | ast:: ExprKind :: Box ( ref expr)
13431347 | ast:: ExprKind :: Try ( ref expr)
13441348 | ast:: ExprKind :: Unary ( _, ref expr)
@@ -1985,21 +1989,22 @@ pub(crate) fn prefer_next_line(
19851989
19861990fn rewrite_expr_addrof (
19871991 context : & RewriteContext < ' _ > ,
1992+ _borrow_kind : ast:: BorrowKind ,
19881993 mutability : ast:: Mutability ,
19891994 expr : & ast:: Expr ,
19901995 shape : Shape ,
19911996) -> Option < String > {
19921997 let operator_str = match mutability {
1993- ast:: Mutability :: Immutable => "&" ,
1994- ast:: Mutability :: Mutable => "&mut " ,
1998+ ast:: Mutability :: Not => "&" ,
1999+ ast:: Mutability :: Mut => "&mut " ,
19952000 } ;
19962001 rewrite_unary_prefix ( context, operator_str, expr, shape)
19972002}
19982003
19992004pub ( crate ) fn is_method_call ( expr : & ast:: Expr ) -> bool {
20002005 match expr. kind {
20012006 ast:: ExprKind :: MethodCall ( ..) => true ,
2002- ast:: ExprKind :: AddrOf ( _, ref expr)
2007+ ast:: ExprKind :: AddrOf ( _, _ , ref expr)
20032008 | ast:: ExprKind :: Box ( ref expr)
20042009 | ast:: ExprKind :: Cast ( ref expr, _)
20052010 | ast:: ExprKind :: Try ( ref expr)
0 commit comments