Skip to content

Commit 1781b85

Browse files
authored
perf(es/utils): Restrict recursion of get_type (#9933)
1 parent d24f785 commit 1781b85

File tree

16 files changed

+89
-61
lines changed

16 files changed

+89
-61
lines changed

.changeset/empty-steaks-dream.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_ecma_ast: minor
3+
swc_ecma_utils: major
4+
---
5+
6+
perf(es/utils): Restrict recursion of `get_type`

crates/swc_ecma_minifier/src/compress/optimize/bools.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ impl Optimizer<'_> {
4242
}
4343

4444
if !is_ret_val_ignored {
45-
if let Known(Type::Bool) = e.left.get_type() {
45+
if let Known(Type::Bool) = e.left.get_type(self.ctx.expr_ctx) {
4646
} else {
4747
// Don't change type.
4848
return false;
4949
}
5050

51-
if let Known(Type::Bool) = e.right.get_type() {
51+
if let Known(Type::Bool) = e.right.get_type(self.ctx.expr_ctx) {
5252
} else {
5353
// Don't change type.
5454
return false;
@@ -277,8 +277,8 @@ impl Optimizer<'_> {
277277
_ => return None,
278278
};
279279

280-
let lt = left.get_type();
281-
let rt = right.get_type();
280+
let lt = left.get_type(self.ctx.expr_ctx);
281+
let rt = right.get_type(self.ctx.expr_ctx);
282282
if let Value::Known(lt) = lt {
283283
if let Value::Known(rt) = rt {
284284
match (lt, rt) {

crates/swc_ecma_minifier/src/compress/optimize/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,11 +1630,11 @@ impl VisitMut for Optimizer<'_> {
16301630
self.optimize_bin_and_or(n);
16311631

16321632
if n.op == op!(bin, "+") {
1633-
if let Known(Type::Str) = n.left.get_type() {
1633+
if let Known(Type::Str) = n.left.get_type(self.ctx.expr_ctx) {
16341634
self.optimize_expr_in_str_ctx(&mut n.right);
16351635
}
16361636

1637-
if let Known(Type::Str) = n.right.get_type() {
1637+
if let Known(Type::Str) = n.right.get_type(self.ctx.expr_ctx) {
16381638
self.optimize_expr_in_str_ctx(&mut n.left);
16391639
}
16401640
}

crates/swc_ecma_minifier/src/compress/optimize/ops.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl Optimizer<'_> {
5858
}
5959
}
6060

61-
let lt = e.left.get_type();
62-
let rt = e.right.get_type();
61+
let lt = e.left.get_type(self.ctx.expr_ctx);
62+
let rt = e.right.get_type(self.ctx.expr_ctx);
6363

6464
if e.op == op!("===") {
6565
if let Known(lt) = lt {
@@ -127,7 +127,10 @@ impl Optimizer<'_> {
127127
.into(),
128128
)
129129
};
130-
match (n.left.get_type().opt()?, n.right.get_type().opt()?) {
130+
match (
131+
n.left.get_type(self.ctx.expr_ctx).opt()?,
132+
n.right.get_type(self.ctx.expr_ctx).opt()?,
133+
) {
131134
// Abort if types differ, or one of them is unknown.
132135
(lt, rt) if lt != rt => {}
133136
(Type::Obj, Type::Obj) => {}
@@ -181,7 +184,7 @@ impl Optimizer<'_> {
181184
| Expr::Bin(BinExpr { op: op!("<"), .. })
182185
| Expr::Bin(BinExpr { op: op!(">="), .. })
183186
| Expr::Bin(BinExpr { op: op!(">"), .. }) => {
184-
if let Known(Type::Bool) = arg.get_type() {
187+
if let Known(Type::Bool) = arg.get_type(self.ctx.expr_ctx) {
185188
self.changed = true;
186189
report_change!("Optimizing: `!!expr` => `expr`");
187190
*e = *arg.take();
@@ -299,14 +302,14 @@ impl Optimizer<'_> {
299302
_ => {}
300303
}
301304

302-
let lt = bin.left.get_type();
305+
let lt = bin.left.get_type(self.ctx.expr_ctx);
303306
match lt {
304307
// Don't change type
305308
Known(Type::Bool) => {}
306309
_ => return,
307310
}
308311

309-
let rt = bin.right.get_type();
312+
let rt = bin.right.get_type(self.ctx.expr_ctx);
310313
match rt {
311314
Known(Type::Bool) => {}
312315
_ => return,

crates/swc_ecma_minifier/src/compress/optimize/sequences.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ impl Optimizer<'_> {
23712371
Mergable::Drop => return Ok(false),
23722372
};
23732373

2374-
let a_type = a_right.as_deref().map(|a| a.get_type());
2374+
let a_type = a_right.as_deref().map(|a| a.get_type(self.ctx.expr_ctx));
23752375

23762376
if let Some(a_right) = a_right {
23772377
if a_right.is_this() || a_right.is_ident_ref_to("arguments") {
@@ -2484,7 +2484,7 @@ impl Optimizer<'_> {
24842484
let Some(a_type) = a_type else {
24852485
return Ok(false);
24862486
};
2487-
let b_type = b.right.get_type();
2487+
let b_type = b.right.get_type(self.ctx.expr_ctx);
24882488

24892489
if let Some(a_op) = a_op {
24902490
if can_drop_op_for(a_op, b.op, var_type, a_type, b_type) {

crates/swc_ecma_minifier/src/compress/pure/bools.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ impl Pure<'_> {
8585
matches!(op, op!("==") | op!("===") | op!("!=") | op!("!=="))
8686
}
8787

88-
fn can_absorb_negate(e: &Expr) -> bool {
88+
fn can_absorb_negate(e: &Expr, ctx: ExprCtx) -> bool {
8989
match e {
9090
Expr::Lit(_) => true,
9191
Expr::Bin(BinExpr {
9292
op: op!("&&") | op!("||"),
9393
left,
9494
right,
9595
..
96-
}) => can_absorb_negate(left) && can_absorb_negate(right),
96+
}) => can_absorb_negate(left, ctx) && can_absorb_negate(right, ctx),
9797
Expr::Bin(BinExpr { op, .. }) if is_eq(*op) => true,
9898
Expr::Unary(UnaryExpr {
9999
op: op!("!"), arg, ..
100-
}) => arg.get_type() == Value::Known(Type::Bool),
100+
}) => arg.get_type(ctx) == Value::Known(Type::Bool),
101101
_ => false,
102102
}
103103
}
@@ -123,7 +123,7 @@ impl Pure<'_> {
123123
return;
124124
};
125125

126-
let arg_can_negate = can_absorb_negate(arg);
126+
let arg_can_negate = can_absorb_negate(arg, self.expr_ctx);
127127

128128
match &mut **arg {
129129
Expr::Bin(BinExpr { op, .. }) if is_eq(*op) => {
@@ -158,7 +158,7 @@ impl Pure<'_> {
158158
}
159159

160160
pub(super) fn compress_cmp_with_long_op(&mut self, e: &mut BinExpr) {
161-
fn should_optimize(l: &Expr, r: &Expr, opts: &CompressOptions) -> bool {
161+
fn should_optimize(l: &Expr, r: &Expr, ctx: ExprCtx, opts: &CompressOptions) -> bool {
162162
match (l, r) {
163163
(
164164
Expr::Unary(UnaryExpr {
@@ -168,7 +168,7 @@ impl Pure<'_> {
168168
) => true,
169169
_ => {
170170
if opts.comparisons {
171-
match (l.get_type(), r.get_type()) {
171+
match (l.get_type(ctx), r.get_type(ctx)) {
172172
(Value::Known(lt), Value::Known(rt)) => lt == rt,
173173

174174
_ => false,
@@ -185,8 +185,8 @@ impl Pure<'_> {
185185
_ => return,
186186
}
187187

188-
if should_optimize(&e.left, &e.right, self.options)
189-
|| should_optimize(&e.right, &e.left, self.options)
188+
if should_optimize(&e.left, &e.right, self.expr_ctx, self.options)
189+
|| should_optimize(&e.right, &e.left, self.expr_ctx, self.options)
190190
{
191191
report_change!("bools: Compressing comparison of `typeof` with literal");
192192
self.changed = true;
@@ -226,8 +226,8 @@ impl Pure<'_> {
226226
right,
227227
..
228228
}) => {
229-
let lt = left.get_type();
230-
let rt = right.get_type();
229+
let lt = left.get_type(self.expr_ctx);
230+
let rt = right.get_type(self.expr_ctx);
231231

232232
if let (Value::Known(Type::Bool), Value::Known(Type::Bool)) = (lt, rt) {
233233
let rb = right.as_pure_bool(self.expr_ctx);

crates/swc_ecma_minifier/src/compress/pure/conds.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl Pure<'_> {
2121

2222
let Expr::Cond(cond) = e else { return };
2323

24-
let lt = cond.cons.get_type();
24+
let lt = cond.cons.get_type(self.expr_ctx);
2525
if let Value::Known(Type::Bool) = lt {
2626
let lb = cond.cons.as_pure_bool(self.expr_ctx);
2727
if let Value::Known(true) = lb {
@@ -59,7 +59,7 @@ impl Pure<'_> {
5959
}
6060
}
6161

62-
let rt = cond.alt.get_type();
62+
let rt = cond.alt.get_type(self.expr_ctx);
6363
if let Value::Known(Type::Bool) = rt {
6464
let rb = cond.alt.as_pure_bool(self.expr_ctx);
6565
if let Value::Known(false) = rb {
@@ -220,8 +220,8 @@ impl Pure<'_> {
220220
return;
221221
}
222222

223-
let lt = bin.left.get_type();
224-
let rt = bin.right.get_type();
223+
let lt = bin.left.get_type(self.expr_ctx);
224+
let rt = bin.right.get_type(self.expr_ctx);
225225

226226
let _lb = bin.left.as_pure_bool(self.expr_ctx);
227227
let rb = bin.right.as_pure_bool(self.expr_ctx);

crates/swc_ecma_minifier/src/compress/pure/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,8 +1675,8 @@ impl Pure<'_> {
16751675
_ => return,
16761676
};
16771677

1678-
let lt = cond.cons.get_type();
1679-
let rt = cond.alt.get_type();
1678+
let lt = cond.cons.get_type(self.expr_ctx);
1679+
let rt = cond.alt.get_type(self.expr_ctx);
16801680
match (lt, rt) {
16811681
(Known(Type::Bool), Known(Type::Bool)) => {}
16821682
_ => return,

crates/swc_ecma_minifier/src/compress/pure/strings.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ impl Pure<'_> {
2828
_ => return,
2929
};
3030

31-
match l_l.get_type() {
31+
match l_l.get_type(self.expr_ctx) {
3232
Known(Type::Str) => {}
3333
_ => return,
3434
}
35-
match r_l.get_type() {
35+
match r_l.get_type(self.expr_ctx) {
3636
Known(Type::Str) => {}
3737
_ => return,
3838
}
@@ -487,8 +487,8 @@ impl Pure<'_> {
487487
},
488488
) = &mut *bin.left
489489
{
490-
let type_of_second = left.right.get_type();
491-
let type_of_third = bin.right.get_type();
490+
let type_of_second = left.right.get_type(self.expr_ctx);
491+
let type_of_third = bin.right.get_type(self.expr_ctx);
492492

493493
if let Value::Known(Type::Str) = type_of_second {
494494
if let Value::Known(Type::Str) = type_of_third {
@@ -534,8 +534,8 @@ impl Pure<'_> {
534534
..
535535
}) = e
536536
{
537-
let lt = left.get_type();
538-
let rt = right.get_type();
537+
let lt = left.get_type(self.expr_ctx);
538+
let rt = right.get_type(self.expr_ctx);
539539
if let Value::Known(Type::Str) = lt {
540540
if let Value::Known(Type::Str) = rt {
541541
match &**left {

crates/swc_ecma_minifier/tests/benches-full/react.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@
512512
throw payload._result;
513513
}
514514
function isValidElementType(type) {
515-
return 'string' == typeof type || 'function' == typeof type || type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || 'object' == typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE);
515+
return 'string' == typeof type || 'function' == typeof type || type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || 'object' == typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) || !1 // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
516+
;
516517
}
517518
function resolveDispatcher() {
518519
var dispatcher = ReactCurrentDispatcher.current;

crates/swc_ecma_minifier/tests/fixture/next/styled-components/1/output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6701,7 +6701,7 @@
67016701
* LICENSE file in the root directory of this source tree.
67026702
*/ var u, b = Symbol.for("react.element"), c = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen");
67036703
u = Symbol.for("react.module.reference"), exports.isValidElementType = function(a) {
6704-
return "string" == typeof a || "function" == typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" == typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId);
6704+
return "string" == typeof a || "function" == typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" == typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) || !1;
67056705
}, exports.typeOf = function(a) {
67066706
if ("object" == typeof a && null !== a) {
67076707
var r = a.$$typeof;

crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27994,7 +27994,7 @@
2799427994

2799527995
*/ ToolbarRenderer.prototype.renderColorPickerDropDown = function(args, item, colorPicker, defaultColor) {
2799627996
var range, _this = this, proxy = this, css = classes /* CLS_RTE_ELEMENTS */ .i7 + ' ' + classes /* CLS_TB_BTN */ .Fs + (this.parent.inlineMode ? ' ' + classes /* CLS_INLINE_DROPDOWN */ .ZV : '');
27997-
css += ' ' + ('backgroundcolor' === item ? classes /* CLS_BACKGROUND_COLOR_DROPDOWN */ .Z8 : classes /* CLS_FONT_COLOR_DROPDOWN */ .UQ) + ' ' + this.parent.cssClass;
27997+
css += ' ' + ('backgroundcolor' === item ? classes /* CLS_BACKGROUND_COLOR_DROPDOWN */ .Z8 : classes /* CLS_FONT_COLOR_DROPDOWN */ .UQ), css += ' ' + this.parent.cssClass;
2799827998
var content = proxy.parent.createElement('span', {
2799927999
className: classes /* CLS_COLOR_CONTENT */ .uN
2800028000
}), inlineEle = proxy.parent.createElement('span', {
@@ -30011,7 +30011,7 @@
3001130011
* @returns {boolean} - returns the boolean value
3001230012
* @hidden
3001330013
*/ function isEditableValueEmpty(value) {
30014-
return '<p><br></p>' === value || '&lt;p&gt;&lt;br&gt;&lt;/p&gt;' === value || '<div><br></div>' === value || '&lt;div&gt;&lt;br&gt;&lt;/div&gt;' === value || '<br>' === value || '&lt;br&gt;' === value || '' === value;
30014+
return '<p><br></p>' === value || '&lt;p&gt;&lt;br&gt;&lt;/p&gt;' === value || '<div><br></div>' === value || '&lt;div&gt;&lt;br&gt;&lt;/div&gt;' === value || '<br>' === value || '&lt;br&gt;' === value || '' === value || !1;
3001530015
}
3001630016
/**
3001730017
* @param {string} value - specifies the string value

crates/swc_ecma_minifier/tests/projects/output/react-17.0.1.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@
514514
throw payload._result;
515515
}
516516
function isValidElementType(type) {
517-
return "string" == typeof type || "function" == typeof type || type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || "object" == typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE);
517+
return "string" == typeof type || "function" == typeof type || type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || "object" == typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) || !1 // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
518+
;
518519
}
519520
function resolveDispatcher() {
520521
var dispatcher = ReactCurrentDispatcher.current;

crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl SimplifyExpr {
445445
}
446446
}
447447

448-
match expr.get_type() {
448+
match expr.get_type(self.expr_ctx) {
449449
// String concatenation
450450
Known(StringType) => match expr {
451451
Expr::Bin(BinExpr {
@@ -911,8 +911,8 @@ impl SimplifyExpr {
911911

912912
if (lv.is_unknown() && rv.is_unknown())
913913
|| op == op!(bin, "+")
914-
&& (!left.get_type().casted_to_number_on_add()
915-
|| !right.get_type().casted_to_number_on_add())
914+
&& (!left.get_type(self.expr_ctx).casted_to_number_on_add()
915+
|| !right.get_type(self.expr_ctx).casted_to_number_on_add())
916916
{
917917
return Unknown;
918918
}
@@ -1067,7 +1067,7 @@ impl SimplifyExpr {
10671067
}
10681068

10691069
// Try to evaluate based on the general type.
1070-
let (lt, rt) = (left.get_type(), right.get_type());
1070+
let (lt, rt) = (left.get_type(self.expr_ctx), right.get_type(self.expr_ctx));
10711071

10721072
if let (Known(StringType), Known(StringType)) = (lt, rt) {
10731073
if let (Known(lv), Known(rv)) = (
@@ -1099,7 +1099,10 @@ impl SimplifyExpr {
10991099

11001100
/// https://tc39.github.io/ecma262/#sec-abstract-equality-comparison
11011101
fn perform_abstract_eq_cmp(&mut self, span: Span, left: &Expr, right: &Expr) -> Value<bool> {
1102-
let (lt, rt) = (try_val!(left.get_type()), try_val!(right.get_type()));
1102+
let (lt, rt) = (
1103+
try_val!(left.get_type(self.expr_ctx)),
1104+
try_val!(right.get_type(self.expr_ctx)),
1105+
);
11031106

11041107
if lt == rt {
11051108
return self.perform_strict_eq_cmp(left, right);
@@ -1171,7 +1174,10 @@ impl SimplifyExpr {
11711174
_ => {}
11721175
}
11731176

1174-
let (lt, rt) = (try_val!(left.get_type()), try_val!(right.get_type()));
1177+
let (lt, rt) = (
1178+
try_val!(left.get_type(self.expr_ctx)),
1179+
try_val!(right.get_type(self.expr_ctx)),
1180+
);
11751181
// Strict equality can only be true for values of the same type.
11761182
if lt != rt {
11771183
return Known(false);

crates/swc_ecma_usage_analyzer/src/analyzer/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,19 @@ where
276276
match &n.left {
277277
AssignTarget::Pat(p) => {
278278
for id in find_pat_ids(p) {
279-
self.data
280-
.report_assign(self.ctx, id, is_op_assign, n.right.get_type())
279+
self.data.report_assign(
280+
self.ctx,
281+
id,
282+
is_op_assign,
283+
n.right.get_type(self.expr_ctx),
284+
)
281285
}
282286
}
283287
AssignTarget::Simple(e) => {
284288
self.report_assign_expr_if_ident(
285289
e.as_ident().map(Ident::from).as_ref(),
286290
is_op_assign,
287-
n.right.get_type(),
291+
n.right.get_type(self.expr_ctx),
288292
);
289293
self.mark_mutation_if_member(e.as_member())
290294
}
@@ -1304,7 +1308,10 @@ where
13041308
let ctx = Ctx {
13051309
inline_prevented: self.ctx.inline_prevented || prevent_inline,
13061310
in_pat_of_var_decl: true,
1307-
in_pat_of_var_decl_with_init: e.init.as_ref().map(|init| init.get_type()),
1311+
in_pat_of_var_decl_with_init: e
1312+
.init
1313+
.as_ref()
1314+
.map(|init| init.get_type(self.expr_ctx)),
13081315
in_decl_with_no_side_effect_for_member_access: e
13091316
.init
13101317
.as_deref()

0 commit comments

Comments
 (0)