File tree Expand file tree Collapse file tree 3 files changed +11
-14
lines changed
swc_ecma_compat_es2020/src Expand file tree Collapse file tree 3 files changed +11
-14
lines changed Original file line number Diff line number Diff line change 11use swc_ecma_ast:: Pass ;
2+ pub use swc_ecma_compiler:: es2020:: nullish_coalescing:: Config ;
23use swc_ecma_compiler:: { Compiler , Features } ;
34use swc_ecma_transforms_base:: assumptions:: Assumptions ;
45
5- pub use swc_ecma_compiler:: es2020:: nullish_coalescing:: Config ;
6-
76pub fn nullish_coalescing ( c : Config ) -> impl Pass {
87 let mut assumptions = Assumptions :: default ( ) ;
98 assumptions. no_document_all = c. no_document_all ;
@@ -14,4 +13,4 @@ pub fn nullish_coalescing(c: Config) -> impl Pass {
1413 assumptions,
1514 ..Default :: default ( )
1615 } )
17- }
16+ }
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ pub struct Config {
1414}
1515
1616impl < ' a > CompilerImpl < ' a > {
17- /// Transform nullish coalescing binary expressions (??) to conditional expressions
17+ /// Transform nullish coalescing binary expressions (??) to conditional
18+ /// expressions
1819 pub ( crate ) fn transform_nullish_coalescing_bin_expr ( & mut self , e : & mut Expr ) -> bool {
1920 if let Expr :: Bin ( BinExpr {
2021 span,
@@ -52,7 +53,8 @@ impl<'a> CompilerImpl<'a> {
5253 false
5354 }
5455
55- /// Transform nullish coalescing assignment expressions (??=) to assignment expressions
56+ /// Transform nullish coalescing assignment expressions (??=) to assignment
57+ /// expressions
5658 pub ( crate ) fn transform_nullish_coalescing_assign_expr ( & mut self , e : & mut Expr ) -> bool {
5759 if let Expr :: Assign ( ref mut assign @ AssignExpr { op : op ! ( "??=" ) , .. } ) = e {
5860 match & mut assign. left {
@@ -242,4 +244,4 @@ impl<'a> CompilerImpl<'a> {
242244 }
243245 . into ( )
244246 }
245- }
247+ }
Original file line number Diff line number Diff line change @@ -603,10 +603,8 @@ impl<'a> VisitMut for CompilerImpl<'a> {
603603
604604 // Post-processing: Handle variable hoisting
605605 if need_var_hoisting {
606- let logical_vars = std:: mem:: replace (
607- & mut self . es2021_logical_assignment_vars ,
608- saved_logical_vars,
609- ) ;
606+ let logical_vars =
607+ std:: mem:: replace ( & mut self . es2021_logical_assignment_vars , saved_logical_vars) ;
610608
611609 if !logical_vars. is_empty ( ) {
612610 prepend_stmt (
@@ -666,10 +664,8 @@ impl<'a> VisitMut for CompilerImpl<'a> {
666664
667665 // Post-processing: Handle variable hoisting
668666 if need_var_hoisting {
669- let logical_vars = std:: mem:: replace (
670- & mut self . es2021_logical_assignment_vars ,
671- saved_logical_vars,
672- ) ;
667+ let logical_vars =
668+ std:: mem:: replace ( & mut self . es2021_logical_assignment_vars , saved_logical_vars) ;
673669
674670 if !logical_vars. is_empty ( ) {
675671 prepend_stmt (
You can’t perform that action at this time.
0 commit comments