Skip to content

Commit 99da708

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Remove feature box_syntax
Summary: Towards starlark-rust on stable. Reviewed By: bobyangyf Differential Revision: D41062436 fbshipit-source-id: 5cfd30b067ab16dc2938510748eaf880e1001e4d
1 parent 806848a commit 99da708

File tree

32 files changed

+270
-236
lines changed

32 files changed

+270
-236
lines changed

starlark/src/assert/assert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'a> Assert<'a> {
250250
modules: hashmap!["assert.star".to_owned() => Lazy::force(&ASSERT_STAR).dupe()],
251251
globals: Lazy::force(&GLOBALS).dupe(),
252252
gc_strategy: None,
253-
setup_eval: box |_| (),
253+
setup_eval: Box::new(|_| ()),
254254
print_handler: None,
255255
}
256256
}
@@ -262,7 +262,7 @@ impl<'a> Assert<'a> {
262262

263263
/// Configure a callback which is used to setup evaluator before each evaluation.
264264
pub fn setup_eval(&mut self, setup: impl Fn(&mut Evaluator) + 'static) {
265-
self.setup_eval = box setup;
265+
self.setup_eval = Box::new(setup);
266266
}
267267

268268
/// Configure the handler for `print` function.

starlark/src/environment/globals.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl GlobalsBuilder {
325325
self.set(
326326
name,
327327
NativeFunction {
328-
function: box f,
328+
function: Box::new(f),
329329
name: name.to_owned(),
330330
speculative_exec_safe,
331331
typ,
@@ -426,7 +426,7 @@ impl MethodsBuilder {
426426
self.members.insert(
427427
name,
428428
FrozenValueNotSpecial::new(self.heap.alloc(NativeAttribute {
429-
function: box f,
429+
function: Box::new(f),
430430
speculative_exec_safe,
431431
docstring,
432432
typ,
@@ -450,7 +450,7 @@ impl MethodsBuilder {
450450
self.members.insert(
451451
name,
452452
FrozenValueNotSpecial::new(self.heap.alloc(NativeMethod {
453-
function: box f,
453+
function: Box::new(f),
454454
name: name.to_owned(),
455455
typ,
456456
speculative_exec_safe,

starlark/src/eval/compiler/call.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl CallCompiled {
6363
}
6464
}
6565

66-
ExprCompiled::Call(box IrSpanned {
66+
ExprCompiled::Call(Box::new(IrSpanned {
6767
span,
6868
node: CallCompiled {
6969
fun: IrSpanned {
@@ -72,7 +72,7 @@ impl CallCompiled {
7272
},
7373
args,
7474
},
75-
})
75+
}))
7676
}
7777

7878
/// If this call expression is `len(x)`, return `x`.
@@ -273,10 +273,10 @@ impl CallCompiled {
273273
return CallCompiled::new_method(span, (**this).clone(), field, fun.span, args, ctx);
274274
}
275275

276-
ExprCompiled::Call(box IrSpanned {
276+
ExprCompiled::Call(Box::new(IrSpanned {
277277
span,
278278
node: CallCompiled { fun, args },
279-
})
279+
}))
280280
}
281281
}
282282

starlark/src/eval/compiler/compr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Compiler<'_, '_, '_> {
4040
) -> ExprCompiled {
4141
let clauses = self.compile_clauses(for_, clauses);
4242
let x = self.expr(x);
43-
ExprCompiled::compr(ComprCompiled::List(box x, clauses))
43+
ExprCompiled::compr(ComprCompiled::List(Box::new(x), clauses))
4444
}
4545

4646
pub fn dict_comprehension(
@@ -53,7 +53,7 @@ impl Compiler<'_, '_, '_> {
5353
let clauses = self.compile_clauses(for_, clauses);
5454
let k = self.expr(k);
5555
let v = self.expr(v);
56-
ExprCompiled::compr(ComprCompiled::Dict(box (k, v), clauses))
56+
ExprCompiled::compr(ComprCompiled::Dict(Box::new((k, v)), clauses))
5757
}
5858

5959
/// Peel the final if's from clauses, and return them (in the order they started), plus the next for you get to
@@ -138,13 +138,13 @@ impl ComprCompiled {
138138
match self {
139139
ComprCompiled::List(ref x, ref clauses) => {
140140
let clauses = clauses.optimize(ctx);
141-
ExprCompiled::compr(ComprCompiled::List(box x.optimize(ctx), clauses))
141+
ExprCompiled::compr(ComprCompiled::List(Box::new(x.optimize(ctx)), clauses))
142142
}
143143
ComprCompiled::Dict(k_v, ref clauses) => {
144144
let (k, v) = &**k_v;
145145
let clauses = clauses.optimize(ctx);
146146
ExprCompiled::compr(ComprCompiled::Dict(
147-
box (k.optimize(ctx), v.optimize(ctx)),
147+
Box::new((k.optimize(ctx), v.optimize(ctx))),
148148
clauses.optimize(ctx),
149149
))
150150
}

starlark/src/eval/compiler/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl Compiler<'_, '_, '_> {
379379
// scope
380380
let params = params.into_map(|x| self.parameter(x));
381381
let params = ParametersCompiled { params };
382-
let return_type = self.expr_for_type(return_type).map(|t| box t);
382+
let return_type = self.expr_for_type(return_type).map(Box::new);
383383

384384
self.enter_scope(scope_id);
385385

starlark/src/eval/compiler/def_inline/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'s, 'v, 'a, 'e> InlineDefCallSite<'s, 'v, 'a, 'e> {
319319
let c = self.inline_opt(c.as_ref())?;
320320
IrSpanned {
321321
span,
322-
node: ExprCompiled::Slice(box (l, a, b, c)),
322+
node: ExprCompiled::Slice(Box::new((l, a, b, c))),
323323
}
324324
}
325325
ExprCompiled::Seq(a_b) => {

starlark/src/eval/compiler/expr.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl ExprCompiled {
537537

538538
IrSpanned {
539539
span,
540-
node: ExprCompiled::Builtin2(Builtin2::Equals, box (l, r)),
540+
node: ExprCompiled::Builtin2(Builtin2::Equals, Box::new((l, r))),
541541
}
542542
}
543543

@@ -553,7 +553,7 @@ impl ExprCompiled {
553553
// Collapse `not not e` to `e` only if `e` is known to produce a boolean.
554554
ExprCompiled::Builtin1(Builtin1::Not, e) if e.is_definitely_bool() => (*e).clone(),
555555
_ => IrSpanned {
556-
node: ExprCompiled::Builtin1(Builtin1::Not, box expr),
556+
node: ExprCompiled::Builtin1(Builtin1::Not, Box::new(expr)),
557557
span,
558558
},
559559
}
@@ -581,7 +581,7 @@ impl ExprCompiled {
581581
} else {
582582
let span = l.span.merge(&r.span);
583583
IrSpanned {
584-
node: ExprCompiled::LogicalBinOp(op, box (l, r)),
584+
node: ExprCompiled::LogicalBinOp(op, Box::new((l, r))),
585585
span,
586586
}
587587
}
@@ -596,7 +596,7 @@ impl ExprCompiled {
596596
} else {
597597
let span = l.span.merge(&r.span);
598598
IrSpanned {
599-
node: ExprCompiled::Seq(box (l, r)),
599+
node: ExprCompiled::Seq(Box::new((l, r))),
600600
span,
601601
}
602602
}
@@ -614,7 +614,7 @@ impl ExprCompiled {
614614
return ExprCompiled::percent_s_one(before, r, after, ctx);
615615
}
616616
}
617-
ExprCompiled::Builtin2(Builtin2::Percent, box (l, r))
617+
ExprCompiled::Builtin2(Builtin2::Percent, Box::new((l, r)))
618618
}
619619

620620
fn percent_s_one(
@@ -632,7 +632,7 @@ impl ExprCompiled {
632632
}
633633
}
634634

635-
ExprCompiled::Builtin1(Builtin1::PercentSOne(before, after), box arg)
635+
ExprCompiled::Builtin1(Builtin1::PercentSOne(before, after), Box::new(arg))
636636
}
637637

638638
pub(crate) fn format_one(
@@ -647,7 +647,7 @@ impl ExprCompiled {
647647
return ExprCompiled::Value(value.to_frozen_value());
648648
}
649649

650-
ExprCompiled::Builtin1(Builtin1::FormatOne(before, after), box arg)
650+
ExprCompiled::Builtin1(Builtin1::FormatOne(before, after), Box::new(arg))
651651
}
652652

653653
fn add(l: IrSpanned<ExprCompiled>, r: IrSpanned<ExprCompiled>) -> ExprCompiled {
@@ -663,7 +663,7 @@ impl ExprCompiled {
663663
.collect();
664664
return ExprCompiled::List(lr);
665665
}
666-
ExprCompiled::Builtin2(Builtin2::Add, box (l, r))
666+
ExprCompiled::Builtin2(Builtin2::Add, Box::new((l, r)))
667667
}
668668

669669
pub(crate) fn bin_op(
@@ -688,7 +688,7 @@ impl ExprCompiled {
688688
Builtin2::Add => ExprCompiled::add(l, r),
689689
Builtin2::Equals => ExprCompiled::equals(l, r).node,
690690
Builtin2::ArrayIndex => ExprCompiled::array_indirection(l, r, ctx),
691-
bin_op => ExprCompiled::Builtin2(bin_op, box (l, r)),
691+
bin_op => ExprCompiled::Builtin2(bin_op, Box::new((l, r))),
692692
}
693693
}
694694

@@ -715,7 +715,7 @@ impl ExprCompiled {
715715
};
716716
let span = cond.span.merge(&t.span).merge(&f.span);
717717
IrSpanned {
718-
node: ExprCompiled::If(box (cond, t, f)),
718+
node: ExprCompiled::If(Box::new((cond, t, f))),
719719
span,
720720
}
721721
}
@@ -746,7 +746,7 @@ impl ExprCompiled {
746746
Builtin1::Dot(field) => ExprCompiled::dot(expr, field, ctx),
747747
Builtin1::TypeIs(t) => ExprCompiled::type_is(expr, *t),
748748
Builtin1::Not => ExprCompiled::not(span, expr).node,
749-
op => ExprCompiled::Builtin1(op.clone(), box expr),
749+
op => ExprCompiled::Builtin1(op.clone(), Box::new(expr)),
750750
}
751751
}
752752

@@ -813,7 +813,7 @@ impl ExprCompiled {
813813
if clauses.is_nop() {
814814
ExprCompiled::Dict(Vec::new())
815815
} else {
816-
ExprCompiled::Compr(ComprCompiled::Dict(box (k, v), clauses))
816+
ExprCompiled::Compr(ComprCompiled::Dict(Box::new((k, v)), clauses))
817817
}
818818
}
819819
}
@@ -857,7 +857,7 @@ impl ExprCompiled {
857857
}
858858
}
859859

860-
ExprCompiled::Builtin1(Builtin1::Dot(field.clone()), box object)
860+
ExprCompiled::Builtin1(Builtin1::Dot(field.clone()), Box::new(object))
861861
}
862862

863863
fn slice(
@@ -885,7 +885,7 @@ impl ExprCompiled {
885885
}
886886
}
887887
}
888-
ExprCompiled::Slice(box (array, start, stop, step))
888+
ExprCompiled::Slice(Box::new((array, start, stop, step)))
889889
}
890890

891891
pub(crate) fn array_indirection(
@@ -901,7 +901,7 @@ impl ExprCompiled {
901901
}
902902
}
903903
}
904-
ExprCompiled::Builtin2(Builtin2::ArrayIndex, box (array, index))
904+
ExprCompiled::Builtin2(Builtin2::ArrayIndex, Box::new((array, index)))
905905
}
906906

907907
pub(crate) fn typ(span: FrozenFileSpan, v: IrSpanned<ExprCompiled>) -> ExprCompiled {
@@ -923,7 +923,7 @@ impl ExprCompiled {
923923
{
924924
ExprCompiled::Value(StarlarkBool::get_type_value_static().to_frozen_value())
925925
}
926-
_ => ExprCompiled::Call(box IrSpanned {
926+
_ => ExprCompiled::Call(Box::new(IrSpanned {
927927
span,
928928
node: CallCompiled {
929929
fun: IrSpanned {
@@ -935,7 +935,7 @@ impl ExprCompiled {
935935
..ArgsCompiledValue::default()
936936
},
937937
},
938-
}),
938+
})),
939939
}
940940
}
941941

@@ -945,7 +945,7 @@ impl ExprCompiled {
945945
v.to_value().get_type() == t.as_str(),
946946
));
947947
}
948-
ExprCompiled::Builtin1(Builtin1::TypeIs(t), box v)
948+
ExprCompiled::Builtin1(Builtin1::TypeIs(t), Box::new(v))
949949
}
950950

