Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::{
utils::{AstPathRange, unparen},
};

#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct EffectsBlock {
pub effects: Vec<Effect>,
pub range: AstPathRange,
Expand All @@ -47,7 +47,7 @@ impl EffectsBlock {
}
}

#[derive(Debug, Clone)]
#[derive(Debug)]
pub enum ConditionalKind {
/// The blocks of an `if` statement without an `else` block.
If { then: Box<EffectsBlock> },
Expand Down Expand Up @@ -117,7 +117,7 @@ impl ConditionalKind {
}
}

#[derive(Debug, Clone)]
#[derive(Debug)]
pub enum EffectArg {
Value(JsValue),
Closure(JsValue, Box<EffectsBlock>),
Expand All @@ -140,7 +140,7 @@ impl EffectArg {
}
}

#[derive(Debug, Clone)]
#[derive(Debug)]
pub enum Effect {
/// Some condition which affects which effects might be executed. If the
/// condition evaluates to some compile-time constant, we can use that
Expand Down Expand Up @@ -2428,14 +2428,16 @@ impl VisitAstPath for Analyzer<'_> {
self.effects.append(&mut block);
self.effects.append(&mut handler);
if let Some(finalizer) = stmt.finalizer.as_ref() {
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::TryStmt(stmt, TryStmtField::Finalizer));
finalizer.visit_with_ast_path(self, &mut ast_path);
{
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::TryStmt(stmt, TryStmtField::Finalizer));
finalizer.visit_with_ast_path(self, &mut ast_path);
}
// If a finally block early returns the parent block does too.
if self.end_early_return_block() {
self.early_return_stack.push(EarlyReturn::Always {
prev_effects: take(&mut self.effects),
start_ast_path: as_parent_path(&ast_path),
start_ast_path: as_parent_path(ast_path),
});
}
};
Expand Down
4 changes: 3 additions & 1 deletion turbopack/crates/turbopack-ecmascript/src/code_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ impl_modify!(visit_mut_block_stmt, BlockStmt);
impl_modify!(visit_mut_switch_case, SwitchCase);
impl_modify!(visit_mut_program, Program);

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub enum CodeGen {
// AMD occurs very rarely and makes the enum much bigger
AmdDefineWithDependenciesCodeGen(Box<AmdDefineWithDependenciesCodeGen>),
Expand Down
6 changes: 5 additions & 1 deletion turbopack/crates/turbopack-ecmascript/src/references/amd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl ChunkableModuleReference for AmdDefineAssetReference {}
TraceRawVcs,
Clone,
NonLocalValue,
Hash,
)]
pub enum AmdDefineDependencyElement {
Request {
Expand All @@ -120,14 +121,17 @@ pub enum AmdDefineDependencyElement {
Copy,
Clone,
NonLocalValue,
Hash,
)]
pub enum AmdDefineFactoryType {
Unknown,
Function,
Value,
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct AmdDefineWithDependenciesCodeGen {
dependencies_requests: Vec<AmdDefineDependencyElement>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
Expand Down
12 changes: 9 additions & 3 deletions turbopack/crates/turbopack-ecmascript/src/references/cjs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ impl IntoCodeGenReference for CjsRequireAssetReference {
}
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct CjsRequireAssetReferenceCodeGen {
reference: ResolvedVc<CjsRequireAssetReference>,
path: AstPath,
Expand Down Expand Up @@ -274,7 +276,9 @@ impl IntoCodeGenReference for CjsRequireResolveAssetReference {
}
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct CjsRequireResolveAssetReferenceCodeGen {
reference: ResolvedVc<CjsRequireResolveAssetReference>,
path: AstPath,
Expand Down Expand Up @@ -334,7 +338,9 @@ impl CjsRequireResolveAssetReferenceCodeGen {
}
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash,
)]
pub struct CjsRequireCacheAccess {
pub path: AstPath,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub enum ConstantConditionValue {
Nullish,
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash,
)]
pub struct ConstantConditionCodeGen {
value: ConstantConditionValue,
path: AstPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ use crate::{
create_visitor,
};

#[derive(PartialEq, Eq, TraceRawVcs, Serialize, Deserialize, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, TraceRawVcs, Serialize, Deserialize, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
enum DynamicExpressionType {
Promise,
Normal,
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash,
)]
pub struct DynamicExpression {
path: AstPath,
ty: DynamicExpressionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ impl IntoCodeGenReference for EsmAsyncAssetReference {
}
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct EsmAsyncAssetReferenceCodeGen {
path: AstPath,
reference: ResolvedVc<EsmAsyncAssetReference>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::{
/// in the file. But we must only initialize the binding a single time.
///
/// This singleton behavior must be enforced by the caller!
#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash,
)]
pub struct ImportMetaBinding {
path: FileSystemPath,
}
Expand Down Expand Up @@ -85,7 +87,9 @@ impl From<ImportMetaBinding> for CodeGen {
///
/// There can be many references to import.meta, and they appear at any nesting
/// in the file. But all references refer to the same mutable object.
#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct ImportMetaRef {
ast_path: AstPath,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ impl IntoCodeGenReference for EsmModuleIdAssetReference {
}
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct EsmModuleIdAssetReferenceCodeGen {
path: AstPath,
reference: ResolvedVc<EsmModuleIdAssetReference>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use crate::{
/// Makes code changes to remove export/import declarations and places the
/// expr/decl in a normal statement. Unnamed expr/decl will be named with the
/// magic identifier "export default"
#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash,
)]
pub struct EsmModuleItem {
pub path: AstPath,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl IntoCodeGenReference for UrlAssetReference {
}
}

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct UrlAssetReferenceCodeGen {
reference: ResolvedVc<UrlAssetReference>,
path: AstPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use crate::{
/// initialize the binding a single time.
///
/// This singleton behavior must be enforced by the caller!
#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct ExportsInfoBinding {}

impl ExportsInfoBinding {
Expand Down Expand Up @@ -89,7 +91,9 @@ impl From<ExportsInfoBinding> for CodeGen {
///
/// There can be many references, and they appear at any nesting in the file. But all references
/// refer to the same mutable object.
#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct ExportsInfoRef {
ast_path: AstPath,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use crate::{
create_visitor,
};

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash,
)]
pub struct IdentReplacement {
value: RcStr,
path: AstPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ use crate::{
create_visitor,
};

#[derive(PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue)]
#[derive(
PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug,
)]
pub struct MemberReplacement {
key: RcStr,
value: RcStr,
Expand Down
Loading
Loading