Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
d5978f96
Commit
d5978f96
authored
Sep 21, 2025
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix clippy issues and somehow land the same edit for the 10th time
parent
f5ecf4c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
25 deletions
+31
-25
graph.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
+10
-10
mod.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs
+19
-13
well_known.rs
...ck/crates/turbopack-ecmascript/src/analyzer/well_known.rs
+2
-2
No files found.
turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
View file @
d5978f96
...
...
@@ -2395,12 +2395,12 @@ impl VisitAstPath for Analyzer<'_> {
ast_path
:
&
mut
swc_core
::
ecma
::
visit
::
AstNodePath
<
'r
>
,
)
{
enum
ScopeType
{
Function
Scope
,
Block
Scope
,
ControlFlow
Scope
,
Function
,
Block
,
ControlFlow
,
}
let
block_type
=
if
ast_path
.len
()
<
2
{
ScopeType
::
Block
Scope
ScopeType
::
Block
}
else
if
matches!
(
&
ast_path
[
ast_path
.len
()
-
2
..
],
[
...
...
@@ -2419,7 +2419,7 @@ impl VisitAstPath for Analyzer<'_> {
AstParentNodeRef
::
Stmt
(
_
,
StmtField
::
Block
)
]
)
{
ScopeType
::
ControlFlow
Scope
ScopeType
::
ControlFlow
}
else
if
matches!
(
&
ast_path
[
ast_path
.len
()
-
2
..
],
[
_
,
AstParentNodeRef
::
Function
(
_
,
FunctionField
::
Body
)]
...
...
@@ -2431,12 +2431,12 @@ impl VisitAstPath for Analyzer<'_> {
|
[
_
,
AstParentNodeRef
::
SetterProp
(
_
,
SetterPropField
::
Body
)]
|
[
_
,
AstParentNodeRef
::
Constructor
(
_
,
ConstructorField
::
Body
)]
)
{
ScopeType
::
Function
Scope
ScopeType
::
Function
}
else
{
ScopeType
::
Block
Scope
ScopeType
::
Block
};
match
block_type
{
ScopeType
::
Function
Scope
=>
{
ScopeType
::
Function
=>
{
let
early_return_stack
=
take
(
&
mut
self
.early_return_stack
);
let
mut
effects
=
take
(
&
mut
self
.effects
);
let
hoisted_effects
=
take
(
&
mut
self
.hoisted_effects
);
...
...
@@ -2448,7 +2448,7 @@ impl VisitAstPath for Analyzer<'_> {
self
.effects
=
effects
;
self
.early_return_stack
=
early_return_stack
;
}
ScopeType
::
Block
Scope
=>
{
ScopeType
::
Block
=>
{
n
.visit_children_with_ast_path
(
self
,
ast_path
);
if
self
.end_early_return_block
()
{
self
.early_return_stack
.push
(
EarlyReturn
::
Always
{
...
...
@@ -2457,7 +2457,7 @@ impl VisitAstPath for Analyzer<'_> {
});
}
}
ScopeType
::
ControlFlow
Scope
=>
{
ScopeType
::
ControlFlow
=>
{
n
.visit_children_with_ast_path
(
self
,
ast_path
);
}
}
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs
View file @
d5978f96
...
...
@@ -1008,15 +1008,21 @@ impl JsValue {
func_ident
:
u32
,
is_async
:
bool
,
is_generator
:
bool
,
mut
return_value
:
Box
<
JsValue
>
,
return_value
:
JsValue
,
)
->
Self
{
// Check generator first to handle async generators
if
is_generator
{
return_value
=
Box
::
new
(
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
Generator
));
}
else
if
is_async
&&
!
matches!
(
return_value
,
box
JsValue
::
Promise
(
_
,
_
))
{
return_value
=
Box
::
new
(
JsValue
::
promise
(
return_value
));
}
Self
::
Function
(
1
+
return_value
.total_nodes
(),
func_ident
,
return_value
)
let
return_value
=
if
is_generator
{
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
Generator
)
}
else
if
is_async
{
JsValue
::
promise
(
return_value
)
}
else
{
return_value
};
Self
::
Function
(
1
+
return_value
.total_nodes
(),
func_ident
,
Box
::
new
(
return_value
),
)
}
pub
fn
object
(
list
:
Vec
<
ObjectPart
>
)
->
Self
{
...
...
@@ -1072,12 +1078,12 @@ impl JsValue {
Self
::
Member
(
1
+
o
.total_nodes
()
+
p
.total_nodes
(),
o
,
p
)
}
pub
fn
promise
(
operand
:
Box
<
JsValue
>
)
->
Self
{
pub
fn
promise
(
operand
:
JsValue
)
->
Self
{
// In ecmascript Promise<Promise<T>> is equivalent to Promise<T>
if
let
JsValue
::
Promise
(
_
,
_
)
=
&*
operand
{
return
*
operand
;
if
let
JsValue
::
Promise
(
_
,
_
)
=
operand
{
return
operand
;
}
Self
::
Promise
(
1
+
operand
.total_nodes
(),
operand
)
Self
::
Promise
(
1
+
operand
.total_nodes
(),
Box
::
new
(
operand
)
)
}
pub
fn
awaited
(
operand
:
Box
<
JsValue
>
)
->
Self
{
...
...
@@ -3665,10 +3671,10 @@ pub mod test_utils {
ref
args
,
)
=>
match
&
args
[
0
]
{
JsValue
::
Constant
(
ConstantValue
::
Str
(
v
))
=>
{
JsValue
::
promise
(
Box
::
new
(
JsValue
::
Module
(
ModuleValue
{
JsValue
::
promise
(
JsValue
::
Module
(
ModuleValue
{
module
:
v
.as_atom
()
.into_owned
(),
annotations
:
ImportAnnotations
::
default
(),
}))
)
}))
}
_
=>
v
.into_unknown
(
true
,
"import() non constant"
),
},
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs
View file @
d5978f96
...
...
@@ -345,10 +345,10 @@ fn path_dirname(mut args: Vec<JsValue>) -> JsValue {
pub
fn
import
(
args
:
Vec
<
JsValue
>
)
->
JsValue
{
match
&
args
[
..
]
{
[
JsValue
::
Constant
(
ConstantValue
::
Str
(
v
))]
=>
{
JsValue
::
promise
(
Box
::
new
(
JsValue
::
Module
(
ModuleValue
{
JsValue
::
promise
(
JsValue
::
Module
(
ModuleValue
{
module
:
v
.as_atom
()
.into_owned
(),
annotations
:
ImportAnnotations
::
default
(),
}))
)
}))
}
_
=>
JsValue
::
unknown
(
JsValue
::
call
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment