Skip to content

Commit 1a26bd1

Browse files
committed
auto merge of #11005 : sanxiyn/rust/mut, r=alexcrichton
There is no `~mut T` and `[mut T]` any more.
2 parents fb6ec38 + 4a13364 commit 1a26bd1

File tree

9 files changed

+48
-48
lines changed

9 files changed

+48
-48
lines changed

src/librustc/middle/typeck/astconv.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ pub static NO_TPS: uint = 2;
282282
pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
283283
this: &AC, rscope: &RS, ast_ty: &ast::Ty) -> ty::t {
284284

285+
fn ast_ty_to_mt<AC:AstConv, RS:RegionScope>(
286+
this: &AC, rscope: &RS, ty: &ast::Ty) -> ty::mt {
287+
288+
ty::mt {ty: ast_ty_to_ty(this, rscope, ty), mutbl: ast::MutImmutable}
289+
}
290+
285291
fn ast_mt_to_mt<AC:AstConv, RS:RegionScope>(
286292
this: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt {
287293

@@ -303,8 +309,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
303309
debug!("mk_pointer(vst={:?})", vst);
304310

305311
match a_seq_ty.ty.node {
306-
ast::ty_vec(ref mt) => {
307-
let mut mt = ast_mt_to_mt(this, rscope, mt);
312+
ast::ty_vec(ty) => {
313+
let mut mt = ast_ty_to_mt(this, rscope, ty);
308314
if a_seq_ty.mutbl == ast::MutMutable {
309315
mt = ty::mt { ty: mt.ty, mutbl: a_seq_ty.mutbl };
310316
}
@@ -394,14 +400,15 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
394400
mk_pointer(this, rscope, mt, ty::vstore_box,
395401
|tmt| ty::mk_box(tcx, tmt))
396402
}
397-
ast::ty_uniq(ref mt) => {
398-
mk_pointer(this, rscope, mt, ty::vstore_uniq,
403+
ast::ty_uniq(ty) => {
404+
let mt = ast::mt { ty: ty, mutbl: ast::MutImmutable };
405+
mk_pointer(this, rscope, &mt, ty::vstore_uniq,
399406
|tmt| ty::mk_uniq(tcx, tmt))
400407
}
401-
ast::ty_vec(ref mt) => {
408+
ast::ty_vec(ty) => {
402409
tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type");
403410
// return /something/ so they can at least get more errors
404-
ty::mk_evec(tcx, ast_mt_to_mt(this, rscope, mt), ty::vstore_uniq)
411+
ty::mk_evec(tcx, ast_ty_to_mt(this, rscope, ty), ty::vstore_uniq)
405412
}
406413
ast::ty_ptr(ref mt) => {
407414
ty::mk_ptr(tcx, ast_mt_to_mt(this, rscope, mt))
@@ -532,15 +539,15 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
532539
}
533540
}
534541
}
535-
ast::ty_fixed_length_vec(ref a_mt, e) => {
542+
ast::ty_fixed_length_vec(ty, e) => {
536543
match const_eval::eval_const_expr_partial(&tcx, e) {
537544
Ok(ref r) => {
538545
match *r {
539546
const_eval::const_int(i) =>
540-
ty::mk_evec(tcx, ast_mt_to_mt(this, rscope, a_mt),
547+
ty::mk_evec(tcx, ast_ty_to_mt(this, rscope, ty),
541548
ty::vstore_fixed(i as uint)),
542549
const_eval::const_uint(i) =>
543-
ty::mk_evec(tcx, ast_mt_to_mt(this, rscope, a_mt),
550+
ty::mk_evec(tcx, ast_ty_to_mt(this, rscope, ty),
544551
ty::vstore_fixed(i as uint)),
545552
_ => {
546553
tcx.sess.span_fatal(

src/librustdoc/clean.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,10 @@ impl Clean<Type> for ast::Ty {
621621
BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
622622
type_: ~m.ty.clean()},
623623
ty_box(ref m) => Managed(m.mutbl.clean(), ~m.ty.clean()),
624-
ty_uniq(ref m) => Unique(~m.ty.clean()),
625-
ty_vec(ref m) => Vector(~m.ty.clean()),
626-
ty_fixed_length_vec(ref m, ref e) => FixedVector(~m.ty.clean(),
627-
e.span.to_src()),
624+
ty_uniq(ty) => Unique(~ty.clean()),
625+
ty_vec(ty) => Vector(~ty.clean()),
626+
ty_fixed_length_vec(ty, ref e) => FixedVector(~ty.clean(),
627+
e.span.to_src()),
628628
ty_tup(ref tys) => Tuple(tys.iter().map(|x| x.clean()).collect()),
629629
ty_path(ref p, ref tpbs, id) =>
630630
resolve_type(p.clean(), tpbs.clean(), id),

src/libsyntax/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,9 @@ pub enum ty_ {
875875
ty_nil,
876876
ty_bot, /* bottom type */
877877
ty_box(mt),
878-
ty_uniq(mt),
879-
ty_vec(mt),
880-
ty_fixed_length_vec(mt, @Expr),
878+
ty_uniq(P<Ty>),
879+
ty_vec(P<Ty>),
880+
ty_fixed_length_vec(P<Ty>, @Expr),
881881
ty_ptr(mt),
882882
ty_rptr(Option<Lifetime>, mt),
883883
ty_closure(@TyClosure),

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl AstBuilder for @ExtCtxt {
312312
ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl)))
313313
}
314314
fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> {
315-
self.ty(span, ast::ty_uniq(self.ty_mt(ty, ast::MutImmutable)))
315+
self.ty(span, ast::ty_uniq(ty))
316316
}
317317
fn ty_box(&self, span: Span,
318318
ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty> {

src/libsyntax/ext/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl Context {
593593
~[]
594594
), None);
595595
let ty = ast::ty_fixed_length_vec(
596-
self.ecx.ty_mt(piece_ty, ast::MutImmutable),
596+
piece_ty,
597597
self.ecx.expr_uint(self.fmtsp, self.pieces.len())
598598
);
599599
let ty = self.ecx.ty(self.fmtsp, ty);

src/libsyntax/fold.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ pub trait ast_fold {
241241
let node = match t.node {
242242
ty_nil | ty_bot | ty_infer => t.node.clone(),
243243
ty_box(ref mt) => ty_box(fold_mt(mt, self)),
244-
ty_uniq(ref mt) => ty_uniq(fold_mt(mt, self)),
245-
ty_vec(ref mt) => ty_vec(fold_mt(mt, self)),
244+
ty_uniq(ty) => ty_uniq(self.fold_ty(ty)),
245+
ty_vec(ty) => ty_vec(self.fold_ty(ty)),
246246
ty_ptr(ref mt) => ty_ptr(fold_mt(mt, self)),
247247
ty_rptr(ref region, ref mt) => {
248248
ty_rptr(fold_opt_lifetime(region, self), fold_mt(mt, self))
@@ -272,8 +272,8 @@ pub trait ast_fold {
272272
fold_opt_bounds(bounds, self),
273273
self.new_id(id))
274274
}
275-
ty_fixed_length_vec(ref mt, e) => {
276-
ty_fixed_length_vec(fold_mt(mt, self), self.fold_expr(e))
275+
ty_fixed_length_vec(ty, e) => {
276+
ty_fixed_length_vec(self.fold_ty(ty), self.fold_expr(e))
277277
}
278278
ty_typeof(expr) => ty_typeof(self.fold_expr(expr)),
279279
};

src/libsyntax/parse/parser.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,25 +1213,25 @@ impl Parser {
12131213
} else if *self.token == token::AT {
12141214
// MANAGED POINTER
12151215
self.bump();
1216-
self.parse_box_or_uniq_pointee(ManagedSigil, ty_box)
1216+
self.parse_box_or_uniq_pointee(ManagedSigil)
12171217
} else if *self.token == token::TILDE {
12181218
// OWNED POINTER
12191219
self.bump();
1220-
self.parse_box_or_uniq_pointee(OwnedSigil, ty_uniq)
1220+
self.parse_box_or_uniq_pointee(OwnedSigil)
12211221
} else if *self.token == token::BINOP(token::STAR) {
12221222
// STAR POINTER (bare pointer?)
12231223
self.bump();
12241224
ty_ptr(self.parse_mt())
12251225
} else if *self.token == token::LBRACKET {
12261226
// VECTOR
12271227
self.expect(&token::LBRACKET);
1228-
let mt = mt { ty: self.parse_ty(false), mutbl: MutImmutable };
1228+
let t = self.parse_ty(false);
12291229

12301230
// Parse the `, ..e` in `[ int, ..e ]`
12311231
// where `e` is a const expression
12321232
let t = match self.maybe_parse_fixed_vstore() {
1233-
None => ty_vec(mt),
1234-
Some(suffix) => ty_fixed_length_vec(mt, suffix)
1233+
None => ty_vec(t),
1234+
Some(suffix) => ty_fixed_length_vec(t, suffix)
12351235
};
12361236
self.expect(&token::RBRACKET);
12371237
t
@@ -1284,8 +1284,7 @@ impl Parser {
12841284

12851285
// parse the type following a @ or a ~
12861286
pub fn parse_box_or_uniq_pointee(&self,
1287-
sigil: ast::Sigil,
1288-
ctor: |v: mt| -> ty_)
1287+
sigil: ast::Sigil)
12891288
-> ty_ {
12901289
// ~'foo fn() or ~fn() are parsed directly as obsolete fn types:
12911290
match *self.token {
@@ -1309,9 +1308,9 @@ impl Parser {
13091308
// rather than boxed ptrs. But the special casing of str/vec is not
13101309
// reflected in the AST type.
13111310
if sigil == OwnedSigil {
1312-
ctor(mt { ty: self.parse_ty(false), mutbl: MutImmutable })
1311+
ty_uniq(self.parse_ty(false))
13131312
} else {
1314-
ctor(self.parse_mt())
1313+
ty_box(self.parse_mt())
13151314
}
13161315
}
13171316

src/libsyntax/print/pprust.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,10 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
401401
ast::ty_nil => word(s.s, "()"),
402402
ast::ty_bot => word(s.s, "!"),
403403
ast::ty_box(ref mt) => { word(s.s, "@"); print_mt(s, mt); }
404-
ast::ty_uniq(ref mt) => { word(s.s, "~"); print_mt(s, mt); }
405-
ast::ty_vec(ref mt) => {
404+
ast::ty_uniq(ty) => { word(s.s, "~"); print_type(s, ty); }
405+
ast::ty_vec(ty) => {
406406
word(s.s, "[");
407-
match mt.mutbl {
408-
ast::MutMutable => word_space(s, "mut"),
409-
ast::MutImmutable => ()
410-
}
411-
print_type(s, mt.ty);
407+
print_type(s, ty);
412408
word(s.s, "]");
413409
}
414410
ast::ty_ptr(ref mt) => { word(s.s, "*"); print_mt(s, mt); }
@@ -444,13 +440,9 @@ pub fn print_type(s: @ps, ty: &ast::Ty) {
444440
Some(&generics), None);
445441
}
446442
ast::ty_path(ref path, ref bounds, _) => print_bounded_path(s, path, bounds),
447-
ast::ty_fixed_length_vec(ref mt, v) => {
443+
ast::ty_fixed_length_vec(ty, v) => {
448444
word(s.s, "[");
449-
match mt.mutbl {
450-
ast::MutMutable => word_space(s, "mut"),
451-
ast::MutImmutable => ()
452-
}
453-
print_type(s, mt.ty);
445+
print_type(s, ty);
454446
word(s.s, ", ..");
455447
print_expr(s, v);
456448
word(s.s, "]");

src/libsyntax/visit.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ pub fn skip_ty<E, V:Visitor<E>>(_: &mut V, _: &Ty, _: E) {
302302

303303
pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
304304
match typ.node {
305-
ty_box(ref mutable_type) | ty_uniq(ref mutable_type) |
306-
ty_vec(ref mutable_type) | ty_ptr(ref mutable_type) => {
305+
ty_uniq(ty) | ty_vec(ty) => {
306+
visitor.visit_ty(ty, env)
307+
}
308+
ty_box(ref mutable_type) | ty_ptr(ref mutable_type) => {
307309
visitor.visit_ty(mutable_type.ty, env)
308310
}
309311
ty_rptr(ref lifetime, ref mutable_type) => {
@@ -344,8 +346,8 @@ pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
344346
walk_ty_param_bounds(visitor, bounds, env.clone())
345347
}
346348
}
347-
ty_fixed_length_vec(ref mutable_type, expression) => {
348-
visitor.visit_ty(mutable_type.ty, env.clone());
349+
ty_fixed_length_vec(ty, expression) => {
350+
visitor.visit_ty(ty, env.clone());
349351
visitor.visit_expr(expression, env)
350352
}
351353
ty_typeof(expression) => {

0 commit comments

Comments
 (0)