diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-15 09:52:21 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-03-03 21:05:55 +0100 |
| commit | 0d5bcb14adb71900a99f06b92485de7e019734c2 (patch) | |
| tree | 37b9faace62c6658ff6ecf9d646e04c01be875fb /src/libsyntax/ext | |
| parent | b03279aaa2b20f6033e66fc7aea29c0b43e71082 (diff) | |
| download | rust-0d5bcb14adb71900a99f06b92485de7e019734c2.tar.gz rust-0d5bcb14adb71900a99f06b92485de7e019734c2.zip | |
Switched to Box::new in many places.
Many of the modifications putting in `Box::new` calls also include a pointer to Issue 22405, which tracks going back to `box <expr>` if possible in the future. (Still tried to use `Box<_>` where it sufficed; thus some tests still have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.) Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/clone.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/eq.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totaleq.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totalord.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/decodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/default.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/hash.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/primitive.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/show.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 4 |
15 files changed, 44 insertions, 43 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e5d1fe2388c..ad5ca627a93 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -465,7 +465,7 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>) -> SyntaxEnv { // utility function to simplify creating NormalTT syntax extensions fn builtin_normal_expander(f: MacroExpanderFn) -> SyntaxExtension { - NormalTT(box f, None) + NormalTT(Box::new(f), None) } let mut syntax_expanders = SyntaxEnv::new(); @@ -489,9 +489,9 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>) builtin_normal_expander( ext::log_syntax::expand_syntax_ext)); syntax_expanders.insert(intern("derive"), - Decorator(box ext::deriving::expand_meta_derive)); + Decorator(Box::new(ext::deriving::expand_meta_derive))); syntax_expanders.insert(intern("deriving"), - Decorator(box ext::deriving::expand_deprecated_deriving)); + Decorator(Box::new(ext::deriving::expand_deprecated_deriving))); if ecfg.enable_quotes() { // Quasi-quoting expanders diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 5f460264216..f89f3ab55f3 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -40,9 +40,9 @@ pub fn expand_deriving_clone<F>(cx: &mut ExtCtxt, args: Vec::new(), ret_ty: Self_, attributes: attrs, - combine_substructure: combine_substructure(box |c, s, sub| { + combine_substructure: combine_substructure(Box::new(|c, s, sub| { cs_clone("Clone", c, s, sub) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 80ef882745f..c02af437b1c 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -40,7 +40,7 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt, cx.expr_binary(span, ast::BiAnd, subexpr, eq) }, cx.expr_bool(span, true), - box |cx, span, _, _| cx.expr_bool(span, false), + Box::new(|cx, span, _, _| cx.expr_bool(span, false)), cx, span, substr) } fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> { @@ -57,7 +57,7 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt, cx.expr_binary(span, ast::BiOr, subexpr, eq) }, cx.expr_bool(span, false), - box |cx, span, _, _| cx.expr_bool(span, true), + Box::new(|cx, span, _, _| cx.expr_bool(span, true)), cx, span, substr) } @@ -72,9 +72,9 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(path_local!(bool)), attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { $f(a, b, c) - }) + })) } } } } diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index be4a33002aa..b2b26548018 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -38,9 +38,9 @@ pub fn expand_deriving_ord<F>(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(path_local!(bool)), attributes: attrs, - combine_substructure: combine_substructure(box |cx, span, substr| { + combine_substructure: combine_substructure(Box::new(|cx, span, substr| { cs_op($op, $equal, cx, span, substr) - }) + })) } } } } @@ -61,9 +61,9 @@ pub fn expand_deriving_ord<F>(cx: &mut ExtCtxt, args: vec![borrowed_self()], ret_ty: ret_ty, attributes: attrs, - combine_substructure: combine_substructure(box |cx, span, substr| { + combine_substructure: combine_substructure(Box::new(|cx, span, substr| { cs_partial_cmp(cx, span, substr) - }) + })) }; let trait_def = TraitDef { @@ -175,13 +175,13 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, cx.expr_block(cx.block(span, vec!(assign), Some(if_))) }, equals_expr.clone(), - box |cx, span, (self_args, tag_tuple), _non_self_args| { + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") } else { some_ordering_collapsed(cx, span, PartialCmpOp, tag_tuple) } - }, + }), cx, span, substr) } @@ -223,7 +223,7 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, cx.expr_binary(span, ast::BiOr, cmp, and) }, cx.expr_bool(span, equal), - box |cx, span, (self_args, tag_tuple), _non_self_args| { + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") } else { @@ -233,6 +233,6 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, }; some_ordering_collapsed(cx, span, op, tag_tuple) } - }, + }), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 31a754a1254..83164d242e8 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -32,7 +32,8 @@ pub fn expand_deriving_totaleq<F>(cx: &mut ExtCtxt, let block = cx.block(span, stmts, None); cx.expr_block(block) }, - box |cx, sp, _, _| cx.span_bug(sp, "non matching enums in derive(Eq)?"), + Box::new(|cx, sp, _, _| { + cx.span_bug(sp, "non matching enums in derive(Eq)?") }), cx, span, substr) @@ -57,9 +58,9 @@ pub fn expand_deriving_totaleq<F>(cx: &mut ExtCtxt, args: vec!(), ret_ty: nil_ty(), attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { cs_total_eq_assert(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 2f6f99bc1ee..1de955856e7 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -41,9 +41,9 @@ pub fn expand_deriving_totalord<F>(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(path_std!(cx, core::cmp::Ordering)), attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { cs_cmp(a, b, c) - }), + })), } ), associated_types: Vec::new(), @@ -131,12 +131,12 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, cx.expr_block(cx.block(span, vec!(assign), Some(if_))) }, cx.expr_path(equals_path.clone()), - box |cx, span, (self_args, tag_tuple), _non_self_args| { + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derives(Ord)`") } else { ordering_collapsed(cx, span, tag_tuple) } - }, + }), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index f27bbc338e5..6ce68948e4b 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -82,9 +82,9 @@ fn expand_deriving_decodable_imp<F>(cx: &mut ExtCtxt, true )), attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { decodable_substructure(a, b, c, krate) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index c10975a2d32..f9991a23354 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -40,9 +40,9 @@ pub fn expand_deriving_default<F>(cx: &mut ExtCtxt, args: Vec::new(), ret_ty: Self_, attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { default_substructure(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 17687534d75..d7961d7da00 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -158,9 +158,9 @@ fn expand_deriving_encodable_imp<F>(cx: &mut ExtCtxt, true )), attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { encodable_substructure(a, b, c) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index 2149c7a7f77..da80c7a0e6d 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -45,9 +45,9 @@ pub fn expand_deriving_hash<F>(cx: &mut ExtCtxt, args: vec!(Ptr(box Literal(arg), Borrowed(None, MutMutable))), ret_ty: nil_ty(), attributes: vec![], - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { hash_substructure(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 3b96292323a..b2d0a9f6b51 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -45,9 +45,9 @@ pub fn expand_deriving_from_primitive<F>(cx: &mut ExtCtxt, true)), // #[inline] liable to cause code-bloat attributes: attrs.clone(), - combine_substructure: combine_substructure(box |c, s, sub| { + combine_substructure: combine_substructure(Box::new(|c, s, sub| { cs_from("i64", c, s, sub) - }), + })), }, MethodDef { name: "from_u64", @@ -60,9 +60,9 @@ pub fn expand_deriving_from_primitive<F>(cx: &mut ExtCtxt, true)), // #[inline] liable to cause code-bloat attributes: attrs, - combine_substructure: combine_substructure(box |c, s, sub| { + combine_substructure: combine_substructure(Box::new(|c, s, sub| { cs_from("u64", c, s, sub) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 029b6535108..8a764fded6f 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -55,9 +55,9 @@ pub fn expand_deriving_rand<F>(cx: &mut ExtCtxt, ), ret_ty: Self_, attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { rand_substructure(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 281f23f9e61..ce89c541fd4 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -46,9 +46,9 @@ pub fn expand_deriving_show<F>(cx: &mut ExtCtxt, args: vec!(fmtr), ret_ty: Literal(path_std!(cx, core::fmt::Result)), attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { show_substructure(a, b, c) - }) + })) } ], associated_types: Vec::new(), diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index ce513bc91f5..0ac78209b6f 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -479,7 +479,7 @@ pub fn parse(sess: &ParseSess, } rdr.next_token(); } else /* bb_eis.len() == 1 */ { - let mut rust_parser = Parser::new(sess, cfg.clone(), box rdr.clone()); + let mut rust_parser = Parser::new(sess, cfg.clone(), Box::new(rdr.clone())); let mut ei = bb_eis.pop().unwrap(); match ei.top_elts.get_tt(ei.idx) { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 67011ad21a6..db7db4b83ac 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -180,7 +180,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, Some(named_matches), imported_from, rhs); - let mut p = Parser::new(cx.parse_sess(), cx.cfg(), box trncbr); + let mut p = Parser::new(cx.parse_sess(), cx.cfg(), Box::new(trncbr)); p.check_unknown_macro_variable(); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. @@ -267,7 +267,7 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, _ => cx.span_bug(def.span, "wrong-structured rhs") }; - let exp = box MacroRulesMacroExpander { + let exp: Box<_> = box MacroRulesMacroExpander { name: def.ident, imported_from: def.imported_from, lhses: lhses, |