951951
pub(crate) fn len(span: FrozenFileSpan, arg: IrSpanned<ExprCompiled>) -> ExprCompiled {
@@ -954,7 +954,7 @@ impl ExprCompiled {
954954
return ExprCompiled::Value(FrozenValue::new_int(len));
955955
}
956956
}
957-
ExprCompiled::Call(box IrSpanned {
957+
ExprCompiled::Call(Box::new(IrSpanned {
958958
span,
959959
node: CallCompiled {
960960
fun: IrSpanned {
@@ -966,7 +966,7 @@ impl ExprCompiled {
966966
..ArgsCompiledValue::default()
967967
},
968968
},
969-
})
969+
}))
970970
}
971971
}
972972

starlark/src/eval/compiler/expr_bool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl ExprCompiledBool {
7878
None => IrSpanned {
7979
node: ExprCompiledBool::Expr(ExprCompiled::Builtin1(
8080
Builtin1::Not,
81-
box x.into_expr(),
81+
Box::new(x.into_expr()),
8282
)),
8383
span,
8484
},
@@ -126,7 +126,7 @@ impl ExprCompiledBool {
126126
(op, None, None) => IrSpanned {
127127
node: ExprCompiledBool::Expr(ExprCompiled::LogicalBinOp(
128128
op,
129-
box (x.into_expr(), y.into_expr()),
129+
Box::new((x.into_expr(), y.into_expr())),
130130
)),
131131
span,
132132
},

starlark/src/eval/compiler/stmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl StmtsCompiled {
322322
} else {
323323
StmtsCompiled::one(IrSpanned {
324324
span,
325-
node: StmtCompiled::If(box (cond, t, f)),
325+
node: StmtCompiled::If(Box::new((cond, t, f))),
326326
})
327327
}
328328
}
@@ -341,7 +341,7 @@ impl StmtsCompiled {
341341
}
342342
StmtsCompiled::one(IrSpanned {
343343
span,
344-
node: StmtCompiled::For(box (var, over, body)),
344+
node: StmtCompiled::For(Box::new((var, over, body))),
345345
})
346346
}
347347
}
@@ -788,7 +788,7 @@ impl Compiler<'_, '_, '_> {
788788
StmtP::Assign(lhs, ty_rhs) => {
789789
let (ty, rhs) = *ty_rhs;
790790
let rhs = self.expr(rhs);
791-
let ty = self.expr_for_type(ty.map(|x| box x));
791+
let ty = self.expr_for_type(ty.map(Box::new));
792792
let lhs = self.assign(lhs);
793793
StmtsCompiled::one(IrSpanned {
794794
span,

starlark/src/eval/runtime/arguments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'v, 'a> Arguments<'v, 'a> {
465465
// Very sad that we allocate into a vector, but I expect calling into a small positional argument
466466
// with a *args is very rare.
467467
let args = match x.0.args {
468-
None => box None.into_iter(),
468+
None => Box::new(None.into_iter()),
469469
Some(args) => args.iterate(heap)?,
470470
};
471471
let xs = x.0.pos.iter().copied().chain(args).collect::<Vec<_>>();

0 commit comments

Comments
 (0)