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