@@ -127,24 +127,13 @@ impl<'a> FmtVisitor<'a> {
127
127
128
128
fn rewrite_paren ( & mut self , subexpr : & ast:: Expr , width : usize , offset : usize ) -> String {
129
129
debug ! ( "rewrite_paren, width: {}, offset: {}" , width, offset) ;
130
- // 1 is for opening paren
131
- let subexpr_str = self . rewrite_expr ( subexpr, width-1 , offset+1 ) ;
130
+ // 1 is for opening paren, 2 is for opening+closing, we want to keep the closing
131
+ // paren on the same line as the subexpr
132
+ let subexpr_str = self . rewrite_expr ( subexpr, width-2 , offset+1 ) ;
132
133
debug ! ( "rewrite_paren, subexpr_str: `{}`" , subexpr_str) ;
133
- let mut lines = subexpr_str. rsplit ( '\n' ) ;
134
- let last_line_len = lines. next ( ) . unwrap ( ) . len ( ) ;
135
- let last_line_offset = match lines. next ( ) {
136
- None => offset+1 ,
137
- Some ( _) => 0 ,
138
- } ;
139
- if width + offset - last_line_offset - last_line_len > 0 {
140
- format ! ( "({})" , subexpr_str)
141
- } else {
142
- // FIXME That's correct unless we have width < 2. Return an Option for such cases ?
143
- format ! ( "({}\n {} )" , subexpr_str, make_indent( offset) )
144
- }
134
+ format ! ( "({})" , subexpr_str)
145
135
}
146
136
147
-
148
137
pub fn rewrite_expr ( & mut self , expr : & ast:: Expr , width : usize , offset : usize ) -> String {
149
138
match expr. node {
150
139
ast:: Expr_ :: ExprLit ( ref l) => {
0 commit comments