syntax: remove the handling of @str and @[] from the parser completely.
This commit is contained in:
parent
aadcf29766
commit
e39cd20a43
@ -228,8 +228,7 @@ impl Visitor<()> for Context {
|
||||
|
||||
fn visit_expr(&mut self, e: &ast::Expr, _: ()) {
|
||||
match e.node {
|
||||
ast::ExprUnary(_, ast::UnBox, _) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreBox) => {
|
||||
ast::ExprUnary(_, ast::UnBox, _) => {
|
||||
self.gate_box(e.span);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -192,8 +192,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
|
||||
"references in constants may only refer to \
|
||||
immutable values");
|
||||
},
|
||||
ExprVstore(_, ExprVstoreUniq) |
|
||||
ExprVstore(_, ExprVstoreBox) => {
|
||||
ExprVstore(_, ExprVstoreUniq) => {
|
||||
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
|
||||
},
|
||||
|
||||
|
@ -240,7 +240,6 @@ impl ConstEvalVisitor {
|
||||
match vstore {
|
||||
ast::ExprVstoreSlice => self.classify(e),
|
||||
ast::ExprVstoreUniq |
|
||||
ast::ExprVstoreBox |
|
||||
ast::ExprVstoreMutSlice => non_const
|
||||
}
|
||||
}
|
||||
|
@ -1248,8 +1248,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
|
||||
// Warn if string and vector literals with sigils, or boxing expressions,
|
||||
// are immediately borrowed.
|
||||
let allocation = match e.node {
|
||||
ast::ExprVstore(e2, ast::ExprVstoreUniq) |
|
||||
ast::ExprVstore(e2, ast::ExprVstoreBox) => {
|
||||
ast::ExprVstore(e2, ast::ExprVstoreUniq) => {
|
||||
match e2.node {
|
||||
ast::ExprLit(lit) if ast_util::lit_is_str(lit) => {
|
||||
VectorAllocation
|
||||
|
@ -519,14 +519,6 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>,
|
||||
ast::ExprIndex(_, base, idx) => {
|
||||
trans_index(bcx, expr, base, idx)
|
||||
}
|
||||
ast::ExprVstore(contents, ast::ExprVstoreBox) => {
|
||||
fcx.push_ast_cleanup_scope(contents.id);
|
||||
let datum = unpack_datum!(
|
||||
bcx, tvec::trans_uniq_or_managed_vstore(bcx, heap_managed,
|
||||
expr, contents));
|
||||
bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, contents.id);
|
||||
DatumBlock(bcx, datum)
|
||||
}
|
||||
ast::ExprVstore(contents, ast::ExprVstoreUniq) => {
|
||||
fcx.push_ast_cleanup_scope(contents.id);
|
||||
let datum = unpack_datum!(
|
||||
@ -2030,4 +2022,3 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
|
||||
DatumBlock { bcx: bcx, datum: datum }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3303,7 +3303,6 @@ pub fn expr_kind(tcx: ctxt,
|
||||
ast::ExprUnary(..) |
|
||||
ast::ExprAddrOf(..) |
|
||||
ast::ExprBinary(..) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreBox) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
|
||||
RvalueDatumExpr
|
||||
}
|
||||
|
@ -3909,7 +3909,6 @@ pub fn ast_expr_vstore_to_vstore(fcx: @FnCtxt,
|
||||
-> ty::vstore {
|
||||
match v {
|
||||
ast::ExprVstoreUniq => ty::vstore_uniq,
|
||||
ast::ExprVstoreBox => ty::vstore_box,
|
||||
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
|
||||
match e.node {
|
||||
ast::ExprLit(..) |
|
||||
|
@ -417,7 +417,6 @@ pub enum Vstore {
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub enum ExprVstore {
|
||||
ExprVstoreUniq, // ~[1,2,3,4]
|
||||
ExprVstoreBox, // @[1,2,3,4]
|
||||
ExprVstoreSlice, // &[1,2,3,4]
|
||||
ExprVstoreMutSlice, // &mut [1,2,3,4]
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex};
|
||||
use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac};
|
||||
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
|
||||
use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary};
|
||||
use ast::{ExprVec, ExprVstore, ExprVstoreSlice, ExprVstoreBox};
|
||||
use ast::{ExprVec, ExprVstore, ExprVstoreSlice};
|
||||
use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, ExternFn, Field, FnDecl};
|
||||
use ast::{ExprVstoreUniq, Onceness, Once, Many};
|
||||
use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod};
|
||||
@ -2291,16 +2291,18 @@ impl Parser {
|
||||
self.bump();
|
||||
let e = self.parse_prefix_expr();
|
||||
hi = e.span.hi;
|
||||
// HACK: turn @[...] into a @-vec
|
||||
// HACK: pretending @[] is a (removed) @-vec
|
||||
ex = match e.node {
|
||||
ExprVec(..) |
|
||||
ExprRepeat(..) => {
|
||||
self.obsolete(e.span, ObsoleteManagedVec);
|
||||
ExprVstore(e, ExprVstoreBox)
|
||||
// the above error means that no-one will know we're
|
||||
// lying... hopefully.
|
||||
ExprVstore(e, ExprVstoreUniq)
|
||||
}
|
||||
ExprLit(lit) if lit_is_str(lit) => {
|
||||
self.obsolete(self.last_span, ObsoleteManagedString);
|
||||
ExprVstore(e, ExprVstoreBox)
|
||||
ExprVstore(e, ExprVstoreUniq)
|
||||
}
|
||||
_ => self.mk_unary(UnBox, e)
|
||||
};
|
||||
@ -2819,34 +2821,11 @@ impl Parser {
|
||||
token::AT => {
|
||||
self.bump();
|
||||
let sub = self.parse_pat();
|
||||
hi = sub.span.hi;
|
||||
// HACK: parse @"..." as a literal of a vstore @str
|
||||
pat = match sub.node {
|
||||
PatLit(e) => {
|
||||
match e.node {
|
||||
ExprLit(lit) if lit_is_str(lit) => {
|
||||
let vst = @Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ExprVstore(e, ExprVstoreBox),
|
||||
span: mk_sp(lo, hi),
|
||||
};
|
||||
PatLit(vst)
|
||||
}
|
||||
_ => {
|
||||
self.obsolete(self.span, ObsoleteManagedPattern);
|
||||
PatUniq(sub)
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.obsolete(self.span, ObsoleteManagedPattern);
|
||||
PatUniq(sub)
|
||||
}
|
||||
};
|
||||
hi = self.last_span.hi;
|
||||
self.obsolete(self.span, ObsoleteManagedPattern);
|
||||
let hi = self.last_span.hi;
|
||||
return @ast::Pat {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: pat,
|
||||
node: sub,
|
||||
span: mk_sp(lo, hi)
|
||||
}
|
||||
}
|
||||
|
@ -1074,7 +1074,6 @@ pub fn print_vstore(s: &mut State, t: ast::Vstore) {
|
||||
pub fn print_expr_vstore(s: &mut State, t: ast::ExprVstore) {
|
||||
match t {
|
||||
ast::ExprVstoreUniq => word(&mut s.s, "~"),
|
||||
ast::ExprVstoreBox => word(&mut s.s, "@"),
|
||||
ast::ExprVstoreSlice => word(&mut s.s, "&"),
|
||||
ast::ExprVstoreMutSlice => {
|
||||
word(&mut s.s, "&");
|
||||
|
Loading…
x
Reference in New Issue
Block a user