librustc: Remove @mut
support from the parser
This commit is contained in:
parent
88281290ff
commit
82a09b9a04
20 changed files with 52 additions and 81 deletions
|
@ -189,9 +189,8 @@ 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) |
|
ast::ExprVstore(_, ast::ExprVstoreBox) => {
|
||||||
ast::ExprVstore(_, ast::ExprVstoreMutBox) => {
|
|
||||||
self.gate_box(e.span);
|
self.gate_box(e.span);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -116,7 +116,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
|
||||||
if is_const {
|
if is_const {
|
||||||
match e.node {
|
match e.node {
|
||||||
ExprUnary(_, UnDeref, _) => { }
|
ExprUnary(_, UnDeref, _) => { }
|
||||||
ExprUnary(_, UnBox(_), _) | ExprUnary(_, UnUniq, _) => {
|
ExprUnary(_, UnBox, _) | ExprUnary(_, UnUniq, _) => {
|
||||||
sess.span_err(e.span,
|
sess.span_err(e.span,
|
||||||
"cannot do allocations in constant expressions");
|
"cannot do allocations in constant expressions");
|
||||||
return;
|
return;
|
||||||
|
@ -197,8 +197,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
|
||||||
immutable values");
|
immutable values");
|
||||||
},
|
},
|
||||||
ExprVstore(_, ExprVstoreUniq) |
|
ExprVstore(_, ExprVstoreUniq) |
|
||||||
ExprVstore(_, ExprVstoreBox) |
|
ExprVstore(_, ExprVstoreBox) => {
|
||||||
ExprVstore(_, ExprVstoreMutBox) => {
|
|
||||||
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
|
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,6 @@ impl ConstEvalVisitor {
|
||||||
ast::ExprVstoreSlice => self.classify(e),
|
ast::ExprVstoreSlice => self.classify(e),
|
||||||
ast::ExprVstoreUniq |
|
ast::ExprVstoreUniq |
|
||||||
ast::ExprVstoreBox |
|
ast::ExprVstoreBox |
|
||||||
ast::ExprVstoreMutBox |
|
|
||||||
ast::ExprVstoreMutSlice => non_const
|
ast::ExprVstoreMutSlice => non_const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,7 @@ pub fn check_expr(cx: &mut Context, e: @Expr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
match e.node {
|
match e.node {
|
||||||
ExprUnary(_, UnBox(_), interior) => {
|
ExprUnary(_, UnBox, interior) => {
|
||||||
let interior_type = ty::expr_ty(cx.tcx, interior);
|
let interior_type = ty::expr_ty(cx.tcx, interior);
|
||||||
let _ = check_durable(cx.tcx, interior_type, interior.span);
|
let _ = check_durable(cx.tcx, interior_type, interior.span);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprUnary(_, ast::UnUniq, _) |
|
ast::ExprUnary(_, ast::UnUniq, _) |
|
||||||
ast::ExprUnary(_, ast::UnBox(..), _) => BoxAllocation,
|
ast::ExprUnary(_, ast::UnBox, _) => BoxAllocation,
|
||||||
|
|
||||||
_ => return
|
_ => return
|
||||||
};
|
};
|
||||||
|
|
|
@ -377,9 +377,7 @@ fn const_expr_unadjusted(cx: @CrateContext,
|
||||||
let ty = ty::expr_ty(cx.tcx, e);
|
let ty = ty::expr_ty(cx.tcx, e);
|
||||||
let is_float = ty::type_is_fp(ty);
|
let is_float = ty::type_is_fp(ty);
|
||||||
return (match u {
|
return (match u {
|
||||||
ast::UnBox(_) |
|
ast::UnBox | ast::UnUniq | ast::UnDeref => {
|
||||||
ast::UnUniq |
|
|
||||||
ast::UnDeref => {
|
|
||||||
let (dv, _dt) = const_deref(cx, te, ty, true);
|
let (dv, _dt) = const_deref(cx, te, ty, true);
|
||||||
dv
|
dv
|
||||||
}
|
}
|
||||||
|
|
|
@ -590,8 +590,7 @@ fn trans_rvalue_datum_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
|
||||||
ast::ExprPath(_) | ast::ExprSelf => {
|
ast::ExprPath(_) | ast::ExprSelf => {
|
||||||
return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id));
|
return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id));
|
||||||
}
|
}
|
||||||
ast::ExprVstore(contents, ast::ExprVstoreBox) |
|
ast::ExprVstore(contents, ast::ExprVstoreBox) => {
|
||||||
ast::ExprVstore(contents, ast::ExprVstoreMutBox) => {
|
|
||||||
return tvec::trans_uniq_or_managed_vstore(bcx, heap_managed,
|
return tvec::trans_uniq_or_managed_vstore(bcx, heap_managed,
|
||||||
expr, contents);
|
expr, contents);
|
||||||
}
|
}
|
||||||
|
@ -1406,9 +1405,8 @@ fn trans_unary_datum(bcx: @Block,
|
||||||
};
|
};
|
||||||
immediate_rvalue_bcx(bcx, llneg, un_ty)
|
immediate_rvalue_bcx(bcx, llneg, un_ty)
|
||||||
}
|
}
|
||||||
ast::UnBox(_) => {
|
ast::UnBox => {
|
||||||
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty,
|
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap_managed)
|
||||||
heap_managed)
|
|
||||||
}
|
}
|
||||||
ast::UnUniq => {
|
ast::UnUniq => {
|
||||||
let heap = heap_for_unique(bcx, un_ty);
|
let heap = heap_for_unique(bcx, un_ty);
|
||||||
|
|
|
@ -3257,7 +3257,6 @@ pub fn expr_kind(tcx: ctxt,
|
||||||
ast::ExprAddrOf(..) |
|
ast::ExprAddrOf(..) |
|
||||||
ast::ExprBinary(..) |
|
ast::ExprBinary(..) |
|
||||||
ast::ExprVstore(_, ast::ExprVstoreBox) |
|
ast::ExprVstore(_, ast::ExprVstoreBox) |
|
||||||
ast::ExprVstore(_, ast::ExprVstoreMutBox) |
|
|
||||||
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
|
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
|
||||||
RvalueDatumExpr
|
RvalueDatumExpr
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,8 +401,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
let typ = match ast_ty.node {
|
let typ = match ast_ty.node {
|
||||||
ast::ty_nil => ty::mk_nil(),
|
ast::ty_nil => ty::mk_nil(),
|
||||||
ast::ty_bot => ty::mk_bot(),
|
ast::ty_bot => ty::mk_bot(),
|
||||||
ast::ty_box(ref mt) => {
|
ast::ty_box(ty) => {
|
||||||
let mt = ast::mt { ty: mt.ty, mutbl: ast::MutImmutable };
|
let mt = ast::mt { ty: ty, mutbl: ast::MutImmutable };
|
||||||
mk_pointer(this, rscope, &mt, ty::vstore_box,
|
mk_pointer(this, rscope, &mt, ty::vstore_box,
|
||||||
|tmt| ty::mk_box(tcx, tmt.ty))
|
|tmt| ty::mk_box(tcx, tmt.ty))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2628,15 +2628,12 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref args, mutbl) => {
|
ast::ExprVec(ref args, mutbl) => {
|
||||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||||
let mutability;
|
|
||||||
let mut any_error = false;
|
let mut any_error = false;
|
||||||
let mut any_bot = false;
|
let mut any_bot = false;
|
||||||
match vst {
|
let mutability = match vst {
|
||||||
ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => {
|
ast::ExprVstoreMutSlice => ast::MutMutable,
|
||||||
mutability = ast::MutMutable
|
_ => mutbl,
|
||||||
}
|
};
|
||||||
_ => mutability = mutbl
|
|
||||||
}
|
|
||||||
let t: ty::t = fcx.infcx().next_ty_var();
|
let t: ty::t = fcx.infcx().next_ty_var();
|
||||||
for e in args.iter() {
|
for e in args.iter() {
|
||||||
check_expr_has_type(fcx, *e, t);
|
check_expr_has_type(fcx, *e, t);
|
||||||
|
@ -2650,11 +2647,9 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
||||||
}
|
}
|
||||||
if any_error {
|
if any_error {
|
||||||
ty::mk_err()
|
ty::mk_err()
|
||||||
}
|
} else if any_bot {
|
||||||
else if any_bot {
|
|
||||||
ty::mk_bot()
|
ty::mk_bot()
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2663,10 +2658,8 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
||||||
let _ = ty::eval_repeat_count(fcx, count_expr);
|
let _ = ty::eval_repeat_count(fcx, count_expr);
|
||||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||||
let mutability = match vst {
|
let mutability = match vst {
|
||||||
ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => {
|
ast::ExprVstoreMutSlice => ast::MutMutable,
|
||||||
ast::MutMutable
|
_ => mutbl,
|
||||||
}
|
|
||||||
_ => mutbl
|
|
||||||
};
|
};
|
||||||
let t: ty::t = fcx.infcx().next_ty_var();
|
let t: ty::t = fcx.infcx().next_ty_var();
|
||||||
check_expr_has_type(fcx, element, t);
|
check_expr_has_type(fcx, element, t);
|
||||||
|
@ -2741,7 +2734,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
||||||
ast::ExprUnary(callee_id, unop, oprnd) => {
|
ast::ExprUnary(callee_id, unop, oprnd) => {
|
||||||
let exp_inner = unpack_expected(fcx, expected, |sty| {
|
let exp_inner = unpack_expected(fcx, expected, |sty| {
|
||||||
match unop {
|
match unop {
|
||||||
ast::UnBox(_) | ast::UnUniq => match *sty {
|
ast::UnBox | ast::UnUniq => match *sty {
|
||||||
ty::ty_box(ty) => Some(ty),
|
ty::ty_box(ty) => Some(ty),
|
||||||
ty::ty_uniq(ref mt) => Some(mt.ty),
|
ty::ty_uniq(ref mt) => Some(mt.ty),
|
||||||
_ => None
|
_ => None
|
||||||
|
@ -2755,7 +2748,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
||||||
if !ty::type_is_error(oprnd_t) &&
|
if !ty::type_is_error(oprnd_t) &&
|
||||||
!ty::type_is_bot(oprnd_t) {
|
!ty::type_is_bot(oprnd_t) {
|
||||||
match unop {
|
match unop {
|
||||||
ast::UnBox(_) => {
|
ast::UnBox => {
|
||||||
oprnd_t = ty::mk_box(tcx, oprnd_t)
|
oprnd_t = ty::mk_box(tcx, oprnd_t)
|
||||||
}
|
}
|
||||||
ast::UnUniq => {
|
ast::UnUniq => {
|
||||||
|
@ -3920,7 +3913,7 @@ 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 | ast::ExprVstoreMutBox => ty::vstore_box,
|
ast::ExprVstoreBox => ty::vstore_box,
|
||||||
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
|
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
|
||||||
let r = fcx.infcx().next_region_var(infer::AddrOfSlice(e.span));
|
let r = fcx.infcx().next_region_var(infer::AddrOfSlice(e.span));
|
||||||
ty::vstore_slice(r)
|
ty::vstore_slice(r)
|
||||||
|
|
|
@ -594,7 +594,7 @@ pub enum Type {
|
||||||
/// aka ty_bot
|
/// aka ty_bot
|
||||||
Bottom,
|
Bottom,
|
||||||
Unique(~Type),
|
Unique(~Type),
|
||||||
Managed(Mutability, ~Type),
|
Managed(~Type),
|
||||||
RawPointer(Mutability, ~Type),
|
RawPointer(Mutability, ~Type),
|
||||||
BorrowedRef { lifetime: Option<Lifetime>, mutability: Mutability, type_: ~Type},
|
BorrowedRef { lifetime: Option<Lifetime>, mutability: Mutability, type_: ~Type},
|
||||||
// region, raw, other boxes, mutable
|
// region, raw, other boxes, mutable
|
||||||
|
@ -620,7 +620,7 @@ impl Clean<Type> for ast::Ty {
|
||||||
ty_rptr(ref l, ref m) =>
|
ty_rptr(ref l, ref m) =>
|
||||||
BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
|
BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
|
||||||
type_: ~m.ty.clean()},
|
type_: ~m.ty.clean()},
|
||||||
ty_box(ref m) => Managed(m.mutbl.clean(), ~m.ty.clean()),
|
ty_box(ty) => Managed(~ty.clean()),
|
||||||
ty_uniq(ty) => Unique(~ty.clean()),
|
ty_uniq(ty) => Unique(~ty.clean()),
|
||||||
ty_vec(ty) => Vector(~ty.clean()),
|
ty_vec(ty) => Vector(~ty.clean()),
|
||||||
ty_fixed_length_vec(ty, ref e) => FixedVector(~ty.clean(),
|
ty_fixed_length_vec(ty, ref e) => FixedVector(~ty.clean(),
|
||||||
|
|
|
@ -340,13 +340,7 @@ impl fmt::Default for clean::Type {
|
||||||
clean::Unit => f.buf.write("()".as_bytes()),
|
clean::Unit => f.buf.write("()".as_bytes()),
|
||||||
clean::Bottom => f.buf.write("!".as_bytes()),
|
clean::Bottom => f.buf.write("!".as_bytes()),
|
||||||
clean::Unique(ref t) => write!(f.buf, "~{}", **t),
|
clean::Unique(ref t) => write!(f.buf, "~{}", **t),
|
||||||
clean::Managed(m, ref t) => {
|
clean::Managed(ref t) => write!(f.buf, "@{}", **t),
|
||||||
write!(f.buf, "@{}{}",
|
|
||||||
match m {
|
|
||||||
clean::Mutable => "mut ",
|
|
||||||
clean::Immutable => "",
|
|
||||||
}, **t)
|
|
||||||
}
|
|
||||||
clean::RawPointer(m, ref t) => {
|
clean::RawPointer(m, ref t) => {
|
||||||
write!(f.buf, "*{}{}",
|
write!(f.buf, "*{}{}",
|
||||||
match m {
|
match m {
|
||||||
|
|
|
@ -415,7 +415,6 @@ pub enum Vstore {
|
||||||
pub enum ExprVstore {
|
pub enum ExprVstore {
|
||||||
ExprVstoreUniq, // ~[1,2,3,4]
|
ExprVstoreUniq, // ~[1,2,3,4]
|
||||||
ExprVstoreBox, // @[1,2,3,4]
|
ExprVstoreBox, // @[1,2,3,4]
|
||||||
ExprVstoreMutBox, // @mut [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]
|
||||||
}
|
}
|
||||||
|
@ -444,7 +443,7 @@ pub enum BinOp {
|
||||||
|
|
||||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||||
pub enum UnOp {
|
pub enum UnOp {
|
||||||
UnBox(Mutability),
|
UnBox,
|
||||||
UnUniq,
|
UnUniq,
|
||||||
UnDeref,
|
UnDeref,
|
||||||
UnNot,
|
UnNot,
|
||||||
|
@ -875,7 +874,7 @@ pub struct TyBareFn {
|
||||||
pub enum ty_ {
|
pub enum ty_ {
|
||||||
ty_nil,
|
ty_nil,
|
||||||
ty_bot, /* bottom type */
|
ty_bot, /* bottom type */
|
||||||
ty_box(mt),
|
ty_box(P<Ty>),
|
||||||
ty_uniq(P<Ty>),
|
ty_uniq(P<Ty>),
|
||||||
ty_vec(P<Ty>),
|
ty_vec(P<Ty>),
|
||||||
ty_fixed_length_vec(P<Ty>, @Expr),
|
ty_fixed_length_vec(P<Ty>, @Expr),
|
||||||
|
|
|
@ -137,13 +137,13 @@ pub fn is_shift_binop(b: BinOp) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unop_to_str(op: UnOp) -> ~str {
|
pub fn unop_to_str(op: UnOp) -> &'static str {
|
||||||
match op {
|
match op {
|
||||||
UnBox(mt) => if mt == MutMutable { ~"@mut " } else { ~"@" },
|
UnBox => "@",
|
||||||
UnUniq => ~"~",
|
UnUniq => "~",
|
||||||
UnDeref => ~"*",
|
UnDeref => "*",
|
||||||
UnNot => ~"!",
|
UnNot => "!",
|
||||||
UnNeg => ~"-"
|
UnNeg => "-",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ pub trait AstBuilder {
|
||||||
lifetime: Option<ast::Lifetime>,
|
lifetime: Option<ast::Lifetime>,
|
||||||
mutbl: ast::Mutability) -> P<ast::Ty>;
|
mutbl: ast::Mutability) -> P<ast::Ty>;
|
||||||
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>;
|
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>;
|
||||||
fn ty_box(&self, span: Span, ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty>;
|
fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>;
|
||||||
|
|
||||||
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>;
|
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>;
|
||||||
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
|
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
|
||||||
|
@ -311,12 +311,13 @@ impl AstBuilder for ExtCtxt {
|
||||||
self.ty(span,
|
self.ty(span,
|
||||||
ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl)))
|
ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> {
|
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> {
|
||||||
self.ty(span, ast::ty_uniq(ty))
|
self.ty(span, ast::ty_uniq(ty))
|
||||||
}
|
}
|
||||||
fn ty_box(&self, span: Span,
|
|
||||||
ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty> {
|
fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> {
|
||||||
self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl)))
|
self.ty(span, ast::ty_box(ty))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
|
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
|
||||||
|
@ -494,7 +495,7 @@ impl AstBuilder for ExtCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
|
fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
|
||||||
self.expr_unary(sp, ast::UnBox(ast::MutImmutable), e)
|
self.expr_unary(sp, ast::UnBox, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr {
|
fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr {
|
||||||
|
|
|
@ -24,7 +24,7 @@ use opt_vec::OptVec;
|
||||||
/// The types of pointers
|
/// The types of pointers
|
||||||
pub enum PtrTy<'a> {
|
pub enum PtrTy<'a> {
|
||||||
Send, // ~
|
Send, // ~
|
||||||
Managed(ast::Mutability), // @[mut]
|
Managed, // @
|
||||||
Borrowed(Option<&'a str>, ast::Mutability), // &['lifetime] [mut]
|
Borrowed(Option<&'a str>, ast::Mutability), // &['lifetime] [mut]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ impl<'a> Ty<'a> {
|
||||||
Send => {
|
Send => {
|
||||||
cx.ty_uniq(span, raw_ty)
|
cx.ty_uniq(span, raw_ty)
|
||||||
}
|
}
|
||||||
Managed(mutbl) => {
|
Managed => {
|
||||||
cx.ty_box(span, raw_ty, mutbl)
|
cx.ty_box(span, raw_ty)
|
||||||
}
|
}
|
||||||
Borrowed(ref lt, mutbl) => {
|
Borrowed(ref lt, mutbl) => {
|
||||||
let lt = mk_lifetime(cx, span, lt);
|
let lt = mk_lifetime(cx, span, lt);
|
||||||
|
@ -251,7 +251,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
|
||||||
span,
|
span,
|
||||||
match *ptr {
|
match *ptr {
|
||||||
Send => ast::sty_uniq(ast::MutImmutable),
|
Send => ast::sty_uniq(ast::MutImmutable),
|
||||||
Managed(mutbl) => ast::sty_box(mutbl),
|
Managed => ast::sty_box(ast::MutImmutable),
|
||||||
Borrowed(ref lt, mutbl) => {
|
Borrowed(ref lt, mutbl) => {
|
||||||
let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s)));
|
let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s)));
|
||||||
ast::sty_region(lt, mutbl)
|
ast::sty_region(lt, mutbl)
|
||||||
|
|
|
@ -238,7 +238,7 @@ pub trait ast_fold {
|
||||||
fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> {
|
fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> {
|
||||||
let node = match t.node {
|
let node = match t.node {
|
||||||
ty_nil | ty_bot | ty_infer => t.node.clone(),
|
ty_nil | ty_bot | ty_infer => t.node.clone(),
|
||||||
ty_box(ref mt) => ty_box(fold_mt(mt, self)),
|
ty_box(ty) => ty_box(self.fold_ty(ty)),
|
||||||
ty_uniq(ty) => ty_uniq(self.fold_ty(ty)),
|
ty_uniq(ty) => ty_uniq(self.fold_ty(ty)),
|
||||||
ty_vec(ty) => ty_vec(self.fold_ty(ty)),
|
ty_vec(ty) => ty_vec(self.fold_ty(ty)),
|
||||||
ty_ptr(ref mt) => ty_ptr(fold_mt(mt, self)),
|
ty_ptr(ref mt) => ty_ptr(fold_mt(mt, self)),
|
||||||
|
|
|
@ -29,8 +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, ExprRepeat};
|
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc, ExprRepeat};
|
||||||
use ast::{ExprRet, ExprSelf, ExprStruct, ExprTup, ExprUnary};
|
use ast::{ExprRet, ExprSelf, ExprStruct, ExprTup, ExprUnary};
|
||||||
use ast::{ExprVec, ExprVstore, ExprVstoreMutBox};
|
use ast::{ExprVec, ExprVstore, ExprVstoreSlice, ExprVstoreBox};
|
||||||
use ast::{ExprVstoreSlice, ExprVstoreBox};
|
|
||||||
use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, extern_fn, Field, fn_decl};
|
use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, extern_fn, Field, fn_decl};
|
||||||
use ast::{ExprVstoreUniq, Onceness, Once, Many};
|
use ast::{ExprVstoreUniq, Onceness, Once, Many};
|
||||||
use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod};
|
use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod};
|
||||||
|
@ -1300,7 +1299,7 @@ impl Parser {
|
||||||
if sigil == OwnedSigil {
|
if sigil == OwnedSigil {
|
||||||
ty_uniq(self.parse_ty(false))
|
ty_uniq(self.parse_ty(false))
|
||||||
} else {
|
} else {
|
||||||
ty_box(self.parse_mt())
|
ty_box(self.parse_ty(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2300,17 +2299,14 @@ impl Parser {
|
||||||
}
|
}
|
||||||
token::AT => {
|
token::AT => {
|
||||||
self.bump();
|
self.bump();
|
||||||
let m = self.parse_mutability();
|
|
||||||
let e = self.parse_prefix_expr();
|
let e = self.parse_prefix_expr();
|
||||||
hi = e.span.hi;
|
hi = e.span.hi;
|
||||||
// HACK: turn @[...] into a @-evec
|
// HACK: turn @[...] into a @-evec
|
||||||
ex = match e.node {
|
ex = match e.node {
|
||||||
ExprVec(..) | ExprRepeat(..) if m == MutMutable =>
|
|
||||||
ExprVstore(e, ExprVstoreMutBox),
|
|
||||||
ExprVec(..) |
|
ExprVec(..) |
|
||||||
ExprLit(@codemap::Spanned { node: lit_str(..), span: _}) |
|
ExprLit(@codemap::Spanned { node: lit_str(..), span: _}) |
|
||||||
ExprRepeat(..) if m == MutImmutable => ExprVstore(e, ExprVstoreBox),
|
ExprRepeat(..) => ExprVstore(e, ExprVstoreBox),
|
||||||
_ => self.mk_unary(UnBox(m), e)
|
_ => self.mk_unary(UnBox, e)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
token::TILDE => {
|
token::TILDE => {
|
||||||
|
|
|
@ -422,7 +422,7 @@ pub fn print_type(s: &mut ps, ty: &ast::Ty) {
|
||||||
match ty.node {
|
match ty.node {
|
||||||
ast::ty_nil => word(&mut s.s, "()"),
|
ast::ty_nil => word(&mut s.s, "()"),
|
||||||
ast::ty_bot => word(&mut s.s, "!"),
|
ast::ty_bot => word(&mut s.s, "!"),
|
||||||
ast::ty_box(ref mt) => { word(&mut s.s, "@"); print_mt(s, mt); }
|
ast::ty_box(ty) => { word(&mut s.s, "@"); print_type(s, ty); }
|
||||||
ast::ty_uniq(ty) => { word(&mut s.s, "~"); print_type(s, ty); }
|
ast::ty_uniq(ty) => { word(&mut s.s, "~"); print_type(s, ty); }
|
||||||
ast::ty_vec(ty) => {
|
ast::ty_vec(ty) => {
|
||||||
word(&mut s.s, "[");
|
word(&mut s.s, "[");
|
||||||
|
@ -1083,10 +1083,6 @@ pub fn print_expr_vstore(s: &mut ps, 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::ExprVstoreBox => word(&mut s.s, "@"),
|
||||||
ast::ExprVstoreMutBox => {
|
|
||||||
word(&mut s.s, "@");
|
|
||||||
word(&mut s.s, "mut");
|
|
||||||
}
|
|
||||||
ast::ExprVstoreSlice => word(&mut s.s, "&"),
|
ast::ExprVstoreSlice => word(&mut s.s, "&"),
|
||||||
ast::ExprVstoreMutSlice => {
|
ast::ExprVstoreMutSlice => {
|
||||||
word(&mut s.s, "&");
|
word(&mut s.s, "&");
|
||||||
|
|
|
@ -302,10 +302,10 @@ pub fn skip_ty<E, V:Visitor<E>>(_: &mut V, _: &Ty, _: E) {
|
||||||
|
|
||||||
pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
|
pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
|
||||||
match typ.node {
|
match typ.node {
|
||||||
ty_uniq(ty) | ty_vec(ty) => {
|
ty_uniq(ty) | ty_vec(ty) | ty_box(ty) => {
|
||||||
visitor.visit_ty(ty, env)
|
visitor.visit_ty(ty, env)
|
||||||
}
|
}
|
||||||
ty_box(ref mutable_type) | ty_ptr(ref mutable_type) => {
|
ty_ptr(ref mutable_type) => {
|
||||||
visitor.visit_ty(mutable_type.ty, env)
|
visitor.visit_ty(mutable_type.ty, env)
|
||||||
}
|
}
|
||||||
ty_rptr(ref lifetime, ref mutable_type) => {
|
ty_rptr(ref lifetime, ref mutable_type) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue