diff options
| author | bors <bors@rust-lang.org> | 2015-03-03 20:17:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-03 20:17:08 +0000 |
| commit | fed12499e7d91f9cdfba5833e34d20e8fd19b898 (patch) | |
| tree | 2c5b377f6a53498f2555965e4903b77e4c8aad30 /src/libsyntax | |
| parent | 129173f1980e9ac03f7ef0fc0193c41235d07649 (diff) | |
| parent | cb1b0dd589c80c3edb94b8982ea33e000978f572 (diff) | |
| download | rust-fed12499e7d91f9cdfba5833e34d20e8fd19b898.tar.gz rust-fed12499e7d91f9cdfba5833e34d20e8fd19b898.zip | |
Auto merge of #23002 - pnkfelix:fsk-box-place-runway, r=nikomatsakis
Runway for RFC 809 (overloaded box/placement-in) by adding type annotations or explicit calls to `Box::new` where I found it necessary on PR #22086. I have broken this up into more than one PR because the entire commit chain (see PR #22086) is long, widespread and unwieldy to rebase frequently. To my knowledge this is not a breaking change. Also, there is in principle nothing stopping someone from reverting some/all of these annotations, since without the rest of the commit chain in #22086, the associated code would continue to compile. All I can do is ask: Try to discourage others from removing seemingly "unnecessary" uses of the `Box` type or the `Box::new()` function, until the rest of RFC 809 lands.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 6 | ||||
| -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 | ||||
| -rw-r--r-- | src/libsyntax/owned_slice.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 5 |
18 files changed, 51 insertions, 49 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index a6f4974502c..e094cbcac53 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -223,7 +223,7 @@ pub fn mk_span_handler(handler: Handler, cm: codemap::CodeMap) -> SpanHandler { pub fn default_handler(color_config: ColorConfig, registry: Option<diagnostics::registry::Registry>, can_emit_warnings: bool) -> Handler { - mk_handler(can_emit_warnings, box EmitterWriter::stderr(color_config, registry)) + mk_handler(can_emit_warnings, Box::new(EmitterWriter::stderr(color_config, registry))) } pub fn mk_handler(can_emit_warnings: bool, e: Box<Emitter + Send>) -> Handler { @@ -352,11 +352,11 @@ impl EmitterWriter { if use_color { let dst = match term::stderr() { Some(t) => Terminal(t), - None => Raw(box stderr), + None => Raw(Box::new(stderr)), }; EmitterWriter { dst: dst, registry: registry } } else { - EmitterWriter { dst: Raw(box stderr), registry: registry } + EmitterWriter { dst: Raw(Box::new(stderr)), registry: registry } } } 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, diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index f5201d4a8bc..25f1f9b8480 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -30,7 +30,7 @@ impl<T:fmt::Debug> fmt::Debug for OwnedSlice<T> { impl<T> OwnedSlice<T> { pub fn empty() -> OwnedSlice<T> { - OwnedSlice { data: box [] } + OwnedSlice { data: Box::new([]) } } #[inline(never)] diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 83d2bb0cc70..bbe1ddfd4cf 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1484,8 +1484,9 @@ mod test { use std::old_io::util; fn mk_sh() -> diagnostic::SpanHandler { - let emitter = diagnostic::EmitterWriter::new(box util::NullWriter, None); - let handler = diagnostic::mk_handler(true, box emitter); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let emitter = diagnostic::EmitterWriter::new(Box::new(util::NullWriter), None); + let handler = diagnostic::mk_handler(true, Box::new(emitter)); diagnostic::mk_span_handler(handler, CodeMap::new()) } |
