Skip to content

Commit

Permalink
syntax: remove #![feature(box_syntax, box_patterns)]
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Apr 21, 2015
1 parent 7397bdc commit a4541b0
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 46 deletions.
8 changes: 4 additions & 4 deletions src/libsyntax/ext/base.rs
Expand Up @@ -262,10 +262,10 @@ macro_rules! make_MacEager {
impl MacEager {
$(
pub fn $fld(v: $t) -> Box<MacResult> {
box MacEager {
Box::new(MacEager {
$fld: Some(v),
..Default::default()
}
})
}
)*
}
Expand Down Expand Up @@ -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<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.
Expand All @@ -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<MacResult+'static> {
box DummyResult { expr_only: true, span: sp }
Box::new(DummyResult { expr_only: true, span: sp })
}

/// A plain dummy expression.
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/cmp/partial_ord.rs
Expand Up @@ -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"));
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/ext/deriving/decodable.rs
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/ext/deriving/encodable.rs
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/generic/mod.rs
Expand Up @@ -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))
}
_ => {
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/ext/deriving/generic/ty.rs
Expand Up @@ -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),
Expand All @@ -34,7 +34,7 @@ pub enum PtrTy<'a> {

/// A path, e.g. `::std::option::Option::<i32>` (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>,
Expand Down Expand Up @@ -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
Expand All @@ -109,7 +109,7 @@ pub fn borrowed_explicit_self<'r>() -> Option<Option<PtrTy<'r>>> {
}

pub fn borrowed_self<'r>() -> Ty<'r> {
borrowed(box Self_)
borrowed(Box::new(Self_))
}

pub fn nil_ty<'r>() -> Ty<'r> {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/hash.rs
Expand Up @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/deriving/primitive.rs
Expand Up @@ -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(),
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/show.rs
Expand Up @@ -25,7 +25,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt,
push: &mut FnMut(P<Item>))
{
// &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 {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/source_util.rs
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/ext/tt/macro_parser.rs
Expand Up @@ -165,7 +165,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
-> Box<MatcherPos> {
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,
Expand All @@ -176,7 +176,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, 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:
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -533,15 +533,15 @@ 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 {}",
&token_str[..])))
}
},
"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()),
_ => {
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/ext/tt/macro_rules.rs
Expand Up @@ -192,15 +192,15 @@ 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
// so we can print a useful error message if the parse of the expanded
// 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;
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/tt/transcribe.rs
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/fold.rs
Expand Up @@ -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::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))),
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/libsyntax/lib.rs
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/parse/mod.rs
Expand Up @@ -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.
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())
}

Expand All @@ -297,7 +297,7 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess,
tts: Vec<ast::TokenTree>,
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
}
Expand Down Expand Up @@ -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())
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -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
};
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/print/pprust.rs
Expand Up @@ -188,7 +188,7 @@ pub fn to_string<F>(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 {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ptr.rs
Expand Up @@ -52,7 +52,7 @@ pub struct P<T> {
/// Construct a `P<T>` from a `T` value.
pub fn P<T: 'static>(value: T) -> P<T> {
P {
ptr: box value
ptr: Box::new(value)
}
}

Expand Down

0 comments on commit a4541b0

Please sign in to comment.