Skip to content

Commit 1114bc4

Browse files
committed
syntax: remove #![feature(box_syntax, box_patterns)]
1 parent abf0548 commit 1114bc4

19 files changed

+44
-46
lines changed

src/libsyntax/ext/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ macro_rules! make_MacEager {
262262
impl MacEager {
263263
$(
264264
pub fn $fld(v: $t) -> Box<MacResult> {
265-
box MacEager {
265+
Box::new(MacEager {
266266
$fld: Some(v),
267267
..Default::default()
268-
}
268+
})
269269
}
270270
)*
271271
}
@@ -331,7 +331,7 @@ impl DummyResult {
331331
/// Use this as a return value after hitting any errors and
332332
/// calling `span_err`.
333333
pub fn any(sp: Span) -> Box<MacResult+'static> {
334-
box DummyResult { expr_only: false, span: sp }
334+
Box::new(DummyResult { expr_only: false, span: sp })
335335
}
336336

337337
/// Create a default MacResult that can only be an expression.
@@ -340,7 +340,7 @@ impl DummyResult {
340340
/// if an error is encountered internally, the user will receive
341341
/// an error that they also used it in the wrong place.
342342
pub fn expr(sp: Span) -> Box<MacResult+'static> {
343-
box DummyResult { expr_only: true, span: sp }
343+
Box::new(DummyResult { expr_only: true, span: sp })
344344
}
345345

346346
/// A plain dummy expression.

src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn expand_deriving_ord<F>(cx: &mut ExtCtxt,
4848
let ordering_ty = Literal(path_std!(cx, core::cmp::Ordering));
4949
let ret_ty = Literal(Path::new_(pathvec_std!(cx, core::option::Option),
5050
None,
51-
vec![box ordering_ty],
51+
vec![Box::new(ordering_ty)],
5252
true));
5353

5454
let inline = cx.meta_word(span, InternedString::new("inline"));

src/libsyntax/ext/deriving/decodable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ fn expand_deriving_decodable_imp<F>(cx: &mut ExtCtxt,
7171
vec!(), true))))
7272
},
7373
explicit_self: None,
74-
args: vec!(Ptr(box Literal(Path::new_local("__D")),
74+
args: vec!(Ptr(Box::new(Literal(Path::new_local("__D"))),
7575
Borrowed(None, MutMutable))),
7676
ret_ty: Literal(Path::new_(
7777
pathvec_std!(cx, core::result::Result),
7878
None,
79-
vec!(box Self_, box Literal(Path::new_(
79+
vec!(Box::new(Self_), Box::new(Literal(Path::new_(
8080
vec!["__D", "Error"], None, vec![], false
81-
))),
81+
)))),
8282
true
8383
)),
8484
attributes: Vec::new(),

src/libsyntax/ext/deriving/encodable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ fn expand_deriving_encodable_imp<F>(cx: &mut ExtCtxt,
147147
vec!(), true))))
148148
},
149149
explicit_self: borrowed_explicit_self(),
150-
args: vec!(Ptr(box Literal(Path::new_local("__S")),
150+
args: vec!(Ptr(Box::new(Literal(Path::new_local("__S"))),
151151
Borrowed(None, MutMutable))),
152152
ret_ty: Literal(Path::new_(
153153
pathvec_std!(cx, core::result::Result),
154154
None,
155-
vec!(box Tuple(Vec::new()), box Literal(Path::new_(
155+
vec!(Box::new(Tuple(Vec::new())), Box::new(Literal(Path::new_(
156156
vec!["__S", "Error"], None, vec![], false
157-
))),
157+
)))),
158158
true
159159
)),
160160
attributes: Vec::new(),

src/libsyntax/ext/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ impl<'a> MethodDef<'a> {
808808
Self_ if nonstatic => {
809809
self_args.push(arg_expr);
810810
}
811-
Ptr(box Self_, _) if nonstatic => {
811+
Ptr(ref ty, _) if **ty == Self_ && nonstatic => {
812812
self_args.push(cx.expr_deref(trait_.span, arg_expr))
813813
}
814814
_ => {

src/libsyntax/ext/deriving/generic/ty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use parse::token::special_idents;
2424
use ptr::P;
2525

2626
/// The types of pointers
27-
#[derive(Clone)]
27+
#[derive(Clone, Eq, PartialEq)]
2828
pub enum PtrTy<'a> {
2929
/// &'lifetime mut
3030
Borrowed(Option<&'a str>, ast::Mutability),
@@ -34,7 +34,7 @@ pub enum PtrTy<'a> {
3434

3535
/// A path, e.g. `::std::option::Option::<i32>` (global). Has support
3636
/// for type parameters and a lifetime.
37-
#[derive(Clone)]
37+
#[derive(Clone, Eq, PartialEq)]
3838
pub struct Path<'a> {
3939
pub path: Vec<&'a str> ,
4040
pub lifetime: Option<&'a str>,
@@ -85,7 +85,7 @@ impl<'a> Path<'a> {
8585
}
8686

8787
/// A type. Supports pointers, Self, and literals
88-
#[derive(Clone)]
88+
#[derive(Clone, Eq, PartialEq)]
8989
pub enum Ty<'a> {
9090
Self_,
9191
/// &/Box/ Ty
@@ -109,7 +109,7 @@ pub fn borrowed_explicit_self<'r>() -> Option<Option<PtrTy<'r>>> {
109109
}
110110

111111
pub fn borrowed_self<'r>() -> Ty<'r> {
112-
borrowed(box Self_)
112+
borrowed(Box::new(Self_))
113113
}
114114

115115
pub fn nil_ty<'r>() -> Ty<'r> {

src/libsyntax/ext/deriving/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn expand_deriving_hash<F>(cx: &mut ExtCtxt,
4242
vec![path_std!(cx, core::hash::Hasher)])],
4343
},
4444
explicit_self: borrowed_explicit_self(),
45-
args: vec!(Ptr(box Literal(arg), Borrowed(None, MutMutable))),
45+
args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, MutMutable))),
4646
ret_ty: nil_ty(),
4747
attributes: vec![],
4848
combine_substructure: combine_substructure(Box::new(|a, b, c| {

src/libsyntax/ext/deriving/primitive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn expand_deriving_from_primitive<F>(cx: &mut ExtCtxt,
4141
args: vec!(Literal(path_local!(i64))),
4242
ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option),
4343
None,
44-
vec!(box Self_),
44+
vec!(Box::new(Self_)),
4545
true)),
4646
// #[inline] liable to cause code-bloat
4747
attributes: attrs.clone(),
@@ -56,7 +56,7 @@ pub fn expand_deriving_from_primitive<F>(cx: &mut ExtCtxt,
5656
args: vec!(Literal(path_local!(u64))),
5757
ret_ty: Literal(Path::new_(pathvec_std!(cx, core::option::Option),
5858
None,
59-
vec!(box Self_),
59+
vec!(Box::new(Self_)),
6060
true)),
6161
// #[inline] liable to cause code-bloat
6262
attributes: attrs,

src/libsyntax/ext/deriving/show.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn expand_deriving_show<F>(cx: &mut ExtCtxt,
2626
F: FnOnce(P<Item>),
2727
{
2828
// &mut ::std::fmt::Formatter
29-
let fmtr = Ptr(box Literal(path_std!(cx, core::fmt::Formatter)),
29+
let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))),
3030
Borrowed(None, ast::MutMutable));
3131

3232
let trait_def = TraitDef {

src/libsyntax/ext/source_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree
128128
}
129129
}
130130

131-
box ExpandResult { p: p }
131+
Box::new(ExpandResult { p: p })
132132
}
133133

134134
// include_str! : read the given file, insert it as a literal string expr

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
167167
-> Box<MatcherPos> {
168168
let match_idx_hi = count_names(&ms[..]);
169169
let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect();
170-
box MatcherPos {
170+
Box::new(MatcherPos {
171171
stack: vec![],
172172
top_elts: TtSeq(ms),
173173
sep: sep,
@@ -178,7 +178,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
178178
match_cur: 0,
179179
match_hi: match_idx_hi,
180180
sp_lo: lo
181-
}
181+
})
182182
}
183183

184184
/// NamedMatch is a pattern-match result for a single token::MATCH_NONTERMINAL:
@@ -398,7 +398,7 @@ pub fn parse(sess: &ParseSess,
398398
let matches: Vec<_> = (0..ei.matches.len())
399399
.map(|_| Vec::new()).collect();
400400
let ei_t = ei;
401-
cur_eis.push(box MatcherPos {
401+
cur_eis.push(Box::new(MatcherPos {
402402
stack: vec![],
403403
sep: seq.separator.clone(),
404404
idx: 0,
@@ -409,7 +409,7 @@ pub fn parse(sess: &ParseSess,
409409
up: Some(ei_t),
410410
sp_lo: sp.lo,
411411
top_elts: Tt(TtSequence(sp, seq)),
412-
});
412+
}));
413413
}
414414
TtToken(_, MatchNt(..)) => {
415415
// Built-in nonterminals never start with these tokens,
@@ -535,15 +535,15 @@ pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal {
535535
"ty" => token::NtTy(p.parse_ty()),
536536
// this could be handled like a token, since it is one
537537
"ident" => match p.token {
538-
token::Ident(sn,b) => { panictry!(p.bump()); token::NtIdent(box sn,b) }
538+
token::Ident(sn,b) => { panictry!(p.bump()); token::NtIdent(Box::new(sn),b) }
539539
_ => {
540540
let token_str = pprust::token_to_string(&p.token);
541541
panic!(p.fatal(&format!("expected ident, found {}",
542542
&token_str[..])))
543543
}
544544
},
545545
"path" => {
546-
token::NtPath(box panictry!(p.parse_path(LifetimeAndTypesWithoutColons)))
546+
token::NtPath(Box::new(panictry!(p.parse_path(LifetimeAndTypesWithoutColons))))
547547
}
548548
"meta" => token::NtMeta(p.parse_meta_item()),
549549
_ => {

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
192192
panictry!(p.check_unknown_macro_variable());
193193
// Let the context choose how to interpret the result.
194194
// Weird, but useful for X-macros.
195-
return box ParserAnyMacro {
195+
return Box::new(ParserAnyMacro {
196196
parser: RefCell::new(p),
197197

198198
// Pass along the original expansion site and the name of the macro
199199
// so we can print a useful error message if the parse of the expanded
200200
// macro leaves unparsed tokens.
201201
site_span: sp,
202202
macro_ident: name
203-
}
203+
})
204204
}
205205
Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo {
206206
best_fail_spot = sp;
@@ -281,12 +281,12 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
281281
_ => cx.span_bug(def.span, "wrong-structured rhs")
282282
};
283283

284-
let exp: Box<_> = box MacroRulesMacroExpander {
284+
let exp: Box<_> = Box::new(MacroRulesMacroExpander {
285285
name: def.ident,
286286
imported_from: def.imported_from,
287287
lhses: lhses,
288288
rhses: rhses,
289-
};
289+
});
290290

291291
NormalTT(exp, Some(def.span), def.allow_internal_unstable)
292292
}

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
294294
// sidestep the interpolation tricks for ident because
295295
// (a) idents can be in lots of places, so it'd be a pain
296296
// (b) we actually can, since it's a token.
297-
MatchedNonterminal(NtIdent(box sn, b)) => {
297+
MatchedNonterminal(NtIdent(ref sn, b)) => {
298298
r.cur_span = sp;
299-
r.cur_tok = token::Ident(sn, b);
299+
r.cur_tok = token::Ident(**sn, b);
300300
return ret_val;
301301
}
302302
MatchedNonterminal(ref other_whole_nt) => {

src/libsyntax/fold.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,10 @@ pub fn noop_fold_interpolated<T: Folder>(nt: token::Nonterminal, fld: &mut T)
677677
token::NtPat(pat) => token::NtPat(fld.fold_pat(pat)),
678678
token::NtExpr(expr) => token::NtExpr(fld.fold_expr(expr)),
679679
token::NtTy(ty) => token::NtTy(fld.fold_ty(ty)),
680-
token::NtIdent(box id, is_mod_name) =>
681-
token::NtIdent(box fld.fold_ident(id), is_mod_name),
680+
token::NtIdent(id, is_mod_name) =>
681+
token::NtIdent(Box::new(fld.fold_ident(*id)), is_mod_name),
682682
token::NtMeta(meta_item) => token::NtMeta(fld.fold_meta_item(meta_item)),
683-
token::NtPath(box path) => token::NtPath(box fld.fold_path(path)),
683+
token::NtPath(path) => token::NtPath(Box::new(fld.fold_path(*path))),
684684
token::NtTT(tt) => token::NtTT(P(fld.fold_tt(&*tt))),
685685
}
686686
}

src/libsyntax/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2626
html_root_url = "http://doc.rust-lang.org/nightly/")]
2727

28-
#![feature(box_patterns)]
29-
#![feature(box_syntax)]
3028
#![feature(collections)]
3129
#![feature(core)]
3230
#![feature(libc)]

src/libsyntax/parse/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc<FileMap>)
288288
// parsing tt's probably shouldn't require a parser at all.
289289
let cfg = Vec::new();
290290
let srdr = lexer::StringReader::new(&sess.span_diagnostic, filemap);
291-
let mut p1 = Parser::new(sess, cfg, box srdr);
291+
let mut p1 = Parser::new(sess, cfg, Box::new(srdr));
292292
panictry!(p1.parse_all_token_trees())
293293
}
294294

