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 ;
@@ -272,13 +272,17 @@ struct PairList<'a, 'b, T: Rewrite> {
272
272
span : Span ,
273
273
}
274
274
275
- fn is_ident ( expr : & ast:: Expr ) -> bool {
275
+ fn is_ident_or_bool_lit ( expr : & ast:: Expr ) -> bool {
276
276
match & expr. kind {
277
277
ast:: ExprKind :: Path ( None , path) if path. segments . len ( ) == 1 => true ,
278
+ ast:: ExprKind :: Lit ( token:: Lit {
279
+ kind : token:: LitKind :: Bool ,
280
+ ..
281
+ } ) => true ,
278
282
ast:: ExprKind :: Unary ( _, expr)
279
283
| ast:: ExprKind :: AddrOf ( _, _, expr)
280
284
| ast:: ExprKind :: Paren ( expr)
281
- | ast:: ExprKind :: Try ( expr) => is_ident ( expr) ,
285
+ | ast:: ExprKind :: Try ( expr) => is_ident_or_bool_lit ( expr) ,
282
286
_ => false ,
283
287
}
284
288
}
@@ -296,10 +300,10 @@ impl<'a, 'b> PairList<'a, 'b, ast::Expr> {
296
300
return false ;
297
301
}
298
302
299
- let fist_item_is_ident = is_ident ( self . list [ 0 ] . 0 ) ;
303
+ let fist_item_is_ident_or_bool_lit = is_ident_or_bool_lit ( self . list [ 0 ] . 0 ) ;
300
304
let second_item_is_let_chain = matches ! ( self . list[ 1 ] . 0 . kind, ast:: ExprKind :: Let ( ..) ) ;
301
305
302
- fist_item_is_ident && second_item_is_let_chain
306
+ fist_item_is_ident_or_bool_lit && second_item_is_let_chain
303
307
}
304
308
}
305
309
0 commit comments