syntax: remove #![feature(box_syntax, box_patterns)]

This commit is contained in:
Erick Tryzelaar 2015-04-15 20:56:16 -07:00
parent 7397bdc9c5
commit a4541b02a3
19 changed files with 44 additions and 46 deletions

View file

@ -262,10 +262,10 @@ macro_rules! make_MacEager {
impl MacEager { impl MacEager {
$( $(
pub fn $fld(v: $t) -> Box<MacResult> { pub fn $fld(v: $t) -> Box<MacResult> {
box MacEager { Box::new(MacEager {
$fld: Some(v), $fld: Some(v),
..Default::default() ..Default::default()
} })
} }
)* )*
} }
@ -331,7 +331,7 @@ impl DummyResult {
/// Use this as a return value after hitting any errors and /// Use this as a return value after hitting any errors and
/// calling `span_err`. /// calling `span_err`.
pub fn any(sp: Span) -> Box<MacResult+'static> { pub fn any(sp: Span) -> Box<MacResult+'static> {
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. /// 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 /// if an error is encountered internally, the user will receive
/// an error that they also used it in the wrong place. /// an error that they also used it in the wrong place.
pub fn expr(sp: Span) -> Box<MacResult+'static> { pub fn expr(sp: Span) -> Box<MacResult+'static> {
box DummyResult { expr_only: true, span: sp } Box::new(DummyResult { expr_only: true, span: sp })
} }
/// A plain dummy expression. /// A plain dummy expression.

View file

@ -47,7 +47,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
let ordering_ty = Literal(path_std!(cx, core::cmp::Ordering)); let ordering_ty = Literal(path_std!(cx, core::cmp::Ordering));
let ret_ty = Literal(Path::new_(pathvec_std!(cx, core::option::Option), let ret_ty = Literal(Path::new_(pathvec_std!(cx, core::option::Option),
None, None,
vec![box ordering_ty], vec![Box::new(ordering_ty)],
true)); true));
let inline = cx.meta_word(span, InternedString::new("inline")); let inline = cx.meta_word(span, InternedString::new("inline"));

View file

@ -68,14 +68,14 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
vec!(), true)))) vec!(), true))))
}, },
explicit_self: None, 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))), Borrowed(None, MutMutable))),
ret_ty: Literal(Path::new_( ret_ty: Literal(Path::new_(
pathvec_std!(cx, core::result::Result), pathvec_std!(cx, core::result::Result),
None, None,
vec!(box Self_, box Literal(Path::new_( vec!(Box::new(Self_), Box::new(Literal(Path::new_(
vec!["__D", "Error"], None, vec![], false vec!["__D", "Error"], None, vec![], false
))), )))),
true true
)), )),
attributes: Vec::new(), attributes: Vec::new(),

View file

@ -144,14 +144,14 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
vec!(), true)))) vec!(), true))))
}, },
explicit_self: borrowed_explicit_self(), 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))), Borrowed(None, MutMutable))),
ret_ty: Literal(Path::new_( ret_ty: Literal(Path::new_(
pathvec_std!(cx, core::result::Result), pathvec_std!(cx, core::result::Result),
None, 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 vec!["__S", "Error"], None, vec![], false
))), )))),
true true
)), )),
attributes: Vec::new(), attributes: Vec::new(),

View file

@ -807,7 +807,7 @@ impl<'a> MethodDef<'a> {
Self_ if nonstatic => { Self_ if nonstatic => {
self_args.push(arg_expr); 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)) self_args.push(cx.expr_deref(trait_.span, arg_expr))
} }
_ => { _ => {

View file

@ -24,7 +24,7 @@ use parse::token::special_idents;
use ptr::P; use ptr::P;
/// The types of pointers /// The types of pointers
#[derive(Clone)] #[derive(Clone, Eq, PartialEq)]
pub enum PtrTy<'a> { pub enum PtrTy<'a> {
/// &'lifetime mut /// &'lifetime mut
Borrowed(Option<&'a str>, ast::Mutability), Borrowed(Option<&'a str>, ast::Mutability),
@ -34,7 +34,7 @@ pub enum PtrTy<'a> {
/// A path, e.g. `::std::option::Option::<i32>` (global). Has support /// A path, e.g. `::std::option::Option::<i32>` (global). Has support
/// for type parameters and a lifetime. /// for type parameters and a lifetime.
#[derive(Clone)] #[derive(Clone, Eq, PartialEq)]
pub struct Path<'a> { pub struct Path<'a> {
pub path: Vec<&'a str> , pub path: Vec<&'a str> ,
pub lifetime: Option<&'a str>, pub lifetime: Option<&'a str>,
@ -85,7 +85,7 @@ impl<'a> Path<'a> {
} }
/// A type. Supports pointers, Self, and literals /// A type. Supports pointers, Self, and literals
#[derive(Clone)] #[derive(Clone, Eq, PartialEq)]
pub enum Ty<'a> { pub enum Ty<'a> {
Self_, Self_,
/// &/Box/ Ty /// &/Box/ Ty
@ -109,7 +109,7 @@ pub fn borrowed_explicit_self<'r>() -> Option<Option<PtrTy<'r>>> {
} }
pub fn borrowed_self<'r>() -> Ty<'r> { pub fn borrowed_self<'r>() -> Ty<'r> {
borrowed(box Self_) borrowed(Box::new(Self_))
} }
pub fn nil_ty<'r>() -> Ty<'r> { pub fn nil_ty<'r>() -> Ty<'r> {

View file

@ -41,7 +41,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
vec![path_std!(cx, core::hash::Hasher)])], vec![path_std!(cx, core::hash::Hasher)])],
}, },
explicit_self: borrowed_explicit_self(), 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(), ret_ty: nil_ty(),
attributes: vec![], attributes: vec![],
combine_substructure: combine_substructure(Box::new(|a, b, c| { combine_substructure: combine_substructure(Box::new(|a, b, c| {

View file

@ -40,7 +40,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
args: vec!(Literal(path_local!(i64))), args: vec!(Literal(path_local!(i64))),
ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option), ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option),
None, None,
vec!(box Self_), vec!(Box::new(Self_)),
true)), true)),
// #[inline] liable to cause code-bloat // #[inline] liable to cause code-bloat
attributes: attrs.clone(), attributes: attrs.clone(),
@ -55,7 +55,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
args: vec!(Literal(path_local!(u64))), args: vec!(Literal(path_local!(u64))),
ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option), ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option),
None, None,
vec!(box Self_), vec!(Box::new(Self_)),
true)), true)),
// #[inline] liable to cause code-bloat // #[inline] liable to cause code-bloat
attributes: attrs, attributes: attrs,

