Skip to content

Commit

Permalink
Update swc_core
Browse files Browse the repository at this point in the history
Closes GH-59.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
kdy1 authored Dec 9, 2024
1 parent 4cd0631 commit af5ed09
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ serializable = ["serde"]
[dependencies]
markdown = "=1.0.0-alpha.21"
serde = { version = "1", optional = true }
swc_core = { version = "5", features = [
swc_core = { version = "9", features = [
"common",
"ecma_ast",
"ecma_codegen",
Expand Down
16 changes: 8 additions & 8 deletions src/mdx_plugin_recma_jsx_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct State<'a> {
explicit_jsxs: FxHashSet<Span>,
}

impl<'a> State<'a> {
impl State<'_> {
/// Open a new scope.
fn enter(&mut self, info: Option<Info>) {
self.scopes.push(Scope {
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<'a> State<'a> {
// ```jsx
// props.components
// ```
if is_props_receiving_fn(&info.name) {
if is_props_receiving_fn(info.name.as_deref()) {
let member = MemberExpr {
obj: Box::new(create_ident_expression("props")),
prop: MemberProp::Ident(create_ident("components")),
Expand Down Expand Up @@ -552,7 +552,7 @@ impl<'a> State<'a> {
}

/// Reference a component or object name.
fn ref_dynamic(&mut self, path: &[String], component: bool, position: &Option<Position>) {
fn ref_dynamic(&mut self, path: &[String], component: bool, position: Option<&Position>) {
let scope = self.current_top_level_info().expect("expected scope");
let name = path.join(".");
let existing = scope.dynamic.iter_mut().find(|d| d.name == name);
Expand All @@ -565,7 +565,7 @@ impl<'a> State<'a> {
let dynamic = Dynamic {
name,
component,
position: position.clone(),
position: position.cloned(),
};

scope.dynamic.push(dynamic);
Expand All @@ -592,7 +592,7 @@ impl<'a> State<'a> {
// If there is a top-level, non-global, scope which is a function:
if let Some(info) = self.current_top_level_info() {
// Rewrite only if we can rewrite.
if is_props_receiving_fn(&info.name) || self.provider {
if is_props_receiving_fn(info.name.as_deref()) || self.provider {
debug_assert!(!ids.is_empty(), "expected non-empty ids");
let explicit_jsx = self.explicit_jsxs.contains(&span);
let mut path = ids.to_owned();
Expand All @@ -611,7 +611,7 @@ impl<'a> State<'a> {
// Component or object not in scope.
let mut index = 1;
while index <= path.len() {
self.ref_dynamic(&path[0..index], index == ids.len(), &position);
self.ref_dynamic(&path[0..index], index == ids.len(), position.as_ref());
index += 1;
}
}
Expand Down Expand Up @@ -691,7 +691,7 @@ impl<'a> State<'a> {
}
}

impl<'a> VisitMut for State<'a> {
impl VisitMut for State<'_> {
noop_visit_mut_type!();

/// Rewrite JSX identifiers.
Expand Down Expand Up @@ -999,7 +999,7 @@ fn create_error_helper(development: bool, path: Option<String>) -> ModuleItem {
}

/// Check if this function is a props receiving component: it’s one of ours.
fn is_props_receiving_fn(name: &Option<String>) -> bool {
fn is_props_receiving_fn(name: Option<&str>) -> bool {
if let Some(name) = name {
name == "_createMdxContent" || name == "MDXContent"
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/swc_util_build_jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ struct State<'a> {
fragment_expression: Expr,
}

impl<'a> State<'a> {
impl State<'_> {
/// Turn an attribute value into an expression.
fn jsx_attribute_value_to_expression(
&mut self,
Expand Down Expand Up @@ -590,7 +590,7 @@ impl<'a> State<'a> {
}
}

impl<'a> VisitMut for State<'a> {
impl VisitMut for State<'_> {
noop_visit_mut_type!();

/// Visit expressions, rewriting JSX, and walking deeper.
Expand Down
2 changes: 1 addition & 1 deletion src/swc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct RewriteStopsContext<'a> {
pub location: Option<&'a Location>,
}

impl<'a> VisitMut for RewriteStopsContext<'a> {
impl VisitMut for RewriteStopsContext<'_> {
noop_visit_mut_type!();

/// Rewrite spans.
Expand Down

0 comments on commit af5ed09

Please sign in to comment.