Skip to content

Commit 0c129c5

Browse files
committed
make ecma_compat
1 parent 4528ca5 commit 0c129c5

File tree

27 files changed

+141
-1
lines changed

27 files changed

+141
-1
lines changed

crates/swc_ecma_compat_common/src/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ macro_rules! impl_visit_mut_fn {
4444
})],
4545
..Default::default()
4646
},
47+
_ => panic!("unable to access unknown nodes"),
4748
},
4849
);
4950

crates/swc_ecma_compat_es2015/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ version = "29.0.0"
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

15+
[features]
16+
unknown = ["swc_ecma_transforms_base/unknown"]
17+
1518
[dependencies]
1619
arrayvec = { workspace = true }
1720
indexmap = { workspace = true }

crates/swc_ecma_compat_es2015/src/arrow.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ impl VisitMut for Arrow {
158158
})],
159159
..Default::default()
160160
},
161+
#[cfg(feature = "unknown")]
162+
_ => panic!("unable to access unknown nodes"),
161163
}),
162164
..Default::default()
163165
}

crates/swc_ecma_compat_es2015/src/block_scoping/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ impl VisitMut for FlowHelper<'_> {
700700
self.check(id);
701701
}
702702
}
703+
#[cfg(feature = "unknown")]
704+
_ => panic!("unable to access unknown nodes"),
703705
}
704706

705707
n.visit_mut_children_with(self);

crates/swc_ecma_compat_es2015/src/block_scoping/vars.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ impl VisitMut for BlockScopedVars {
252252
BlockStmtOrExpr::Expr(b) => {
253253
b.visit_mut_with(v);
254254
}
255+
#[cfg(feature = "unknown")]
256+
_ => panic!("unable to access unknown nodes"),
255257
}
256258
});
257259
}

crates/swc_ecma_compat_es2015/src/classes/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,10 @@ impl Classes {
519519
| ClassMember::TsIndexSignature(..)
520520
| ClassMember::StaticBlock(..)
521521
| ClassMember::AutoAccessor(..) => {}
522-
ClassMember::Empty(..) => {}
522+
ClassMember::Empty(..) => {},
523+
524+
#[cfg(feature = "unknown")]
525+
_ => panic!("unable to access unknown nodes"),
523526
}
524527
}
525528

@@ -632,6 +635,8 @@ impl Classes {
632635
}
633636
.into(),
634637
PropName::Computed(c) => c.expr,
638+
#[cfg(feature = "unknown")]
639+
_ => panic!("unable to access unknown nodes"),
635640
},
636641
}))
637642
}
@@ -657,6 +662,8 @@ impl Classes {
657662
.into(),
658663
}),
659664
PropName::Computed(c) => MemberProp::Computed(c),
665+
#[cfg(feature = "unknown")]
666+
_ => panic!("unable to access unknown nodes"),
660667
}
661668
}
662669

@@ -832,6 +839,8 @@ impl Classes {
832839
data.set = None;
833840
data.method = Some(value)
834841
}
842+
#[cfg(feature = "unknown")]
843+
_ => panic!("unable to access unknown nodes"),
835844
}
836845
}
837846

crates/swc_ecma_compat_es2015/src/classes/prop_name.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ impl From<&PropName> for HashKey {
1818
PropName::Num(Number { value, .. }) => HashKey::Str(value.to_string().into()),
1919
PropName::BigInt(BigInt { value, .. }) => HashKey::Str(value.to_string().into()),
2020
PropName::Computed(expr) => HashKey::Computed(expr.span()),
21+
#[cfg(feature = "unknown")]
22+
_ => panic!("unable to access unknown nodes"),
2123
}
2224
}
2325
}
@@ -36,6 +38,8 @@ pub fn is_pure_prop_name(p: &PropName) -> bool {
3638
Expr::Tpl(tpl) => tpl.exprs.is_empty(),
3739
_ => false,
3840
},
41+
#[cfg(feature = "unknown")]
42+
_ => false,
3943
}
4044
}
4145