View file

@ -25,7 +25,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt,
push: &mut FnMut(P<Item>)) push: &mut FnMut(P<Item>))
{ {
// &mut ::std::fmt::Formatter // &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)); Borrowed(None, ast::MutMutable));
let trait_def = TraitDef { let trait_def = TraitDef {

View file

@ -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 // include_str! : read the given file, insert it as a literal string expr

View file

@ -165,7 +165,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
-> Box<MatcherPos> { -> Box<MatcherPos> {
let match_idx_hi = count_names(&ms[..]); let match_idx_hi = count_names(&ms[..]);
let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect(); let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect();
box MatcherPos { Box::new(MatcherPos {
stack: vec![], stack: vec![],
top_elts: TtSeq(ms), top_elts: TtSeq(ms),
sep: sep, sep: sep,
@ -176,7 +176,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
match_cur: 0, match_cur: 0,
match_hi: match_idx_hi, match_hi: match_idx_hi,
sp_lo: lo sp_lo: lo
} })
} }
/// NamedMatch is a pattern-match result for a single token::MATCH_NONTERMINAL: /// 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()) let matches: Vec<_> = (0..ei.matches.len())
.map(|_| Vec::new()).collect(); .map(|_| Vec::new()).collect();
let ei_t = ei; let ei_t = ei;
cur_eis.push(box MatcherPos { cur_eis.push(Box::new(MatcherPos {
stack: vec![], stack: vec![],
sep: seq.separator.clone(), sep: seq.separator.clone(),
idx: 0, idx: 0,
@ -407,7 +407,7 @@ pub fn parse(sess: &ParseSess,
up: Some(ei_t), up: Some(ei_t),
sp_lo: sp.lo, sp_lo: sp.lo,
top_elts: Tt(TtSequence(sp, seq)), top_elts: Tt(TtSequence(sp, seq)),
}); }));
} }
TtToken(_, MatchNt(..)) => { TtToken(_, MatchNt(..)) => {
// Built-in nonterminals never start with these tokens, // 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()), "ty" => token::NtTy(p.parse_ty()),
// this could be handled like a token, since it is one // this could be handled like a token, since it is one
"ident" => match p.token { "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); let token_str = pprust::token_to_string(&p.token);
panic!(p.fatal(&format!("expected ident, found {}", panic!(p.fatal(&format!("expected ident, found {}",
@ -541,7 +541,7 @@ pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal {
} }
}, },
"path" => { "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()), "meta" => token::NtMeta(p.parse_meta_item()),
_ => { _ => {

View file

@ -192,7 +192,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
panictry!(p.check_unknown_macro_variable()); panictry!(p.check_unknown_macro_variable());
// Let the context choose how to interpret the result. // Let the context choose how to interpret the result.
// Weird, but useful for X-macros. // Weird, but useful for X-macros.
return box ParserAnyMacro { return Box::new(ParserAnyMacro {
parser: RefCell::new(p), parser: RefCell::new(p),
// Pass along the original expansion site and the name of the macro // 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. // macro leaves unparsed tokens.
site_span: sp, site_span: sp,
macro_ident: name macro_ident: name
} })
} }
Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo {
best_fail_spot = sp; best_fail_spot = sp;
@ -281,12 +281,12 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
_ => cx.span_bug(def.span, "wrong-structured rhs") _ => cx.span_bug(def.span, "wrong-structured rhs")
}; };
let exp: Box<_> = box MacroRulesMacroExpander { let exp: Box<_> = Box::new(MacroRulesMacroExpander {
name: def.ident, name: def.ident,
imported_from: def.imported_from, imported_from: def.imported_from,
lhses: lhses, lhses: lhses,
rhses: rhses, rhses: rhses,
}; });
NormalTT(exp, Some(def.span), def.allow_internal_unstable) NormalTT(exp, Some(def.span), def.allow_internal_unstable)
} }

View file

@ -294,9 +294,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
// sidestep the interpolation tricks for ident because // sidestep the interpolation tricks for ident because
// (a) idents can be in lots of places, so it'd be a pain // (a) idents can be in lots of places, so it'd be a pain
// (b) we actually can, since it's a token. // (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_span = sp;
r.cur_tok = token::Ident(sn, b); r.cur_tok = token::Ident(**sn, b);
return ret_val; return ret_val;
} }
MatchedNonterminal(ref other_whole_nt) => { MatchedNonterminal(ref other_whole_nt) => {

View file

@ -677,10 +677,10 @@ pub fn noop_fold_interpolated<T: Folder>(nt: token::Nonterminal, fld: &mut T)
token::NtPat(pat) => token::NtPat(fld.fold_pat(pat)), token::NtPat(pat) => token::NtPat(fld.fold_pat(pat)),
token::NtExpr(expr) => token::NtExpr(fld.fold_expr(expr)), token::NtExpr(expr) => token::NtExpr(fld.fold_expr(expr)),
token::NtTy(ty) => token::NtTy(fld.fold_ty(ty)), token::NtTy(ty) => token::NtTy(fld.fold_ty(ty)),
token::NtIdent(box id, is_mod_name) => token::NtIdent(id, is_mod_name) =>
token::NtIdent(box fld.fold_ident(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::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))), token::NtTT(tt) => token::NtTT(P(fld.fold_tt(&*tt))),
} }
} }

View file

@ -25,8 +25,6 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)] #![feature(collections)]
#![feature(core)] #![feature(core)]
#![feature(libc)] #![feature(libc)]

