diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index 808493494c378..ca37f8deded42 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -5,8 +5,8 @@ use crate::ast::*; use std::{cell::Cell, fmt, hash::Hash}; -use oxc_allocator::{Box, Vec}; -use oxc_span::{Atom, CompactStr, SourceType, Span}; +use oxc_allocator::{Box, FromIn, Vec}; +use oxc_span::{Atom, CompactStr, GetSpan, SourceType, Span}; use oxc_syntax::{ operator::UnaryOperator, reference::{ReferenceFlag, ReferenceId}, @@ -665,6 +665,15 @@ impl<'a> Statement<'a> { } } +impl<'a> FromIn<'a, Expression<'a>> for Statement<'a> { + fn from_in(expression: Expression<'a>, alloc: &'a oxc_allocator::Allocator) -> Self { + Statement::ExpressionStatement(Box::from_in( + ExpressionStatement { span: expression.span(), expression }, + alloc, + )) + } +} + impl<'a> Directive<'a> { /// A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either of the exact code point sequences "use strict" or 'use strict'. /// A Use Strict Directive may not contain an EscapeSequence or LineContinuation.