@@ -297,7 +297,7 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess,
297297
tts: Vec<ast::TokenTree>,
298298
cfg: ast::CrateConfig) -> Parser<'a> {
299299
let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, None, tts);
300-
let mut p = Parser::new(sess, cfg, box trdr);
300+
let mut p = Parser::new(sess, cfg, Box::new(trdr));
301301
panictry!(p.check_unknown_macro_variable());
302302
p
303303
}
@@ -360,7 +360,7 @@ pub mod with_hygiene {
360360
use super::lexer::make_reader_with_embedded_idents as make_reader;
361361
let cfg = Vec::new();
362362
let srdr = make_reader(&sess.span_diagnostic, filemap);
363-
let mut p1 = Parser::new(sess, cfg, box srdr);
363+
let mut p1 = Parser::new(sess, cfg, Box::new(srdr));
364364
panictry!(p1.parse_all_token_trees())
365365
}
366366
}

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ impl<'a> Parser<'a> {
897897
self.last_span = self.span;
898898
// Stash token for error recovery (sometimes; clone is not necessarily cheap).
899899
self.last_token = if self.token.is_ident() || self.token.is_path() {
900-
Some(box self.token.clone())
900+
Some(Box::new(self.token.clone()))
901901
} else {
902902
None
903903
};
@@ -1578,8 +1578,8 @@ impl<'a> Parser<'a> {
15781578
token::Interpolated(token::NtPath(_)) => Some(try!(self.bump_and_get())),
15791579
_ => None,
15801580
};
1581-
if let Some(token::Interpolated(token::NtPath(box path))) = found {
1582-
return Ok(path);
1581+
if let Some(token::Interpolated(token::NtPath(path))) = found {
1582+
return Ok(*path);
15831583
}
15841584

15851585
let lo = self.span.lo;

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub fn to_string<F>(f: F) -> String where
188188
F: FnOnce(&mut State) -> io::Result<()>,
189189
{
190190
use std::raw::TraitObject;
191-
let mut s = rust_printer(box Vec::new());
191+
let mut s = rust_printer(Box::new(Vec::new()));
192192
f(&mut s).unwrap();
193193
eof(&mut s.s).unwrap();
194194
let wr = unsafe {

src/libsyntax/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct P<T> {
5252
/// Construct a `P<T>` from a `T` value.
5353
pub fn P<T: 'static>(value: T) -> P<T> {
5454
P {
55-
ptr: box value
55+
ptr: Box::new(value)
5656
}
5757
}
5858

0 commit comments

Comments
 (0)