Skip to content

Commit 045a437

Browse files
committed
rustc: Accept 'const' as synonym for 'mutable?'
1 parent f157d0b commit 045a437

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/comp/syntax/parse/parser.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,13 @@ fn parse_path_and_ty_param_substs(p: parser) -> ast::path {
746746

747747
fn parse_mutability(p: parser) -> ast::mutability {
748748
if eat_word(p, "mutable") {
749-
if p.peek() == token::QUES { p.bump(); ret ast::maybe_mut; }
750-
ret ast::mut;
749+
if p.peek() == token::QUES { p.bump(); ast::maybe_mut }
750+
else { ast::mut }
751+
} else if eat_word(p, "const") {
752+
ast::maybe_mut
753+
} else {
754+
ast::imm
751755
}
752-
ret ast::imm;
753756
}
754757

755758
fn parse_field(p: parser, sep: token::token) -> ast::field {

src/comp/syntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
264264
word(s.s, "[");
265265
alt mt.mut {
266266
ast::mut. { word_space(s, "mutable"); }
267-
ast::maybe_mut. { word_space(s, "mutable?"); }
267+
ast::maybe_mut. { word_space(s, "const"); }
268268
ast::imm. { }
269269
}
270270
print_type(s, mt.ty);

src/test/run-pass/maybe-mutable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
// -*- rust -*-
5-
fn len(v: [mutable? int]) -> uint {
5+
fn len(v: [const int]) -> uint {
66
let i = 0u;
77
for x: int in v { i += 1u; }
88
ret i;

src/test/run-pass/mutable-huh-variance-vec1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
// This is ok because the outer vec is covariant with respect
77
// to the inner vec. If the outer vec was mutable then we
88
// couldn't do this.
9-
fn f(&&v: [[mutable? int]]) {
9+
fn f(&&v: [[const int]]) {
1010
}
1111

1212
f(v);

src/test/run-pass/mutable-huh-variance-vec2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
// This is ok because the outer vec is covariant with respect
77
// to the inner vec. If the outer vec was mutable then we
88
// couldn't do this.
9-
fn f(&&v: [mutable? [mutable? int]]) {
9+
fn f(&&v: [const [const int]]) {
1010
}
1111

1212
f(v);

0 commit comments

Comments
 (0)