crates/swc_ecma_compat_es2015/src/computed_props.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@ impl VisitMut for ComputedProps {
249249
}
250250
.into(),
251251
),
252+
#[cfg(feature = "unknown")]
253+
_ => panic!("unable to access unknown nodes"),
252254
},
253255
PropOrSpread::Spread(..) => unimplemented!("computed spread property"),
256+
#[cfg(feature = "unknown")]
257+
_ => panic!("unable to access unknown nodes"),
254258
};
255259

256260
if !self.c.loose && props_cnt == 1 {
@@ -425,6 +429,8 @@ fn prop_name_to_expr(p: PropName, loose: bool) -> (Expr, bool) {
425429
PropName::Num(n) => (Lit::Num(n).into(), true),
426430
PropName::BigInt(b) => (Lit::BigInt(b).into(), true),
427431
PropName::Computed(c) => (*c.expr, true),
432+
#[cfg(feature = "unknown")]
433+
_ => panic!("unable to access unknown nodes"),
428434
}
429435
}
430436

crates/swc_ecma_compat_es2015/src/destructuring.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ macro_rules! impl_for_for_stmt {
124124
ForHead::UsingDecl(..) => {
125125
unreachable!("using declaration must be removed by previous pass")
126126
}
127+
128+
#[cfg(feature = "unknown")]
129+
_ => panic!("unable to access unknown nodes"),
127130
};
128131

129132
for_stmt.left = left;
@@ -420,6 +423,8 @@ impl AssignFolder {
420423
"Object rest pattern should be removed by es2018::object_rest_spread \
421424
pass"
422425
),
426+
#[cfg(feature = "unknown")]
427+
_ => panic!("unable to access unknown nodes"),
423428
}
424429
}
425430
}
@@ -520,6 +525,8 @@ impl Destructuring {
520525
}
521526
Pat::Rest(..) | Pat::Expr(..) => params.push(param),
522527
Pat::Invalid(..) => {}
528+
#[cfg(feature = "unknown")]
529+
_ => panic!("unable to access unknown nodes"),
523530
}
524531
}
525532

@@ -1004,6 +1011,8 @@ impl VisitMut for AssignFolder {
10041011
"object rest pattern should be removed by \
10051012
es2018::object_rest_spread pass"
10061013
),
1014+
#[cfg(feature = "unknown")]
1015+
_ => panic!("unable to access unknown nodes"),
10071016
}
10081017
}
10091018

@@ -1018,6 +1027,8 @@ impl VisitMut for AssignFolder {
10181027
}
10191028

10201029
AssignTargetPat::Invalid(..) => unreachable!(),
1030+
#[cfg(feature = "unknown")]
1031+
_ => panic!("unable to access unknown nodes"),
10211032
}
10221033
};
10231034
}
@@ -1295,6 +1306,8 @@ fn can_be_null(e: &Expr) -> bool {
12951306
| Expr::TsSatisfies(TsSatisfiesExpr { ref expr, .. }) => can_be_null(expr),
12961307

12971308
Expr::Invalid(..) => unreachable!(),
1309+
#[cfg(feature = "unknown")]
1310+
_ => panic!("unable to access unknown nodes"),
12981311
}
12991312
}
13001313

crates/swc_ecma_compat_es2015/src/for_of.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ impl ForOf {
185185
ForHead::UsingDecl(..) => {
186186
unreachable!("using declaration must be removed by previous pass")
187187
}
188+
189+
#[cfg(feature = "unknown")]
190+
_ => panic!("unable to access unknown nodes"),
188191
}
189192

190193
let stmt = ForStmt {
@@ -286,6 +289,9 @@ impl ForOf {
286289
ForHead::UsingDecl(..) => {
287290
unreachable!("using declaration must be removed by previous pass")
288291
}
292+
293+
#[cfg(feature = "unknown")]
294+
_ => panic!("unable to access unknown nodes"),
289295
}
290296

291297
// !(_step = _iterator()).done;
@@ -377,6 +383,8 @@ impl ForOf {
377383
ForHead::UsingDecl(..) => {
378384
unreachable!("using declaration must be removed by previous pass")
379385
}
386+
#[cfg(feature = "unknown")]
387+
_ => panic!("unable to access unknown nodes"),
380388
},
381389
);
382390

0 commit comments

Comments
 (0)