@@ -237,6 +237,8 @@ impl StmtOrModuleItem for ModuleItem {
237
237
match self {
238
238
ModuleItem :: ModuleDecl ( v) => Err ( v) ,
239
239
ModuleItem :: Stmt ( v) => Ok ( v) ,
240
+ #[ cfg( feature = "unknown" ) ]
241
+ _ => panic ! ( "unable to access unknown nodes" )
240
242
}
241
243
}
242
244
@@ -245,6 +247,8 @@ impl StmtOrModuleItem for ModuleItem {
245
247
match self {
246
248
ModuleItem :: ModuleDecl ( v) => Err ( v) ,
247
249
ModuleItem :: Stmt ( v) => Ok ( v) ,
250
+ #[ cfg( feature = "unknown" ) ]
251
+ _ => panic ! ( "unable to access unknown nodes" )
248
252
}
249
253
}
250
254
@@ -253,6 +257,8 @@ impl StmtOrModuleItem for ModuleItem {
253
257
match self {
254
258
ModuleItem :: ModuleDecl ( v) => Err ( v) ,
255
259
ModuleItem :: Stmt ( v) => Ok ( v) ,
260
+ #[ cfg( feature = "unknown" ) ]
261
+ _ => panic ! ( "unable to access unknown nodes" )
256
262
}
257
263
}
258
264
@@ -1199,6 +1205,8 @@ impl Visit for LiteralVisitor {
1199
1205
}
1200
1206
PropName :: BigInt ( _) => self . is_lit = false ,
1201
1207
PropName :: Computed ( ..) => self . is_lit = false ,
1208
+ #[ cfg( feature = "unknown" ) ]
1209
+ _ => ( ) ,
1202
1210
}
1203
1211
}
1204
1212
@@ -1260,6 +1268,8 @@ pub fn is_simple_pure_member_expr(m: &MemberExpr, pure_getters: bool) -> bool {
1260
1268
MemberProp :: Computed ( c) => {
1261
1269
is_simple_pure_expr ( & c. expr , pure_getters) && is_simple_pure_expr ( & m. obj , pure_getters)
1262
1270
}
1271
+ #[ cfg( feature = "unknown" ) ]
1272
+ _ => false
1263
1273
}
1264
1274
}
1265
1275
@@ -1423,6 +1433,8 @@ pub fn prop_name_to_expr(p: PropName) -> Expr {
1423
1433
PropName :: Num ( n) => Lit :: Num ( n) . into ( ) ,
1424
1434
PropName :: BigInt ( b) => Lit :: BigInt ( b) . into ( ) ,
1425
1435
PropName :: Computed ( c) => * c. expr ,
1436
+ #[ cfg( feature = "unknown" ) ]
1437
+ _ => panic ! ( "unable to access unknown nodes" )
1426
1438
}
1427
1439
}
1428
1440
/// Similar to `prop_name_to_expr`, but used for value position.
@@ -1440,6 +1452,8 @@ pub fn prop_name_to_expr_value(p: PropName) -> Expr {
1440
1452
PropName :: Num ( n) => Lit :: Num ( n) . into ( ) ,
1441
1453
PropName :: BigInt ( b) => Lit :: BigInt ( b) . into ( ) ,
1442
1454
PropName :: Computed ( c) => * c. expr ,
1455
+ #[ cfg( feature = "unknown" ) ]
1456
+ _ => panic ! ( "unable to access unknown nodes" )
1443
1457
}
1444
1458
}
1445
1459
@@ -1459,6 +1473,8 @@ pub fn prop_name_to_member_prop(prop_name: PropName) -> MemberProp {
1459
1473
span : DUMMY_SP ,
1460
1474
expr : b. into ( ) ,
1461
1475
} ) ,
1476
+ #[ cfg( feature = "unknown" ) ]
1477
+ _ => panic ! ( "unable to access unknown nodes" )
1462
1478
}
1463
1479
}
1464
1480
@@ -1930,11 +1946,15 @@ impl ExprCtx {
1930
1946
Prop :: Assign ( ..) => {
1931
1947
unreachable ! ( "assign property in object literal is not a valid syntax" )
1932
1948
}
1949
+ #[ cfg( feature = "unknown" ) ]
1950
+ _ => true ,
1933
1951
} ,
1934
1952
PropOrSpread :: Spread ( SpreadElement { .. } ) => {
1935
1953
has_spread = true ;
1936
1954
true
1937
- }
1955
+ } ,
1956
+ #[ cfg( feature = "unknown" ) ]
1957
+ _ => true ,
1938
1958
} ) ;
1939
1959
1940
1960
if has_spread {
@@ -1962,6 +1982,8 @@ impl ExprCtx {
1962
1982
"assign property in object literal is not a valid syntax"
1963
1983
)
1964
1984
}
1985
+ #[ cfg( feature = "unknown" ) ]
1986
+ _ => panic ! ( "unable to access unknown nodes" )
1965
1987
} ,
1966
1988
_ => unreachable ! ( ) ,
1967
1989
} )
@@ -2007,6 +2029,8 @@ impl ExprCtx {
2007
2029
Expr :: OptChain ( ..) => to. push ( Box :: new ( expr) ) ,
2008
2030
2009
2031
Expr :: Invalid ( ..) => unreachable ! ( ) ,
2032
+ #[ cfg( feature = "unknown" ) ]
2033
+ _ => to. push ( Box :: new ( expr) ) ,
2010
2034
}
2011
2035
}
2012
2036
}
@@ -2021,6 +2045,8 @@ pub fn prop_name_eq(p: &PropName, key: &str) -> bool {
2021
2045
Expr :: Lit ( Lit :: Str ( Str { value, .. } ) ) => * value == * key,
2022
2046
_ => false ,
2023
2047
} ,
2048
+ #[ cfg( feature = "unknown" ) ]
2049
+ _ => false ,
2024
2050
}
2025
2051
}
2026
2052
@@ -2364,6 +2390,8 @@ impl VisitMut for IdentRenamer<'_> {
2364
2390
}
2365
2391
}
2366
2392
ModuleExportName :: Str ( _) => { }
2393
+ #[ cfg( feature = "unknown" ) ]
2394
+ _ => { } ,
2367
2395
}
2368
2396
}
2369
2397
@@ -2515,6 +2543,8 @@ where
2515
2543
JSXElementName :: Ident ( ident) => ident. into ( ) ,
2516
2544
JSXElementName :: JSXMemberExpr ( expr) => Box :: new ( expr) . into ( ) ,
2517
2545
JSXElementName :: JSXNamespacedName ( ..) => unimplemented ! ( ) ,
2546
+ #[ cfg( feature = "unknown" ) ]
2547
+ _ => return ,
2518
2548
}
2519
2549
}
2520
2550
}
@@ -2949,6 +2979,8 @@ fn cast_to_bool(expr: &Expr, ctx: ExprCtx) -> (Purity, BoolValue) {
2949
2979
Lit :: Null ( ..) => false ,
2950
2980
Lit :: Regex ( ..) => true ,
2951
2981
Lit :: JSXText ( ..) => unreachable ! ( "as_bool() for JSXText" ) ,
2982
+ #[ cfg( feature = "unknown" ) ]
2983
+ _ => return ( Pure , Unknown ) ,
2952
2984
} ) ,
2953
2985
) ;
2954
2986
}
@@ -3506,6 +3538,8 @@ fn may_have_side_effects(expr: &Expr, ctx: ExprCtx) -> bool {
3506
3538
} ) => true ,
3507
3539
_ => false ,
3508
3540
} ,
3541
+ #[ cfg( feature = "unknown" ) ]
3542
+ _ => true ,
3509
3543
} ;
3510
3544
if obj. props . iter ( ) . any ( can_have_side_effect) {
3511
3545
return true ;
@@ -3517,6 +3551,8 @@ fn may_have_side_effects(expr: &Expr, ctx: ExprCtx) -> bool {
3517
3551
match prop {
3518
3552
MemberProp :: Computed ( c) => c. expr . may_have_side_effects ( ctx) ,
3519
3553
MemberProp :: Ident ( _) | MemberProp :: PrivateName ( _) => false ,
3554
+ #[ cfg( feature = "unknown" ) ]
3555
+ _ => true ,
3520
3556
}
3521
3557
}
3522
3558
@@ -3590,9 +3626,13 @@ fn may_have_side_effects(expr: &Expr, ctx: ExprCtx) -> bool {
3590
3626
_ => false ,
3591
3627
} ,
3592
3628
Prop :: Assign ( _) => true ,
3629
+ #[ cfg( feature = "unknown" ) ]
3630
+ _ => true ,
3593
3631
} ,
3594
3632
// may trigger getter
3595
3633
PropOrSpread :: Spread ( _) => true ,
3634
+ #[ cfg( feature = "unknown" ) ]
3635
+ _ => true ,
3596
3636
} ) ,
3597
3637
3598
3638
Expr :: JSXMember ( ..)
@@ -3608,6 +3648,8 @@ fn may_have_side_effects(expr: &Expr, ctx: ExprCtx) -> bool {
3608
3648
| Expr :: TsSatisfies ( TsSatisfiesExpr { ref expr, .. } ) => expr. may_have_side_effects ( ctx) ,
3609
3649
3610
3650
Expr :: Invalid ( ..) => true ,
3651
+ #[ cfg( feature = "unknown" ) ]
3652
+ _ => true ,
3611
3653
}
3612
3654
}
3613
3655
0 commit comments