Skip to content

Commit

Permalink
refactor(estree/compat): Do not use nightly features (#9772)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #9770
  • Loading branch information
kdy1 authored Dec 2, 2024
1 parent 0adad25 commit 0f12bbd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/curvy-icons-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_estree_compat: patch
swc_core: patch
---

refactor(estree/compat): Do not use nightly features
5 changes: 4 additions & 1 deletion crates/swc_estree_compat/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 8 additions & 8 deletions crates/swc_estree_compat/src/swcify/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr>;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -1083,47 +1083,47 @@ 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")
}
}

impl Swcify for DoExpression {
type Output = !;
type Output = Never;

fn swcify(self, _: &Context) -> Self::Output {
panic!("swc does not support do expressions")
}
}

impl Swcify for PipelinePrimaryTopicReference {
type Output = !;
type Output = Never;

fn swcify(self, _: &Context) -> Self::Output {
panic!("swc does not support `PipelinePrimaryTopicReference`")
}
}

impl Swcify for RecordExpression {
type Output = !;
type Output = Never;

fn swcify(self, _: &Context) -> Self::Output {
panic!("swc does not support record expressions")
}
}

impl Swcify for TupleExpression {
type Output = !;
type Output = Never;

fn swcify(self, _: &Context) -> Self::Output {
panic!("swc does not support tuple expressions")
}
}

impl Swcify for ModuleExpression {
type Output = !;
type Output = Never;

fn swcify(self, _: &Context) -> Self::Output {
panic!("swc does not support module expressions")
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_estree_compat/src/swcify/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down

0 comments on commit 0f12bbd

Please sign in to comment.