File tree Expand file tree Collapse file tree 3 files changed +5
-11
lines changed Expand file tree Collapse file tree 3 files changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -1413,16 +1413,10 @@ impl ExprCollector<'_> {
1413
1413
ast:: Pat :: LiteralPat ( it) => {
1414
1414
Some ( Box :: new ( LiteralOrConst :: Literal ( pat_literal_to_hir ( it) ?. 0 ) ) )
1415
1415
}
1416
- ast:: Pat :: IdentPat ( p) => {
1417
- let name =
1418
- p. name ( ) . map ( |nr| nr. as_name ( ) ) . unwrap_or_else ( Name :: missing) ;
1419
- Some ( Box :: new ( LiteralOrConst :: Const ( name. into ( ) ) ) )
1416
+ pat @ ( ast:: Pat :: IdentPat ( _) | ast:: Pat :: PathPat ( _) ) => {
1417
+ let subpat = self . collect_pat ( pat. clone ( ) , binding_list) ;
1418
+ Some ( Box :: new ( LiteralOrConst :: Const ( subpat) ) )
1420
1419
}
1421
- ast:: Pat :: PathPat ( p) => p
1422
- . path ( )
1423
- . and_then ( |path| self . expander . parse_path ( self . db , path) )
1424
- . map ( LiteralOrConst :: Const )
1425
- . map ( Box :: new) ,
1426
1420
_ => None ,
1427
1421
} )
1428
1422
} ;
Original file line number Diff line number Diff line change @@ -635,7 +635,7 @@ impl Printer<'_> {
635
635
fn print_literal_or_const ( & mut self , literal_or_const : & LiteralOrConst ) {
636
636
match literal_or_const {
637
637
LiteralOrConst :: Literal ( l) => self . print_literal ( l) ,
638
- LiteralOrConst :: Const ( c) => self . print_path ( c) ,
638
+ LiteralOrConst :: Const ( c) => self . print_pat ( * c) ,
639
639
}
640
640
}
641
641
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ pub enum Literal {
101
101
/// Used in range patterns.
102
102
pub enum LiteralOrConst {
103
103
Literal ( Literal ) ,
104
- Const ( Path ) ,
104
+ Const ( PatId ) ,
105
105
}
106
106
107
107
impl Literal {
You can’t perform that action at this time.
0 commit comments