Skip to content

Commit 62b201c

Browse files
authored
remove box_syntax (vercel/turborepo#4667)
### Description Box syntax removed in rust-lang/rust#108471 Removed all `#![features(box_syntax)]` and ran `cargo fix --broken-code` to replace all previous box_patterns uses of `box` with `Box::new()`. ### Testing Instructions No testing needed.
1 parent 6655ef6 commit 62b201c

File tree

33 files changed

+237
-207
lines changed

33 files changed

+237
-207
lines changed

crates/turbo-tasks-fs/src/lib.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(min_specialization)]
44
#![feature(iter_advance_by)]
55
#![feature(io_error_more)]
6-
#![feature(box_syntax)]
76
#![feature(round_char_boundary)]
87

98
pub mod attach;
@@ -1683,9 +1682,9 @@ impl FileContent {
16831682
let de = &mut serde_json::Deserializer::from_reader(file.read());
16841683
match serde_path_to_error::deserialize(de) {
16851684
Ok(data) => FileJsonContent::Content(data),
1686-
Err(e) => FileJsonContent::Unparseable(
1687-
box UnparseableJson::from_serde_path_to_error(e),
1688-
),
1685+
Err(e) => FileJsonContent::Unparseable(Box::new(
1686+
UnparseableJson::from_serde_path_to_error(e),
1687+
)),
16891688
}
16901689
}
16911690
FileContent::NotFound => FileJsonContent::NotFound,
@@ -1709,9 +1708,8 @@ impl FileContent {
17091708
"text content doesn't contain any json data",
17101709
),
17111710
},
1712-
Err(e) => FileJsonContent::Unparseable(box UnparseableJson::from_jsonc_error(
1713-
e,
1714-
string.as_ref(),
1711+
Err(e) => FileJsonContent::Unparseable(Box::new(
1712+
UnparseableJson::from_jsonc_error(e, string.as_ref()),
17151713
)),
17161714
},
17171715
Err(_) => FileJsonContent::unparseable("binary is not valid utf-8 text"),

crates/turbo-tasks-memory/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(hash_drain_filter)]
22
#![feature(option_get_or_insert_default)]
3-
#![feature(box_syntax)]
43
#![feature(type_alias_impl_trait)]
54
#![feature(lint_reasons)]
65
#![feature(box_patterns)]

crates/turbo-tasks-memory/src/task.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@ impl Task {
528528
Self {
529529
id,
530530
ty,
531-
state: RwLock::new(TaskMetaState::Full(box TaskState::new(
531+
state: RwLock::new(TaskMetaState::Full(Box::new(TaskState::new(
532532
description,
533533
stats_type,
534-
))),
534+
)))),
535535
}
536536
}
537537

