rustc: Accept 'const' as synonym for 'mutable?'
This commit is contained in:
parent
f157d0b32c
commit
045a437556
5 changed files with 10 additions and 7 deletions
|
@ -746,10 +746,13 @@ fn parse_path_and_ty_param_substs(p: parser) -> ast::path {
|
||||||
|
|
||||||
fn parse_mutability(p: parser) -> ast::mutability {
|
fn parse_mutability(p: parser) -> ast::mutability {
|
||||||
if eat_word(p, "mutable") {
|
if eat_word(p, "mutable") {
|
||||||
if p.peek() == token::QUES { p.bump(); ret ast::maybe_mut; }
|
if p.peek() == token::QUES { p.bump(); ast::maybe_mut }
|
||||||
ret ast::mut;
|
else { ast::mut }
|
||||||
|
} else if eat_word(p, "const") {
|
||||||
|
ast::maybe_mut
|
||||||
|
} else {
|
||||||
|
ast::imm
|
||||||
}
|
}
|
||||||
ret ast::imm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_field(p: parser, sep: token::token) -> ast::field {
|
fn parse_field(p: parser, sep: token::token) -> ast::field {
|
||||||
|
|
|
@ -264,7 +264,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
|
||||||
word(s.s, "[");
|
word(s.s, "[");
|
||||||
alt mt.mut {
|
alt mt.mut {
|
||||||
ast::mut. { word_space(s, "mutable"); }
|
ast::mut. { word_space(s, "mutable"); }
|
||||||
ast::maybe_mut. { word_space(s, "mutable?"); }
|
ast::maybe_mut. { word_space(s, "const"); }
|
||||||
ast::imm. { }
|
ast::imm. { }
|
||||||
}
|
}
|
||||||
print_type(s, mt.ty);
|
print_type(s, mt.ty);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
// -*- rust -*-
|
// -*- rust -*-
|
||||||
fn len(v: [mutable? int]) -> uint {
|
fn len(v: [const int]) -> uint {
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
for x: int in v { i += 1u; }
|
for x: int in v { i += 1u; }
|
||||||
ret i;
|
ret i;
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
// This is ok because the outer vec is covariant with respect
|
// This is ok because the outer vec is covariant with respect
|
||||||
// to the inner vec. If the outer vec was mutable then we
|
// to the inner vec. If the outer vec was mutable then we
|
||||||
// couldn't do this.
|
// couldn't do this.
|
||||||
fn f(&&v: [[mutable? int]]) {
|
fn f(&&v: [[const int]]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v);
|
f(v);
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
// This is ok because the outer vec is covariant with respect
|
// This is ok because the outer vec is covariant with respect
|
||||||
// to the inner vec. If the outer vec was mutable then we
|
// to the inner vec. If the outer vec was mutable then we
|
||||||
// couldn't do this.
|
// couldn't do this.
|
||||||
fn f(&&v: [mutable? [mutable? int]]) {
|
fn f(&&v: [const [const int]]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v);
|
f(v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue