From 0f12bbdcaeae3538cabe04db125ac5824da42bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 2 Dec 2024 10:38:51 +0900 Subject: [PATCH] refactor(estree/compat): Do not use nightly features (#9772) **Related issue:** - Closes https://github.com/swc-project/swc/issues/9770 --- .changeset/curvy-icons-drum.md | 6 ++++++ crates/swc_estree_compat/src/lib.rs | 5 ++++- crates/swc_estree_compat/src/swcify/expr.rs | 16 ++++++++-------- .../swc_estree_compat/src/swcify/typescript.rs | 4 ++-- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 .changeset/curvy-icons-drum.md diff --git a/.changeset/curvy-icons-drum.md b/.changeset/curvy-icons-drum.md new file mode 100644 index 000000000000..475d4b815369 --- /dev/null +++ b/.changeset/curvy-icons-drum.md @@ -0,0 +1,6 @@ +--- +swc_estree_compat: patch +swc_core: patch +--- + +refactor(estree/compat): Do not use nightly features diff --git a/crates/swc_estree_compat/src/lib.rs b/crates/swc_estree_compat/src/lib.rs index 7913cf09e2d5..10ae1b7dafd3 100644 --- a/crates/swc_estree_compat/src/lib.rs +++ b/crates/swc_estree_compat/src/lib.rs @@ -1,7 +1,10 @@ #![deny(clippy::all)] #![allow(clippy::large_enum_variant)] #![allow(clippy::upper_case_acronyms)] -#![feature(never_type)] + +use std::convert::Infallible; pub mod babelify; pub mod swcify; + +pub type Never = Infallible; diff --git a/crates/swc_estree_compat/src/swcify/expr.rs b/crates/swc_estree_compat/src/swcify/expr.rs index dc50d6c6e48e..e55774f17802 100644 --- a/crates/swc_estree_compat/src/swcify/expr.rs +++ b/crates/swc_estree_compat/src/swcify/expr.rs @@ -27,7 +27,7 @@ use swc_estree_ast::{ }; use super::Context; -use crate::swcify::Swcify; +use crate::{swcify::Swcify, Never}; impl Swcify for Expression { type Output = Box; @@ -819,7 +819,7 @@ impl Swcify for OptionalCallExpression { } impl Swcify for TypeCastExpression { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { unimplemented!("flow type cast") @@ -1083,7 +1083,7 @@ impl Swcify for swc_estree_ast::JSXClosingFragment { } impl Swcify for BindExpression { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { panic!("swc does not support bind expressions") @@ -1091,7 +1091,7 @@ impl Swcify for BindExpression { } impl Swcify for DoExpression { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { panic!("swc does not support do expressions") @@ -1099,7 +1099,7 @@ impl Swcify for DoExpression { } impl Swcify for PipelinePrimaryTopicReference { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { panic!("swc does not support `PipelinePrimaryTopicReference`") @@ -1107,7 +1107,7 @@ impl Swcify for PipelinePrimaryTopicReference { } impl Swcify for RecordExpression { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { panic!("swc does not support record expressions") @@ -1115,7 +1115,7 @@ impl Swcify for RecordExpression { } impl Swcify for TupleExpression { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { panic!("swc does not support tuple expressions") @@ -1123,7 +1123,7 @@ impl Swcify for TupleExpression { } impl Swcify for ModuleExpression { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { panic!("swc does not support module expressions") diff --git a/crates/swc_estree_compat/src/swcify/typescript.rs b/crates/swc_estree_compat/src/swcify/typescript.rs index 22c5d692e5b1..227be9145351 100644 --- a/crates/swc_estree_compat/src/swcify/typescript.rs +++ b/crates/swc_estree_compat/src/swcify/typescript.rs @@ -9,7 +9,7 @@ use swc_estree_ast::{ }; use super::Context; -use crate::swcify::Swcify; +use crate::{swcify::Swcify, Never}; impl Swcify for TSTypeParameterInstantiation { type Output = TsTypeParamInstantiation; @@ -23,7 +23,7 @@ impl Swcify for TSTypeParameterInstantiation { } impl Swcify for FlowType { - type Output = !; + type Output = Never; fn swcify(self, _: &Context) -> Self::Output { unreachable!("swc does not support flow types")