1
- use rustc_ast:: ast;
1
+ use rustc_ast:: { ast, token } ;
2
2
use rustc_span:: Span ;
3
3
4
4
use crate :: config:: IndentStyle ;
@@ -266,13 +266,17 @@ struct PairList<'a, 'b, T: Rewrite> {
266
266
span : Span ,
267
267
}
268
268
269
- fn is_ident ( expr : & ast:: Expr ) -> bool {
269
+ fn is_ident_or_bool_lit ( expr : & ast:: Expr ) -> bool {
270
270
match & expr. kind {
271
271
ast:: ExprKind :: Path ( None , path) if path. segments . len ( ) == 1 => true ,
272
+ ast:: ExprKind :: Lit ( token:: Lit {
273
+ kind : token:: LitKind :: Bool ,
274
+ ..
275
+ } ) => true ,
272
276
ast:: ExprKind :: Unary ( _, expr)
273
277
| ast:: ExprKind :: AddrOf ( _, _, expr)
274
278
| ast:: ExprKind :: Paren ( expr)
275
- | ast:: ExprKind :: Try ( expr) => is_ident ( expr) ,
279
+ | ast:: ExprKind :: Try ( expr) => is_ident_or_lit ( expr) ,
276
280
_ => false ,
277
281
}
278
282
}
@@ -290,10 +294,10 @@ impl<'a, 'b> PairList<'a, 'b, ast::Expr> {
290
294
return false ;
291
295
}
292
296
293
- let fist_item_is_ident = is_ident ( self . list [ 0 ] . 0 ) ;
297
+ let fist_item_is_ident_or_bool_lit = is_ident_or_bool_lit ( self . list [ 0 ] . 0 ) ;
294
298
let second_item_is_let_chain = matches ! ( self . list[ 1 ] . 0 . kind, ast:: ExprKind :: Let ( ..) ) ;
295
299
296
- fist_item_is_ident && second_item_is_let_chain
300
+ fist_item_is_ident_or_bool_lit && second_item_is_let_chain
297
301
}
298
302
}
299
303
0 commit comments