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 {
|
||||
if eat_word(p, "mutable") {
|
||||
if p.peek() == token::QUES { p.bump(); ret ast::maybe_mut; }
|
||||
ret ast::mut;
|
||||
if p.peek() == token::QUES { p.bump(); ast::maybe_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 {
|
||||
|
|
|
@ -264,7 +264,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
|
|||
word(s.s, "[");
|
||||
alt mt.mut {
|
||||
ast::mut. { word_space(s, "mutable"); }
|
||||
ast::maybe_mut. { word_space(s, "mutable?"); }
|
||||
ast::maybe_mut. { word_space(s, "const"); }
|
||||
ast::imm. { }
|
||||
}
|
||||
print_type(s, mt.ty);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
|
||||
// -*- rust -*-
|
||||
fn len(v: [mutable? int]) -> uint {
|
||||
fn len(v: [const int]) -> uint {
|
||||
let i = 0u;
|
||||
for x: int in v { i += 1u; }
|
||||
ret i;
|
||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
|||
// This is ok because the outer vec is covariant with respect
|
||||
// to the inner vec. If the outer vec was mutable then we
|
||||
// couldn't do this.
|
||||
fn f(&&v: [[mutable? int]]) {
|
||||
fn f(&&v: [[const int]]) {
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
|||
// This is ok because the outer vec is covariant with respect
|
||||
// to the inner vec. If the outer vec was mutable then we
|
||||
// couldn't do this.
|
||||
fn f(&&v: [mutable? [mutable? int]]) {
|
||||
fn f(&&v: [const [const int]]) {
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue