Skip to content

Commit

Permalink
remove box_syntax (vercel/turborepo#4667)
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
seeplusplus authored Apr 26, 2023
1 parent dc8213f commit a77addb
Show file tree
Hide file tree
Showing 33 changed files with 237 additions and 207 deletions.
12 changes: 5 additions & 7 deletions crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![feature(min_specialization)]
#![feature(iter_advance_by)]
#![feature(io_error_more)]
#![feature(box_syntax)]
#![feature(round_char_boundary)]

pub mod attach;
Expand Down Expand Up @@ -1683,9 +1682,9 @@ impl FileContent {
let de = &mut serde_json::Deserializer::from_reader(file.read());
match serde_path_to_error::deserialize(de) {
Ok(data) => FileJsonContent::Content(data),
Err(e) => FileJsonContent::Unparseable(
box UnparseableJson::from_serde_path_to_error(e),
),
Err(e) => FileJsonContent::Unparseable(Box::new(
UnparseableJson::from_serde_path_to_error(e),
)),
}
}
FileContent::NotFound => FileJsonContent::NotFound,
Expand All @@ -1709,9 +1708,8 @@ impl FileContent {
"text content doesn't contain any json data",
),
},
Err(e) => FileJsonContent::Unparseable(box UnparseableJson::from_jsonc_error(
e,
string.as_ref(),
Err(e) => FileJsonContent::Unparseable(Box::new(
UnparseableJson::from_jsonc_error(e, string.as_ref()),
)),
},
Err(_) => FileJsonContent::unparseable("binary is not valid utf-8 text"),
Expand Down
1 change: 0 additions & 1 deletion crates/turbo-tasks-memory/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![feature(hash_drain_filter)]
#![feature(option_get_or_insert_default)]
#![feature(box_syntax)]
#![feature(type_alias_impl_trait)]
#![feature(lint_reasons)]
#![feature(box_patterns)]
Expand Down
34 changes: 15 additions & 19 deletions crates/turbo-tasks-memory/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ impl Task {
Self {
id,
ty,
state: RwLock::new(TaskMetaState::Full(box TaskState::new(
state: RwLock::new(TaskMetaState::Full(Box::new(TaskState::new(
description,
stats_type,
))),
)))),
}
}

Expand All @@ -546,10 +546,8 @@ impl Task {
Self {
id,
ty,
state: RwLock::new(TaskMetaState::Full(box TaskState::new_scheduled_in_scope(
description,
scope,
stats_type,
state: RwLock::new(TaskMetaState::Full(Box::new(
TaskState::new_scheduled_in_scope(description, scope, stats_type),
))),
}
}
Expand All @@ -565,10 +563,8 @@ impl Task {
Self {
id,
ty,
state: RwLock::new(TaskMetaState::Full(box TaskState::new_scheduled_in_scope(
description,
scope,
stats_type,
state: RwLock::new(TaskMetaState::Full(Box::new(
TaskState::new_scheduled_in_scope(description, scope, stats_type),
))),
}
}
Expand All @@ -579,18 +575,18 @@ impl Task {
trait_type_id: TraitTypeId,
stats_type: StatsType,
) -> Self {
let ty = TaskType::ReadScopeCollectibles(box ReadScopeCollectiblesTaskType {
let ty = TaskType::ReadScopeCollectibles(Box::new(ReadScopeCollectiblesTaskType {
scope: target_scope,
trait_type: trait_type_id,
});
}));
let description = Self::get_event_description_static(id, &ty);
Self {
id,
ty,
state: RwLock::new(TaskMetaState::Full(box TaskState::new(
state: RwLock::new(TaskMetaState::Full(Box::new(TaskState::new(
description,
stats_type,
))),
)))),
}
}

Expand All @@ -601,19 +597,19 @@ impl Task {
trait_type_id: TraitTypeId,
stats_type: StatsType,
) -> Self {
let ty = TaskType::ReadTaskCollectibles(box ReadTaskCollectiblesTaskType {
let ty = TaskType::ReadTaskCollectibles(Box::new(ReadTaskCollectiblesTaskType {
task: target_task,
trait_type: trait_type_id,
});
}));
let description = Self::get_event_description_static(id, &ty);
Self {
id,
ty,
state: RwLock::new(TaskMetaState::Full(box TaskState::new_root_scoped(
state: RwLock::new(TaskMetaState::Full(Box::new(TaskState::new_root_scoped(
description,
scope,
stats_type,
))),
)))),
}
}

Expand Down Expand Up @@ -2787,7 +2783,7 @@ impl Task {
if unset {
*state = TaskMetaState::Unloaded(UnloadedTaskState { stats_type });
} else {
*state = TaskMetaState::Partial(box PartialTaskState { scopes, stats_type });
*state = TaskMetaState::Partial(Box::new(PartialTaskState { scopes, stats_type }));
}
drop(state);

Expand Down
8 changes: 5 additions & 3 deletions crates/turbo-tasks-memory/src/task/meta_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ impl<'a> TaskMetaStateWriteGuard<'a> {
)
.into_partial()
.unwrap();
*guard = TaskMetaState::Full(box partial.into_full(task.get_event_description()));
*guard =
TaskMetaState::Full(Box::new(partial.into_full(task.get_event_description())));
}
TaskMetaState::Unloaded(_) => {
let unloaded = replace(
Expand All @@ -199,7 +200,8 @@ impl<'a> TaskMetaStateWriteGuard<'a> {
)
.into_unloaded()
.unwrap();
*guard = TaskMetaState::Full(box unloaded.into_full(task.get_event_description()));
*guard =
TaskMetaState::Full(Box::new(unloaded.into_full(task.get_event_description())));
}
}
WriteGuard::new(guard, TaskMetaState::as_full, TaskMetaState::as_full_mut)
Expand Down Expand Up @@ -228,7 +230,7 @@ impl<'a> TaskMetaStateWriteGuard<'a> {
)
.into_unloaded()
.unwrap();
*guard = TaskMetaState::Partial(box unloaded.into_partial());
*guard = TaskMetaState::Partial(Box::new(unloaded.into_partial()));
TaskMetaStateWriteGuard::Partial(WriteGuard::new(
guard,
TaskMetaState::as_partial,
Expand Down
2 changes: 0 additions & 2 deletions crates/turbo-tasks-testing/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Testing utilities and macros for turbo-tasks and applications based on it.

#![feature(box_syntax)]

mod macros;
pub mod retry;

Expand Down
1 change: 0 additions & 1 deletion crates/turbo-tasks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#![feature(hash_drain_filter)]
#![deny(unsafe_op_in_unsafe_fn)]
#![feature(result_flattening)]
#![feature(box_syntax)]
#![feature(error_generic_member_access)]
#![feature(provide_any)]
#![feature(new_uninit)]
Expand Down
1 change: 0 additions & 1 deletion crates/turbopack-css/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![feature(min_specialization)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(iter_intersperse)]
#![feature(int_roundings)]

Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-css/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ async fn parse_content(
let handler = Handler::with_emitter(
true,
false,
box IssueEmitter {
Box::new(IssueEmitter {
source,
source_map: source_map.clone(),
title: Some("Parsing css source code failed".to_string()),
},
}),
);

let fm = source_map.new_source_file(FileName::Custom(ident_str.to_string()), string);
Expand Down
10 changes: 5 additions & 5 deletions crates/turbopack-css/src/references/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,31 @@ impl ImportAttributes {
}

// something random that's never gonna be in real css
let mut rule = Rule::ListOfComponentValues(box ListOfComponentValues {
let mut rule = Rule::ListOfComponentValues(Box::new(ListOfComponentValues {
span: DUMMY_SP,
children: vec![ComponentValue::PreservedToken(Box::new(token(
Token::String {
value: Default::default(),
raw: r#""""__turbopack_placeholder__""""#.into(),
},
)))],
});
}));

fn at_rule(name: &str, prelude: AtRulePrelude, inner_rule: Rule) -> Rule {
Rule::AtRule(box AtRule {
Rule::AtRule(Box::new(AtRule {
span: DUMMY_SP,
name: AtRuleName::Ident(Ident {
span: DUMMY_SP,
value: name.into(),
raw: None,
}),
prelude: Some(box prelude),
prelude: Some(Box::new(prelude)),
block: Some(SimpleBlock {
span: DUMMY_SP,
name: token(Token::LBrace),
value: vec![ComponentValue::from(inner_rule)],
}),
})
}))
}

if let Some(media) = &self.media {
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-css/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub async fn analyze_css_stylesheet(
let handler = Handler::with_emitter(
true,
false,
box IssueEmitter {
Box::new(IssueEmitter {
source,
source_map: source_map.clone(),
title: None,
},
}),
);
let globals = Globals::new();
HANDLER.set(&handler, || {
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-css/src/references/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ impl CodeGenerateable for UrlAssetReference {

visitors.push(
create_visitor!((&this.path.await?), visit_mut_url(u: &mut Url) {
u.value = Some(box UrlValue::Str(Str {
u.value = Some(Box::new(UrlValue::Str(Str {
span: DUMMY_SP,
value: relative_path.as_str().into(),
raw: None,
}))
})))
}),
);
}
Expand Down
29 changes: 18 additions & 11 deletions crates/turbopack-ecmascript/src/analyzer/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
*value = JsValue::alternatives(
take(alts)
.into_iter()
.map(|alt| JsValue::member(box alt, prop.clone()))
.map(|alt| JsValue::member(Box::new(alt), prop.clone()))
.collect(),
);
true
Expand All @@ -87,7 +87,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
} => {
fn items_to_alternatives(items: &mut Vec<JsValue>, prop: &mut JsValue) -> JsValue {
items.push(JsValue::unknown(
JsValue::member(box JsValue::array(Vec::new()), box take(prop)),
JsValue::member(Box::new(JsValue::array(Vec::new())), Box::new(take(prop))),
"unknown array prototype methods or values",
));
JsValue::alternatives(take(items))
Expand All @@ -105,7 +105,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
true
} else {
*value = JsValue::unknown(
JsValue::member(box take(obj), box take(prop)),
JsValue::member(Box::new(take(obj)), Box::new(take(prop))),
"invalid index",
);
true
Expand All @@ -127,7 +127,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
*value = JsValue::alternatives(
take(alts)
.into_iter()
.map(|alt| JsValue::member(box obj.clone(), box alt))
.map(|alt| JsValue::member(Box::new(obj.clone()), Box::new(alt)))
.collect(),
);
true
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
ObjectPart::Spread(_) => {
values.push(JsValue::unknown(
JsValue::member(
box JsValue::object(vec![take(part)]),
Box::new(JsValue::object(vec![take(part)])),
prop.clone(),
),
"spreaded object",
Expand All @@ -170,7 +170,10 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
}
if include_unknown {
values.push(JsValue::unknown(
JsValue::member(box JsValue::object(Vec::new()), box take(prop)),
JsValue::member(
Box::new(JsValue::object(Vec::new())),
Box::new(take(prop)),
),
"unknown object prototype methods or values",
));
}
Expand Down Expand Up @@ -262,7 +265,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
*value = JsValue::alternatives(
take(alts)
.into_iter()
.map(|alt| JsValue::member(box obj.clone(), box alt))
.map(|alt| JsValue::member(Box::new(obj.clone()), Box::new(alt)))
.collect(),
);
true
Expand Down Expand Up @@ -336,7 +339,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
.enumerate()
.map(|(i, item)| {
JsValue::call(
box func.clone(),
Box::new(func.clone()),
vec![
item,
JsValue::Constant(ConstantValue::Num(
Expand All @@ -361,7 +364,11 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
take(alts)
.into_iter()
.map(|alt| {
JsValue::member_call(box alt, box prop.clone(), args.clone())
JsValue::member_call(
Box::new(alt),
Box::new(prop.clone()),
args.clone(),
)
})
.collect(),
);
Expand All @@ -372,7 +379,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
// without special handling, we convert it into a normal call like
// `(obj.prop)(arg1, arg2, ...)`
*value = JsValue::call(
box JsValue::member(box take(obj), box take(prop)),
Box::new(JsValue::member(Box::new(take(obj)), Box::new(take(prop)))),
take(args),
);
true
Expand All @@ -383,7 +390,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
*value = JsValue::alternatives(
take(alts)
.into_iter()
.map(|alt| JsValue::call(box alt, args.clone()))
.map(|alt| JsValue::call(Box::new(alt), args.clone()))
.collect(),
);
true
Expand Down
Loading

0 comments on commit a77addb

Please sign in to comment.