@@ -546,10 +546,8 @@ impl Task {
546546
Self {
547547
id,
548548
ty,
549-
state: RwLock::new(TaskMetaState::Full(box TaskState::new_scheduled_in_scope(
550-
description,
551-
scope,
552-
stats_type,
549+
state: RwLock::new(TaskMetaState::Full(Box::new(
550+
TaskState::new_scheduled_in_scope(description, scope, stats_type),
553551
))),
554552
}
555553
}
@@ -565,10 +563,8 @@ impl Task {
565563
Self {
566564
id,
567565
ty,
568-
state: RwLock::new(TaskMetaState::Full(box TaskState::new_scheduled_in_scope(
569-
description,
570-
scope,
571-
stats_type,
566+
state: RwLock::new(TaskMetaState::Full(Box::new(
567+
TaskState::new_scheduled_in_scope(description, scope, stats_type),
572568
))),
573569
}
574570
}
@@ -579,18 +575,18 @@ impl Task {
579575
trait_type_id: TraitTypeId,
580576
stats_type: StatsType,
581577
) -> Self {
582-
let ty = TaskType::ReadScopeCollectibles(box ReadScopeCollectiblesTaskType {
578+
let ty = TaskType::ReadScopeCollectibles(Box::new(ReadScopeCollectiblesTaskType {
583579
scope: target_scope,
584580
trait_type: trait_type_id,
585-
});
581+
}));
586582
let description = Self::get_event_description_static(id, &ty);
587583
Self {
588584
id,
589585
ty,
590-
state: RwLock::new(TaskMetaState::Full(box TaskState::new(
586+
state: RwLock::new(TaskMetaState::Full(Box::new(TaskState::new(
591587
description,
592588
stats_type,
593-
))),
589+
)))),
594590
}
595591
}
596592

@@ -601,19 +597,19 @@ impl Task {
601597
trait_type_id: TraitTypeId,
602598
stats_type: StatsType,
603599
) -> Self {
604-
let ty = TaskType::ReadTaskCollectibles(box ReadTaskCollectiblesTaskType {
600+
let ty = TaskType::ReadTaskCollectibles(Box::new(ReadTaskCollectiblesTaskType {
605601
task: target_task,
606602
trait_type: trait_type_id,
607-
});
603+
}));
608604
let description = Self::get_event_description_static(id, &ty);
609605
Self {
610606
id,
611607
ty,
612-
state: RwLock::new(TaskMetaState::Full(box TaskState::new_root_scoped(
608+
state: RwLock::new(TaskMetaState::Full(Box::new(TaskState::new_root_scoped(
613609
description,
614610
scope,
615611
stats_type,
616-
))),
612+
)))),
617613
}
618614
}
619615

@@ -2787,7 +2783,7 @@ impl Task {
27872783
if unset {
27882784
*state = TaskMetaState::Unloaded(UnloadedTaskState { stats_type });
27892785
} else {
2790-
*state = TaskMetaState::Partial(box PartialTaskState { scopes, stats_type });
2786+
*state = TaskMetaState::Partial(Box::new(PartialTaskState { scopes, stats_type }));
27912787
}
27922788
drop(state);
27932789

crates/turbo-tasks-memory/src/task/meta_state.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ impl<'a> TaskMetaStateWriteGuard<'a> {
187187
)
188188
.into_partial()
189189
.unwrap();
190-
*guard = TaskMetaState::Full(box partial.into_full(task.get_event_description()));
190+
*guard =
191+
TaskMetaState::Full(Box::new(partial.into_full(task.get_event_description())));
191192
}
192193
TaskMetaState::Unloaded(_) => {
193194
let unloaded = replace(
@@ -199,7 +200,8 @@ impl<'a> TaskMetaStateWriteGuard<'a> {
199200
)
200201
.into_unloaded()
201202
.unwrap();
202-
*guard = TaskMetaState::Full(box unloaded.into_full(task.get_event_description()));
203+
*guard =
204+
TaskMetaState::Full(Box::new(unloaded.into_full(task.get_event_description())));
203205
}
204206
}
205207
WriteGuard::new(guard, TaskMetaState::as_full, TaskMetaState::as_full_mut)
@@ -228,7 +230,7 @@ impl<'a> TaskMetaStateWriteGuard<'a> {
228230
)
229231
.into_unloaded()
230232
.unwrap();
231-
*guard = TaskMetaState::Partial(box unloaded.into_partial());
233+
*guard = TaskMetaState::Partial(Box::new(unloaded.into_partial()));
232234
TaskMetaStateWriteGuard::Partial(WriteGuard::new(
233235
guard,
234236
TaskMetaState::as_partial,

crates/turbo-tasks-testing/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Testing utilities and macros for turbo-tasks and applications based on it.
22
3-
#![feature(box_syntax)]
4-
53
mod macros;
64
pub mod retry;
75

crates/turbo-tasks/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#![feature(hash_drain_filter)]
2929
#![deny(unsafe_op_in_unsafe_fn)]
3030
#![feature(result_flattening)]
31-
#![feature(box_syntax)]
3231
#![feature(error_generic_member_access)]
3332
#![feature(provide_any)]
3433
#![feature(new_uninit)]

crates/turbopack-css/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(min_specialization)]
22
#![feature(box_patterns)]
3-
#![feature(box_syntax)]
43
#![feature(iter_intersperse)]
54
#![feature(int_roundings)]
65

crates/turbopack-css/src/parse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ async fn parse_content(
161161
let handler = Handler::with_emitter(
162162
true,
163163
false,
164-
box IssueEmitter {
164+
Box::new(IssueEmitter {
165165
source,
166166
source_map: source_map.clone(),
167167
title: Some("Parsing css source code failed".to_string()),
168-
},
168+
}),
169169
);
170170

171171
let fm = source_map.new_source_file(FileName::Custom(ident_str.to_string()), string);

crates/turbopack-css/src/references/import.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,31 @@ impl ImportAttributes {
110110
}
111111

112112
// something random that's never gonna be in real css
113-
let mut rule = Rule::ListOfComponentValues(box ListOfComponentValues {
113+
let mut rule = Rule::ListOfComponentValues(Box::new(ListOfComponentValues {
114114
span: DUMMY_SP,
115115
children: vec![ComponentValue::PreservedToken(Box::new(token(
116116
Token::String {
117117
value: Default::default(),
118118
raw: r#""""__turbopack_placeholder__""""#.into(),
119119
},
120120
)))],
121-
});
121+
}));
122122

123123
fn at_rule(name: &str, prelude: AtRulePrelude, inner_rule: Rule) -> Rule {
124-
Rule::AtRule(box AtRule {
124+
Rule::AtRule(Box::new(AtRule {
125125
span: DUMMY_SP,
126126
name: AtRuleName::Ident(Ident {
127127
span: DUMMY_SP,
128128
value: name.into(),
129129
raw: None,
130130
}),
131-
prelude: Some(box prelude),
131+
prelude: Some(Box::new(prelude)),
132132
block: Some(SimpleBlock {
133133
span: DUMMY_SP,
134134
name: token(Token::LBrace),
135135
value: vec![ComponentValue::from(inner_rule)],
136136
}),
137-
})
137+
}))
138138
}
139139

140140
if let Some(media) = &self.media {

crates/turbopack-css/src/references/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ pub async fn analyze_css_stylesheet(
5858
let handler = Handler::with_emitter(
5959
true,
6060
false,
61-
box IssueEmitter {
61+
Box::new(IssueEmitter {
6262
source,
6363
source_map: source_map.clone(),
6464
title: None,
65-
},
65+
}),
6666
);
6767
let globals = Globals::new();
6868
HANDLER.set(&handler, || {

crates/turbopack-css/src/references/url.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ impl CodeGenerateable for UrlAssetReference {
125125

126126
visitors.push(
127127
create_visitor!((&this.path.await?), visit_mut_url(u: &mut Url) {
128-
u.value = Some(box UrlValue::Str(Str {
128+
u.value = Some(Box::new(UrlValue::Str(Str {
129129
span: DUMMY_SP,
130130
value: relative_path.as_str().into(),
131131
raw: None,
132-
}))
132+
})))
133133
}),
134134
);
135135
}

crates/turbopack-ecmascript/src/analyzer/builtin.rs

+18-11
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
7474
*value = JsValue::alternatives(
7575
take(alts)
7676
.into_iter()
77-
.map(|alt| JsValue::member(box alt, prop.clone()))
77+
.map(|alt| JsValue::member(Box::new(alt), prop.clone()))
7878
.collect(),
7979
);
8080
true
@@ -87,7 +87,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
8787
} => {
8888
fn items_to_alternatives(items: &mut Vec<JsValue>, prop: &mut JsValue) -> JsValue {
8989
items.push(JsValue::unknown(
90-
JsValue::member(box JsValue::array(Vec::new()), box take(prop)),
90+
JsValue::member(Box::new(JsValue::array(Vec::new())), Box::new(take(prop))),
9191
"unknown array prototype methods or values",
9292
));
9393
JsValue::alternatives(take(items))
@@ -105,7 +105,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
105105
true
106106
} else {
107107
*value = JsValue::unknown(
108-
JsValue::member(box take(obj), box take(prop)),
108+
JsValue::member(Box::new(take(obj)), Box::new(take(prop))),
109109
"invalid index",
110110
);
111111
true
@@ -127,7 +127,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
127127
*value = JsValue::alternatives(
128128
take(alts)
129129
.into_iter()
130-
.map(|alt| JsValue::member(box obj.clone(), box alt))
130+
.map(|alt| JsValue::member(Box::new(obj.clone()), Box::new(alt)))
131131
.collect(),
132132
);
133133
true
@@ -160,7 +160,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
160160
ObjectPart::Spread(_) => {
161161
values.push(JsValue::unknown(
162162
JsValue::member(
163-
box JsValue::object(vec![take(part)]),
163+
Box::new(JsValue::object(vec![take(part)])),
164164
prop.clone(),
165165
),
166166
"spreaded object",
@@ -170,7 +170,10 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
170170
}
171171
if include_unknown {
172172
values.push(JsValue::unknown(
173-
JsValue::member(box JsValue::object(Vec::new()), box take(prop)),
173+
JsValue::member(
174+
Box::new(JsValue::object(Vec::new())),
175+
Box::new(take(prop)),
176+
),
174177
"unknown object prototype methods or values",
175178
));
176179
}
@@ -262,7 +265,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
262265
*value = JsValue::alternatives(
263266
take(alts)
264267
.into_iter()
265-
.map(|alt| JsValue::member(box obj.clone(), box alt))
268+
.map(|alt| JsValue::member(Box::new(obj.clone()), Box::new(alt)))
266269
.collect(),
267270
);
268271
true
@@ -336,7 +339,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
336339
.enumerate()
337340
.map(|(i, item)| {
338341
JsValue::call(
339-
box func.clone(),
342+
Box::new(func.clone()),
340343
vec![
341344
item,
342345
JsValue::Constant(ConstantValue::Num(
@@ -361,7 +364,11 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
361364
take(alts)
362365
.into_iter()
363366
.map(|alt| {
364-
JsValue::member_call(box alt, box prop.clone(), args.clone())
367+
JsValue::member_call(
368+
Box::new(alt),
369+
Box::new(prop.clone()),
370+
args.clone(),
371+
)
365372
})
366373
.collect(),
367374
);
@@ -372,7 +379,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
372379
// without special handling, we convert it into a normal call like
373380
// `(obj.prop)(arg1, arg2, ...)`
374381
*value = JsValue::call(
375-
box JsValue::member(box take(obj), box take(prop)),
382+
Box::new(JsValue::member(Box::new(take(obj)), Box::new(take(prop)))),
376383
take(args),
377384
);
378385
true
@@ -383,7 +390,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
383390
*value = JsValue::alternatives(
384391
take(alts)
385392
.into_iter()
386-
.map(|alt| JsValue::call(box alt, args.clone()))
393+
.map(|alt| JsValue::call(Box::new(alt), args.clone()))
387394
.collect(),
388395
);
389396
true

0 commit comments

Comments
 (0)