Skip to content

Commit 82a09b9

Browse files
committed
librustc: Remove @mut support from the parser
1 parent 8828129 commit 82a09b9

File tree

20 files changed

+52
-81
lines changed

20 files changed

+52
-81
lines changed

src/librustc/front/feature_gate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ impl Visitor<()> for Context {
189189

190190
fn visit_expr(&mut self, e: @ast::Expr, _: ()) {
191191
match e.node {
192-
ast::ExprUnary(_, ast::UnBox(..), _) |
193-
ast::ExprVstore(_, ast::ExprVstoreBox) |
194-
ast::ExprVstore(_, ast::ExprVstoreMutBox) => {
192+
ast::ExprUnary(_, ast::UnBox, _) |
193+
ast::ExprVstore(_, ast::ExprVstoreBox) => {
195194
self.gate_box(e.span);
196195
}
197196
_ => {}

src/librustc/middle/check_const.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
116116
if is_const {
117117
match e.node {
118118
ExprUnary(_, UnDeref, _) => { }
119-
ExprUnary(_, UnBox(_), _) | ExprUnary(_, UnUniq, _) => {
119+
ExprUnary(_, UnBox, _) | ExprUnary(_, UnUniq, _) => {
120120
sess.span_err(e.span,
121121
"cannot do allocations in constant expressions");
122122
return;
@@ -197,8 +197,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
197197
immutable values");
198198
},
199199
ExprVstore(_, ExprVstoreUniq) |
200-
ExprVstore(_, ExprVstoreBox) |
201-
ExprVstore(_, ExprVstoreMutBox) => {
200+
ExprVstore(_, ExprVstoreBox) => {
202201
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
203202
},
204203

src/librustc/middle/const_eval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ impl ConstEvalVisitor {
239239
ast::ExprVstoreSlice => self.classify(e),
240240
ast::ExprVstoreUniq |
241241
ast::ExprVstoreBox |
242-
ast::ExprVstoreMutBox |
243242
ast::ExprVstoreMutSlice => non_const
244243
}
245244
}

src/librustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub fn check_expr(cx: &mut Context, e: @Expr) {
306306
}
307307

308308
match e.node {
309-
ExprUnary(_, UnBox(_), interior) => {
309+
ExprUnary(_, UnBox, interior) => {
310310
let interior_type = ty::expr_ty(cx.tcx, interior);
311311
let _ = check_durable(cx.tcx, interior_type, interior.span);
312312
}

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
10681068
}
10691069
}
10701070
ast::ExprUnary(_, ast::UnUniq, _) |
1071-
ast::ExprUnary(_, ast::UnBox(..), _) => BoxAllocation,
1071+
ast::ExprUnary(_, ast::UnBox, _) => BoxAllocation,
10721072

10731073
_ => return
10741074
};

src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ fn const_expr_unadjusted(cx: @CrateContext,
377377
let ty = ty::expr_ty(cx.tcx, e);
378378
let is_float = ty::type_is_fp(ty);
379379
return (match u {
380-
ast::UnBox(_) |
381-
ast::UnUniq |
382-
ast::UnDeref => {
380+
ast::UnBox | ast::UnUniq | ast::UnDeref => {
383381
let (dv, _dt) = const_deref(cx, te, ty, true);
384382
dv
385383
}

src/librustc/middle/trans/expr.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,7 @@ fn trans_rvalue_datum_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
590590
ast::ExprPath(_) | ast::ExprSelf => {
591591
return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id));
592592
}
593-
ast::ExprVstore(contents, ast::ExprVstoreBox) |
594-
ast::ExprVstore(contents, ast::ExprVstoreMutBox) => {
593+
ast::ExprVstore(contents, ast::ExprVstoreBox) => {
595594
return tvec::trans_uniq_or_managed_vstore(bcx, heap_managed,
596595
expr, contents);
597596
}
@@ -1406,9 +1405,8 @@ fn trans_unary_datum(bcx: @Block,
14061405
};
14071406
immediate_rvalue_bcx(bcx, llneg, un_ty)
14081407
}
1409-
ast::UnBox(_) => {
1410-
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty,
1411-
heap_managed)
1408+
ast::UnBox => {
1409+
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap_managed)
14121410
}
14131411
ast::UnUniq => {
14141412
let heap = heap_for_unique(bcx, un_ty);

src/librustc/middle/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3257,7 +3257,6 @@ pub fn expr_kind(tcx: ctxt,
32573257
ast::ExprAddrOf(..) |
32583258
ast::ExprBinary(..) |
32593259
ast::ExprVstore(_, ast::ExprVstoreBox) |
3260-
ast::ExprVstore(_, ast::ExprVstoreMutBox) |
32613260
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
32623261
RvalueDatumExpr
32633262
}

src/librustc/middle/typeck/astconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
401401
let typ = match ast_ty.node {
402402
ast::ty_nil => ty::mk_nil(),
403403
ast::ty_bot => ty::mk_bot(),
404-
ast::ty_box(ref mt) => {
405-
let mt = ast::mt { ty: mt.ty, mutbl: ast::MutImmutable };
404+
ast::ty_box(ty) => {
405+
let mt = ast::mt { ty: ty, mutbl: ast::MutImmutable };
406406
mk_pointer(this, rscope, &mt, ty::vstore_box,
407407
|tmt| ty::mk_box(tcx, tmt.ty))
408408
}

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,15 +2628,12 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
26282628
}
26292629
ast::ExprVec(ref args, mutbl) => {
26302630
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
2631-
let mutability;
26322631
let mut any_error = false;
26332632
let mut any_bot = false;
2634-
match vst {
2635-
ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => {
2636-
mutability = ast::MutMutable
2637-
}
2638-
_ => mutability = mutbl
2639-
}
2633+
let mutability = match vst {
2634+
ast::ExprVstoreMutSlice => ast::MutMutable,
2635+
_ => mutbl,
2636+
};
26402637
let t: ty::t = fcx.infcx().next_ty_var();
26412638
for e in args.iter() {
26422639
check_expr_has_type(fcx, *e, t);
@@ -2650,11 +2647,9 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
26502647
}
26512648
if any_error {
26522649
ty::mk_err()
2653-
}
2654-
else if any_bot {
2650+
} else if any_bot {
26552651
ty::mk_bot()
2656-
}
2657-
else {
2652+
} else {
26582653
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
26592654
}
26602655
}
@@ -2663,10 +2658,8 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
26632658
let _ = ty::eval_repeat_count(fcx, count_expr);
26642659
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
26652660
let mutability = match vst {
2666-
ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => {
2667-
ast::MutMutable
2668-
}
2669-
_ => mutbl
2661+
ast::ExprVstoreMutSlice => ast::MutMutable,
2662+
_ => mutbl,
26702663
};
26712664
let t: ty::t = fcx.infcx().next_ty_var();
26722665
check_expr_has_type(fcx, element, t);
@@ -2741,7 +2734,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
27412734
ast::ExprUnary(callee_id, unop, oprnd) => {
27422735
let exp_inner = unpack_expected(fcx, expected, |sty| {
27432736
match unop {
2744-
ast::UnBox(_) | ast::UnUniq => match *sty {
2737+
ast::UnBox | ast::UnUniq => match *sty {
27452738
ty::ty_box(ty) => Some(ty),
27462739
ty::ty_uniq(ref mt) => Some(mt.ty),
27472740
_ => None
@@ -2755,7 +2748,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
27552748
if !ty::type_is_error(oprnd_t) &&
27562749
!ty::type_is_bot(oprnd_t) {
27572750
match unop {
2758-
ast::UnBox(_) => {
2751+
ast::UnBox => {
27592752
oprnd_t = ty::mk_box(tcx, oprnd_t)
27602753
}
27612754
ast::UnUniq => {
@@ -3920,7 +3913,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: @FnCtxt,
39203913
-> ty::vstore {
39213914
match v {
39223915
ast::ExprVstoreUniq => ty::vstore_uniq,
3923-
ast::ExprVstoreBox | ast::ExprVstoreMutBox => ty::vstore_box,
3916+
ast::ExprVstoreBox => ty::vstore_box,
39243917
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
39253918
let r = fcx.infcx().next_region_var(infer::AddrOfSlice(e.span));
39263919
ty::vstore_slice(r)

src/librustdoc/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ pub enum Type {
594594
/// aka ty_bot
595595
Bottom,
596596
Unique(~Type),
597-
Managed(Mutability, ~Type),
597+
Managed(~Type),
598598
RawPointer(Mutability, ~Type),
599599
BorrowedRef { lifetime: Option<Lifetime>, mutability: Mutability, type_: ~Type},
600600
// region, raw, other boxes, mutable
@@ -620,7 +620,7 @@ impl Clean<Type> for ast::Ty {
620620
ty_rptr(ref l, ref m) =>
621621
BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
622622
type_: ~m.ty.clean()},
623-
ty_box(ref m) => Managed(m.mutbl.clean(), ~m.ty.clean()),
623+
ty_box(ty) => Managed(~ty.clean()),
624624
ty_uniq(ty) => Unique(~ty.clean()),
625625
ty_vec(ty) => Vector(~ty.clean()),
626626
ty_fixed_length_vec(ty, ref e) => FixedVector(~ty.clean(),

src/librustdoc/html/format.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,7 @@ impl fmt::Default for clean::Type {
340340
clean::Unit => f.buf.write("()".as_bytes()),
341341
clean::Bottom => f.buf.write("!".as_bytes()),
342342
clean::Unique(ref t) => write!(f.buf, "~{}", **t),
343-
clean::Managed(m, ref t) => {
344-
write!(f.buf, "@{}{}",
345-
match m {
346-
clean::Mutable => "mut ",
347-
clean::Immutable => "",
348-
}, **t)
349-
}
343+
clean::Managed(ref t) => write!(f.buf, "@{}", **t),
350344
clean::RawPointer(m, ref t) => {
351345
write!(f.buf, "*{}{}",
352346
match m {

src/libsyntax/ast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ pub enum Vstore {
415415
pub enum ExprVstore {
416416
ExprVstoreUniq, // ~[1,2,3,4]
417417
ExprVstoreBox, // @[1,2,3,4]
418-
ExprVstoreMutBox, // @mut [1,2,3,4]
419418
ExprVstoreSlice, // &[1,2,3,4]
420419
ExprVstoreMutSlice, // &mut [1,2,3,4]
421420
}
@@ -444,7 +443,7 @@ pub enum BinOp {
444443

445444
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
446445
pub enum UnOp {
447-
UnBox(Mutability),
446+
UnBox,
448447
UnUniq,
449448
UnDeref,
450449
UnNot,
@@ -875,7 +874,7 @@ pub struct TyBareFn {
875874
pub enum ty_ {
876875
ty_nil,
877876
ty_bot, /* bottom type */
878-
ty_box(mt),
877+
ty_box(P<Ty>),
879878
ty_uniq(P<Ty>),
880879
ty_vec(P<Ty>),
881880
ty_fixed_length_vec(P<Ty>, @Expr),

src/libsyntax/ast_util.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ pub fn is_shift_binop(b: BinOp) -> bool {
137137
}
138138
}
139139

140-
pub fn unop_to_str(op: UnOp) -> ~str {
140+
pub fn unop_to_str(op: UnOp) -> &'static str {
141141
match op {
142-
UnBox(mt) => if mt == MutMutable { ~"@mut " } else { ~"@" },
143-
UnUniq => ~"~",
144-
UnDeref => ~"*",
145-
UnNot => ~"!",
146-
UnNeg => ~"-"
142+
UnBox => "@",
143+
UnUniq => "~",
144+
UnDeref => "*",
145+
UnNot => "!",
146+
UnNeg => "-",
147147
}
148148
}
149149

src/libsyntax/ext/build.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait AstBuilder {
5454
lifetime: Option<ast::Lifetime>,
5555
mutbl: ast::Mutability) -> P<ast::Ty>;
5656
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>;
57-
fn ty_box(&self, span: Span, ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty>;
57+
fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>;
5858

5959
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>;
6060
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
@@ -311,12 +311,13 @@ impl AstBuilder for ExtCtxt {
311311
self.ty(span,
312312
ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl)))
313313
}
314+
314315
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> {
315316
self.ty(span, ast::ty_uniq(ty))
316317
}
317-
fn ty_box(&self, span: Span,
318-
ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty> {
319-
self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl)))
318+
319+
fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> {
320+
self.ty(span, ast::ty_box(ty))
320321
}
321322

322323
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
@@ -494,7 +495,7 @@ impl AstBuilder for ExtCtxt {
494495
}
495496

496497
fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr {
497-
self.expr_unary(sp, ast::UnBox(ast::MutImmutable), e)
498+
self.expr_unary(sp, ast::UnBox, e)
498499
}
499500

500501
fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr {

src/libsyntax/ext/deriving/ty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use opt_vec::OptVec;
2424
/// The types of pointers
2525
pub enum PtrTy<'a> {
2626
Send, // ~
27-
Managed(ast::Mutability), // @[mut]
27+
Managed, // @
2828
Borrowed(Option<&'a str>, ast::Mutability), // &['lifetime] [mut]
2929
}
3030

@@ -138,8 +138,8 @@ impl<'a> Ty<'a> {
138138
Send => {
139139
cx.ty_uniq(span, raw_ty)
140140
}
141-
Managed(mutbl) => {
142-
cx.ty_box(span, raw_ty, mutbl)
141+
Managed => {
142+
cx.ty_box(span, raw_ty)
143143
}
144144
Borrowed(ref lt, mutbl) => {
145145
let lt = mk_lifetime(cx, span, lt);
@@ -251,7 +251,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
251251
span,
252252
match *ptr {
253253
Send => ast::sty_uniq(ast::MutImmutable),
254-
Managed(mutbl) => ast::sty_box(mutbl),
254+
Managed => ast::sty_box(ast::MutImmutable),
255255
Borrowed(ref lt, mutbl) => {
256256
let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s)));
257257
ast::sty_region(lt, mutbl)

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ pub trait ast_fold {
238238
fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> {
239239
let node = match t.node {
240240
ty_nil | ty_bot | ty_infer => t.node.clone(),
241-
ty_box(ref mt) => ty_box(fold_mt(mt, self)),
241+
ty_box(ty) => ty_box(self.fold_ty(ty)),
242242
ty_uniq(ty) => ty_uniq(self.fold_ty(ty)),
243243
ty_vec(ty) => ty_vec(self.fold_ty(ty)),
244244
ty_ptr(ref mt) => ty_ptr(fold_mt(mt, self)),

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex};
2929
use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac};
3030
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc, ExprRepeat};
3131
use ast::{ExprRet, ExprSelf, ExprStruct, ExprTup, ExprUnary};
32-
use ast::{ExprVec, ExprVstore, ExprVstoreMutBox};
33-
use ast::{ExprVstoreSlice, ExprVstoreBox};
32+
use ast::{ExprVec, ExprVstore, ExprVstoreSlice, ExprVstoreBox};
3433
use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, extern_fn, Field, fn_decl};
3534
use ast::{ExprVstoreUniq, Onceness, Once, Many};
3635
use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod};
@@ -1300,7 +1299,7 @@ impl Parser {
13001299
if sigil == OwnedSigil {
13011300
ty_uniq(self.parse_ty(false))
13021301
} else {
1303-
ty_box(self.parse_mt())
1302+
ty_box(self.parse_ty(false))
13041303
}
13051304
}
13061305

@@ -2300,17 +2299,14 @@ impl Parser {
23002299
}
23012300
token::AT => {
23022301
self.bump();
2303-
let m = self.parse_mutability();
23042302
let e = self.parse_prefix_expr();
23052303
hi = e.span.hi;
23062304
// HACK: turn @[...] into a @-evec
23072305
ex = match e.node {
2308-
ExprVec(..) | ExprRepeat(..) if m == MutMutable =>
2309-
ExprVstore(e, ExprVstoreMutBox),
23102306
ExprVec(..) |
23112307
ExprLit(@codemap::Spanned { node: lit_str(..), span: _}) |
2312-
ExprRepeat(..) if m == MutImmutable => ExprVstore(e, ExprVstoreBox),
2313-
_ => self.mk_unary(UnBox(m), e)
2308+
ExprRepeat(..) => ExprVstore(e, ExprVstoreBox),
2309+
_ => self.mk_unary(UnBox, e)
23142310
};
23152311
}
23162312
token::TILDE => {

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ pub fn print_type(s: &mut ps, ty: &ast::Ty) {
422422
match ty.node {
423423
ast::ty_nil => word(&mut s.s, "()"),
424424
ast::ty_bot => word(&mut s.s, "!"),
425-
ast::ty_box(ref mt) => { word(&mut s.s, "@"); print_mt(s, mt); }
425+
ast::ty_box(ty) => { word(&mut s.s, "@"); print_type(s, ty); }
426426
ast::ty_uniq(ty) => { word(&mut s.s, "~"); print_type(s, ty); }
427427
ast::ty_vec(ty) => {
428428
word(&mut s.s, "[");
@@ -1083,10 +1083,6 @@ pub fn print_expr_vstore(s: &mut ps, t: ast::ExprVstore) {
10831083
match t {
10841084
ast::ExprVstoreUniq => word(&mut s.s, "~"),
10851085
ast::ExprVstoreBox => word(&mut s.s, "@"),
1086-
ast::ExprVstoreMutBox => {
1087-
word(&mut s.s, "@");
1088-
word(&mut s.s, "mut");
1089-
}
10901086
ast::ExprVstoreSlice => word(&mut s.s, "&"),
10911087
ast::ExprVstoreMutSlice => {
10921088
word(&mut s.s, "&");

0 commit comments

Comments
 (0)