mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(ast): allow conversion from Expression into Statement with FromIn trait. (#4124)
Our downstream rolldown is using this, If we want them to adopt our traits we should provide this implementation for them.
2cd2a367ee/crates/rolldown_ecmascript/src/allocator_helpers/into_in.rs (L24)
This commit is contained in:
parent
b936162093
commit
485c871e8d
1 changed files with 11 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue