Skip to content

Commit e39cd20

Browse files
committed
syntax: remove the handling of @str and @[] from the parser completely.
1 parent aadcf29 commit e39cd20

File tree

10 files changed

+12
-50
lines changed

10 files changed

+12
-50
lines changed

src/librustc/front/feature_gate.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ impl Visitor<()> for Context {
228228

229229
fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
230230
match e.node {
231-
ast::ExprUnary(_, ast::UnBox, _) |
232-
ast::ExprVstore(_, ast::ExprVstoreBox) => {
231+
ast::ExprUnary(_, ast::UnBox, _) => {
233232
self.gate_box(e.span);
234233
}
235234
_ => {}

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
192192
"references in constants may only refer to \
193193
immutable values");
194194
},
195-
ExprVstore(_, ExprVstoreUniq) |
196-
ExprVstore(_, ExprVstoreBox) => {
195+
ExprVstore(_, ExprVstoreUniq) => {
197196
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
198197
},
199198

src/librustc/middle/const_eval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ impl ConstEvalVisitor {
240240
match vstore {
241241
ast::ExprVstoreSlice => self.classify(e),
242242
ast::ExprVstoreUniq |
243-
ast::ExprVstoreBox |
244243
ast::ExprVstoreMutSlice => non_const
245244
}
246245
}

src/librustc/middle/lint.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
12481248
// Warn if string and vector literals with sigils, or boxing expressions,
12491249
// are immediately borrowed.
12501250
let allocation = match e.node {
1251-
ast::ExprVstore(e2, ast::ExprVstoreUniq) |
1252-
ast::ExprVstore(e2, ast::ExprVstoreBox) => {
1251+
ast::ExprVstore(e2, ast::ExprVstoreUniq) => {
12531252
match e2.node {
12541253
ast::ExprLit(lit) if ast_util::lit_is_str(lit) => {
12551254
VectorAllocation

src/librustc/middle/trans/expr.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,6 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>,
519519
ast::ExprIndex(_, base, idx) => {
520520
trans_index(bcx, expr, base, idx)
521521
}
522-
ast::ExprVstore(contents, ast::ExprVstoreBox) => {
523-
fcx.push_ast_cleanup_scope(contents.id);
524-
let datum = unpack_datum!(
525-
bcx, tvec::trans_uniq_or_managed_vstore(bcx, heap_managed,
526-
expr, contents));
527-
bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, contents.id);
528-
DatumBlock(bcx, datum)
529-
}
530522
ast::ExprVstore(contents, ast::ExprVstoreUniq) => {
531523
fcx.push_ast_cleanup_scope(contents.id);
532524
let datum = unpack_datum!(
@@ -2030,4 +2022,3 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
20302022
DatumBlock { bcx: bcx, datum: datum }
20312023
}
20322024
}
2033-

src/librustc/middle/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3303,7 +3303,6 @@ pub fn expr_kind(tcx: ctxt,
33033303
ast::ExprUnary(..) |
33043304
ast::ExprAddrOf(..) |
33053305
ast::ExprBinary(..) |
3306-
ast::ExprVstore(_, ast::ExprVstoreBox) |
33073306
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
33083307
RvalueDatumExpr
33093308
}

src/librustc/middle/typeck/check/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3909,7 +3909,6 @@ pub fn ast_expr_vstore_to_vstore(fcx: @FnCtxt,
39093909
-> ty::vstore {
39103910
match v {
39113911
ast::ExprVstoreUniq => ty::vstore_uniq,
3912-
ast::ExprVstoreBox => ty::vstore_box,
39133912
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
39143913
match e.node {
39153914
ast::ExprLit(..) |

src/libsyntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ pub enum Vstore {
417417
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
418418
pub enum ExprVstore {
419419
ExprVstoreUniq, // ~[1,2,3,4]
420-
ExprVstoreBox, // @[1,2,3,4]
421420
ExprVstoreSlice, // &[1,2,3,4]
422421
ExprVstoreMutSlice, // &mut [1,2,3,4]
423422
}

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex};
2929
use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac};
3030
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
3131
use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary};
32-
use ast::{ExprVec, ExprVstore, ExprVstoreSlice, ExprVstoreBox};
32+
use ast::{ExprVec, ExprVstore, ExprVstoreSlice};
3333
use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, ExternFn, Field, FnDecl};
3434
use ast::{ExprVstoreUniq, Onceness, Once, Many};
3535
use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod};
@@ -2291,16 +2291,18 @@ impl Parser {
22912291
self.bump();
22922292
let e = self.parse_prefix_expr();
22932293
hi = e.span.hi;
2294-
// HACK: turn @[...] into a @-vec
2294+
// HACK: pretending @[] is a (removed) @-vec
22952295
ex = match e.node {
22962296
ExprVec(..) |
22972297
ExprRepeat(..) => {
22982298
self.obsolete(e.span, ObsoleteManagedVec);
2299-
ExprVstore(e, ExprVstoreBox)
2299+
// the above error means that no-one will know we're
2300+
// lying... hopefully.
2301+
ExprVstore(e, ExprVstoreUniq)
23002302
}
23012303
ExprLit(lit) if lit_is_str(lit) => {
23022304
self.obsolete(self.last_span, ObsoleteManagedString);
2303-
ExprVstore(e, ExprVstoreBox)
2305+
ExprVstore(e, ExprVstoreUniq)
23042306
}
23052307
_ => self.mk_unary(UnBox, e)
23062308
};
@@ -2819,34 +2821,11 @@ impl Parser {
28192821
token::AT => {
28202822
self.bump();
28212823
let sub = self.parse_pat();
2822-
hi = sub.span.hi;
2823-
// HACK: parse @"..." as a literal of a vstore @str
2824-
pat = match sub.node {
2825-
PatLit(e) => {
2826-
match e.node {
2827-
ExprLit(lit) if lit_is_str(lit) => {
2828-
let vst = @Expr {
2829-
id: ast::DUMMY_NODE_ID,
2830-
node: ExprVstore(e, ExprVstoreBox),
2831-
span: mk_sp(lo, hi),
2832-
};
2833-
PatLit(vst)
2834-
}
2835-
_ => {
2836-
self.obsolete(self.span, ObsoleteManagedPattern);
2837-
PatUniq(sub)
2838-
}
2839-
}
2840-
}
2841-
_ => {
2842-
self.obsolete(self.span, ObsoleteManagedPattern);
2843-
PatUniq(sub)
2844-
}
2845-
};
2846-
hi = self.last_span.hi;
2824+
self.obsolete(self.span, ObsoleteManagedPattern);
2825+
let hi = self.last_span.hi;
28472826
return @ast::Pat {
28482827
id: ast::DUMMY_NODE_ID,
2849-
node: pat,
2828+
node: sub,
28502829
span: mk_sp(lo, hi)
28512830
}
28522831
}

src/libsyntax/print/pprust.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,6 @@ pub fn print_vstore(s: &mut State, t: ast::Vstore) {
10741074
pub fn print_expr_vstore(s: &mut State, t: ast::ExprVstore) {
10751075
match t {
10761076
ast::ExprVstoreUniq => word(&mut s.s, "~"),
1077-
ast::ExprVstoreBox => word(&mut s.s, "@"),
10781077
ast::ExprVstoreSlice => word(&mut s.s, "&"),
10791078
ast::ExprVstoreMutSlice => {
10801079
word(&mut s.s, "&");

0 commit comments

Comments
 (0)