View file

@ -288,7 +288,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc<FileMap>)
// parsing tt's probably shouldn't require a parser at all. // parsing tt's probably shouldn't require a parser at all.
let cfg = Vec::new(); let cfg = Vec::new();
let srdr = lexer::StringReader::new(&sess.span_diagnostic, filemap); 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()) panictry!(p1.parse_all_token_trees())
} }
@ -297,7 +297,7 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess,
tts: Vec<ast::TokenTree>, tts: Vec<ast::TokenTree>,
cfg: ast::CrateConfig) -> Parser<'a> { cfg: ast::CrateConfig) -> Parser<'a> {
let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, None, tts); 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()); panictry!(p.check_unknown_macro_variable());
p p
} }
@ -360,7 +360,7 @@ pub mod with_hygiene {
use super::lexer::make_reader_with_embedded_idents as make_reader; use super::lexer::make_reader_with_embedded_idents as make_reader;
let cfg = Vec::new(); let cfg = Vec::new();
let srdr = make_reader(&sess.span_diagnostic, filemap); 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()) panictry!(p1.parse_all_token_trees())
} }
} }

View file

@ -897,7 +897,7 @@ impl<'a> Parser<'a> {
self.last_span = self.span; self.last_span = self.span;
// Stash token for error recovery (sometimes; clone is not necessarily cheap). // Stash token for error recovery (sometimes; clone is not necessarily cheap).
self.last_token = if self.token.is_ident() || self.token.is_path() { self.last_token = if self.token.is_ident() || self.token.is_path() {
Some(box self.token.clone()) Some(Box::new(self.token.clone()))
} else { } else {
None None
}; };
@ -1578,8 +1578,8 @@ impl<'a> Parser<'a> {
token::Interpolated(token::NtPath(_)) => Some(try!(self.bump_and_get())), token::Interpolated(token::NtPath(_)) => Some(try!(self.bump_and_get())),
_ => None, _ => None,
}; };
if let Some(token::Interpolated(token::NtPath(box path))) = found { if let Some(token::Interpolated(token::NtPath(path))) = found {
return Ok(path); return Ok(*path);
} }
let lo = self.span.lo; let lo = self.span.lo;

View file

@ -188,7 +188,7 @@ pub fn to_string<F>(f: F) -> String where
F: FnOnce(&mut State) -> io::Result<()>, F: FnOnce(&mut State) -> io::Result<()>,
{ {
use std::raw::TraitObject; 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(); f(&mut s).unwrap();
eof(&mut s.s).unwrap(); eof(&mut s.s).unwrap();
let wr = unsafe { let wr = unsafe {

View file

@ -52,7 +52,7 @@ pub struct P<T> {
/// Construct a `P<T>` from a `T` value. /// Construct a `P<T>` from a `T` value.
pub fn P<T: 'static>(value: T) -> P<T> { pub fn P<T: 'static>(value: T) -> P<T> {
P { P {
ptr: box value ptr: Box::new(value)
} }
} }