diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 55afac1a1de..50ab430f148 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -262,10 +262,10 @@ macro_rules! make_MacEager { impl MacEager { $( pub fn $fld(v: $t) -> Box { - box MacEager { + Box::new(MacEager { $fld: Some(v), ..Default::default() - } + }) } )* } @@ -331,7 +331,7 @@ impl DummyResult { /// Use this as a return value after hitting any errors and /// calling `span_err`. pub fn any(sp: Span) -> Box { - box DummyResult { expr_only: false, span: sp } + Box::new(DummyResult { expr_only: false, span: sp }) } /// Create a default MacResult that can only be an expression. @@ -340,7 +340,7 @@ impl DummyResult { /// if an error is encountered internally, the user will receive /// an error that they also used it in the wrong place. pub fn expr(sp: Span) -> Box { - box DummyResult { expr_only: true, span: sp } + Box::new(DummyResult { expr_only: true, span: sp }) } /// A plain dummy expression. diff --git a/src/libsyntax/ext/deriving/cmp/partial_ord.rs b/src/libsyntax/ext/deriving/cmp/partial_ord.rs index 9da2db25f7e..fe6a8fea78c 100644 --- a/src/libsyntax/ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax/ext/deriving/cmp/partial_ord.rs @@ -47,7 +47,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, let ordering_ty = Literal(path_std!(cx, core::cmp::Ordering)); let ret_ty = Literal(Path::new_(pathvec_std!(cx, core::option::Option), None, - vec![box ordering_ty], + vec![Box::new(ordering_ty)], true)); let inline = cx.meta_word(span, InternedString::new("inline")); diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 14f0004101c..0b31f06f87d 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -68,14 +68,14 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, vec!(), true)))) }, explicit_self: None, - args: vec!(Ptr(box Literal(Path::new_local("__D")), + args: vec!(Ptr(Box::new(Literal(Path::new_local("__D"))), Borrowed(None, MutMutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core::result::Result), None, - vec!(box Self_, box Literal(Path::new_( + vec!(Box::new(Self_), Box::new(Literal(Path::new_( vec!["__D", "Error"], None, vec![], false - ))), + )))), true )), attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 175f986f6dd..92944d64933 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -144,14 +144,14 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, vec!(), true)))) }, explicit_self: borrowed_explicit_self(), - args: vec!(Ptr(box Literal(Path::new_local("__S")), + args: vec!(Ptr(Box::new(Literal(Path::new_local("__S"))), Borrowed(None, MutMutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core::result::Result), None, - vec!(box Tuple(Vec::new()), box Literal(Path::new_( + vec!(Box::new(Tuple(Vec::new())), Box::new(Literal(Path::new_( vec!["__S", "Error"], None, vec![], false - ))), + )))), true )), attributes: Vec::new(), diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 4685b4b2954..f73a3969bed 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -807,7 +807,7 @@ impl<'a> MethodDef<'a> { Self_ if nonstatic => { self_args.push(arg_expr); } - Ptr(box Self_, _) if nonstatic => { + Ptr(ref ty, _) if **ty == Self_ && nonstatic => { self_args.push(cx.expr_deref(trait_.span, arg_expr)) } _ => { diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index ec13b86a8ae..9e8e68c0b8c 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -24,7 +24,7 @@ use parse::token::special_idents; use ptr::P; /// The types of pointers -#[derive(Clone)] +#[derive(Clone, Eq, PartialEq)] pub enum PtrTy<'a> { /// &'lifetime mut Borrowed(Option<&'a str>, ast::Mutability), @@ -34,7 +34,7 @@ pub enum PtrTy<'a> { /// A path, e.g. `::std::option::Option::` (global). Has support /// for type parameters and a lifetime. -#[derive(Clone)] +#[derive(Clone, Eq, PartialEq)] pub struct Path<'a> { pub path: Vec<&'a str> , pub lifetime: Option<&'a str>, @@ -85,7 +85,7 @@ impl<'a> Path<'a> { } /// A type. Supports pointers, Self, and literals -#[derive(Clone)] +#[derive(Clone, Eq, PartialEq)] pub enum Ty<'a> { Self_, /// &/Box/ Ty @@ -109,7 +109,7 @@ pub fn borrowed_explicit_self<'r>() -> Option>> { } pub fn borrowed_self<'r>() -> Ty<'r> { - borrowed(box Self_) + borrowed(Box::new(Self_)) } pub fn nil_ty<'r>() -> Ty<'r> { diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index 2f6734b1a14..915d9979615 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -41,7 +41,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, vec![path_std!(cx, core::hash::Hasher)])], }, explicit_self: borrowed_explicit_self(), - args: vec!(Ptr(box Literal(arg), Borrowed(None, MutMutable))), + args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, MutMutable))), ret_ty: nil_ty(), attributes: vec![], combine_substructure: combine_substructure(Box::new(|a, b, c| { diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 625f759fced..3d0645fd6e3 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -40,7 +40,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, args: vec!(Literal(path_local!(i64))), ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option), None, - vec!(box Self_), + vec!(Box::new(Self_)), true)), // #[inline] liable to cause code-bloat attributes: attrs.clone(), @@ -55,7 +55,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, args: vec!(Literal(path_local!(u64))), ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option), None, - vec!(box Self_), + vec!(Box::new(Self_)), true)), // #[inline] liable to cause code-bloat attributes: attrs, diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index f3b0e8a7681..3ce1f6f12ce 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -25,7 +25,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt, push: &mut FnMut(P)) { // &mut ::std::fmt::Formatter - let fmtr = Ptr(box Literal(path_std!(cx, core::fmt::Formatter)), + let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))), Borrowed(None, ast::MutMutable)); let trait_def = TraitDef { diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index d91659bafe4..08bb4ca1064 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -128,7 +128,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree } } - box ExpandResult { p: p } + Box::new(ExpandResult { p: p }) } // include_str! : read the given file, insert it as a literal string expr diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 58df4038403..5521c68e75c 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -165,7 +165,7 @@ pub fn initial_matcher_pos(ms: Rc>, sep: Option, lo: ByteP -> Box { let match_idx_hi = count_names(&ms[..]); let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect(); - box MatcherPos { + Box::new(MatcherPos { stack: vec![], top_elts: TtSeq(ms), sep: sep, @@ -176,7 +176,7 @@ pub fn initial_matcher_pos(ms: Rc>, sep: Option, lo: ByteP match_cur: 0, match_hi: match_idx_hi, sp_lo: lo - } + }) } /// NamedMatch is a pattern-match result for a single token::MATCH_NONTERMINAL: @@ -396,7 +396,7 @@ pub fn parse(sess: &ParseSess, let matches: Vec<_> = (0..ei.matches.len()) .map(|_| Vec::new()).collect(); let ei_t = ei; - cur_eis.push(box MatcherPos { + cur_eis.push(Box::new(MatcherPos { stack: vec![], sep: seq.separator.clone(), idx: 0, @@ -407,7 +407,7 @@ pub fn parse(sess: &ParseSess, up: Some(ei_t), sp_lo: sp.lo, top_elts: Tt(TtSequence(sp, seq)), - }); + })); } TtToken(_, MatchNt(..)) => { // Built-in nonterminals never start with these tokens, @@ -533,7 +533,7 @@ pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal { "ty" => token::NtTy(p.parse_ty()), // this could be handled like a token, since it is one "ident" => match p.token { - token::Ident(sn,b) => { panictry!(p.bump()); token::NtIdent(box sn,b) } + token::Ident(sn,b) => { panictry!(p.bump()); token::NtIdent(Box::new(sn),b) } _ => { let token_str = pprust::token_to_string(&p.token); panic!(p.fatal(&format!("expected ident, found {}", @@ -541,7 +541,7 @@ pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal { } }, "path" => { - token::NtPath(box panictry!(p.parse_path(LifetimeAndTypesWithoutColons))) + token::NtPath(Box::new(panictry!(p.parse_path(LifetimeAndTypesWithoutColons)))) } "meta" => token::NtMeta(p.parse_meta_item()), _ => { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 730da6cc594..27a00290ee0 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -192,7 +192,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, panictry!(p.check_unknown_macro_variable()); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. - return box ParserAnyMacro { + return Box::new(ParserAnyMacro { parser: RefCell::new(p), // Pass along the original expansion site and the name of the macro @@ -200,7 +200,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, // macro leaves unparsed tokens. site_span: sp, macro_ident: name - } + }) } Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { best_fail_spot = sp; @@ -281,12 +281,12 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, _ => cx.span_bug(def.span, "wrong-structured rhs") }; - let exp: Box<_> = box MacroRulesMacroExpander { + let exp: Box<_> = Box::new(MacroRulesMacroExpander { name: def.ident, imported_from: def.imported_from, lhses: lhses, rhses: rhses, - }; + }); NormalTT(exp, Some(def.span), def.allow_internal_unstable) } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index e39b46a2d3e..368a9f0c27e 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -294,9 +294,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { // sidestep the interpolation tricks for ident because // (a) idents can be in lots of places, so it'd be a pain // (b) we actually can, since it's a token. - MatchedNonterminal(NtIdent(box sn, b)) => { + MatchedNonterminal(NtIdent(ref sn, b)) => { r.cur_span = sp; - r.cur_tok = token::Ident(sn, b); + r.cur_tok = token::Ident(**sn, b); return ret_val; } MatchedNonterminal(ref other_whole_nt) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index d7033ce7e48..8ba36cefc65 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -677,10 +677,10 @@ pub fn noop_fold_interpolated(nt: token::Nonterminal, fld: &mut T) token::NtPat(pat) => token::NtPat(fld.fold_pat(pat)), token::NtExpr(expr) => token::NtExpr(fld.fold_expr(expr)), token::NtTy(ty) => token::NtTy(fld.fold_ty(ty)), - token::NtIdent(box id, is_mod_name) => - token::NtIdent(box fld.fold_ident(id), is_mod_name), + token::NtIdent(id, is_mod_name) => + token::NtIdent(Box::new(fld.fold_ident(*id)), is_mod_name), token::NtMeta(meta_item) => token::NtMeta(fld.fold_meta_item(meta_item)), - token::NtPath(box path) => token::NtPath(box fld.fold_path(path)), + token::NtPath(path) => token::NtPath(Box::new(fld.fold_path(*path))), token::NtTT(tt) => token::NtTT(P(fld.fold_tt(&*tt))), } } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 3f36d0e8eda..99fb2798e7a 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -25,8 +25,6 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(box_patterns)] -#![feature(box_syntax)] #![feature(collections)] #![feature(core)] #![feature(libc)] diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4b7b7b66582..c078787120f 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -288,7 +288,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc) // parsing tt's probably shouldn't require a parser at all. let cfg = Vec::new(); let srdr = lexer::StringReader::new(&sess.span_diagnostic, filemap); - let mut p1 = Parser::new(sess, cfg, box srdr); + let mut p1 = Parser::new(sess, cfg, Box::new(srdr)); panictry!(p1.parse_all_token_trees()) } @@ -297,7 +297,7 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess, tts: Vec, cfg: ast::CrateConfig) -> Parser<'a> { let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, None, tts); - let mut p = Parser::new(sess, cfg, box trdr); + let mut p = Parser::new(sess, cfg, Box::new(trdr)); panictry!(p.check_unknown_macro_variable()); p } @@ -360,7 +360,7 @@ pub mod with_hygiene { use super::lexer::make_reader_with_embedded_idents as make_reader; let cfg = Vec::new(); let srdr = make_reader(&sess.span_diagnostic, filemap); - let mut p1 = Parser::new(sess, cfg, box srdr); + let mut p1 = Parser::new(sess, cfg, Box::new(srdr)); panictry!(p1.parse_all_token_trees()) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0515d1ae945..dd00ad31321 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -897,7 +897,7 @@ impl<'a> Parser<'a> { self.last_span = self.span; // Stash token for error recovery (sometimes; clone is not necessarily cheap). self.last_token = if self.token.is_ident() || self.token.is_path() { - Some(box self.token.clone()) + Some(Box::new(self.token.clone())) } else { None }; @@ -1578,8 +1578,8 @@ impl<'a> Parser<'a> { token::Interpolated(token::NtPath(_)) => Some(try!(self.bump_and_get())), _ => None, }; - if let Some(token::Interpolated(token::NtPath(box path))) = found { - return Ok(path); + if let Some(token::Interpolated(token::NtPath(path))) = found { + return Ok(*path); } let lo = self.span.lo; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c51b5d03978..1a5c295cdd6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -188,7 +188,7 @@ pub fn to_string(f: F) -> String where F: FnOnce(&mut State) -> io::Result<()>, { use std::raw::TraitObject; - let mut s = rust_printer(box Vec::new()); + let mut s = rust_printer(Box::new(Vec::new())); f(&mut s).unwrap(); eof(&mut s.s).unwrap(); let wr = unsafe { diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 5032cd57eeb..83e321f110c 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -52,7 +52,7 @@ pub struct P { /// Construct a `P` from a `T` value. pub fn P(value: T) -> P { P { - ptr: box value + ptr: Box::new(value) } }