Bulk-edit mutable -> mut.
This commit is contained in:
parent
34283ce7e8
commit
6e6798c4e1
160 changed files with 772 additions and 772 deletions
|
@ -8,7 +8,7 @@ else export
|
||||||
f32 f64 fail false float fn for
|
f32 f64 fail false float fn for
|
||||||
i16 i32 i64 i8 if import in int
|
i16 i32 i64 i8 if import in int
|
||||||
let log loop
|
let log loop
|
||||||
mod mutable
|
mod mut
|
||||||
native note
|
native note
|
||||||
obj
|
obj
|
||||||
prove pure
|
prove pure
|
||||||
|
|
|
@ -218,14 +218,14 @@ CodeMirror.defineMode("rust", function() {
|
||||||
if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
|
if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
|
||||||
if (content == "||") return cont(poplex, pushlex("}", "block"), block);
|
if (content == "||") return cont(poplex, pushlex("}", "block"), block);
|
||||||
}
|
}
|
||||||
if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
|
if (content == "mut" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
|
||||||
&& !cx.stream.match("::", false)))
|
&& !cx.stream.match("::", false)))
|
||||||
return pass(record_of(expression));
|
return pass(record_of(expression));
|
||||||
return pass(block);
|
return pass(block);
|
||||||
}
|
}
|
||||||
function record_of(comb) {
|
function record_of(comb) {
|
||||||
function ro(type) {
|
function ro(type) {
|
||||||
if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
|
if (content == "mut" || content == "with") {cx.marked = "keyword"; return cont(ro);}
|
||||||
if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
|
if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
|
||||||
if (type == ":") return cont(comb, ro);
|
if (type == ":") return cont(comb, ro);
|
||||||
if (type == "}") return cont();
|
if (type == "}") return cont();
|
||||||
|
@ -317,7 +317,7 @@ CodeMirror.defineMode("rust", function() {
|
||||||
}
|
}
|
||||||
function rtype(type) {
|
function rtype(type) {
|
||||||
if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
|
if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
|
||||||
if (content == "mutable") {cx.marked = "keyword"; return cont(rtype);}
|
if (content == "mut") {cx.marked = "keyword"; return cont(rtype);}
|
||||||
if (type == "atom") return cont(rtypemaybeparam);
|
if (type == "atom") return cont(rtypemaybeparam);
|
||||||
if (type == "op" || type == "obj") return cont(rtype);
|
if (type == "op" || type == "obj") return cont(rtype);
|
||||||
if (type == "fn") return cont(fntype);
|
if (type == "fn") return cont(fntype);
|
||||||
|
|
18
doc/rust.md
18
doc/rust.md
|
@ -217,7 +217,7 @@ else enum export
|
||||||
fail false fn for
|
fail false fn for
|
||||||
if iface impl import
|
if iface impl import
|
||||||
let log loop
|
let log loop
|
||||||
mod mutable
|
mod mut
|
||||||
native
|
native
|
||||||
pure
|
pure
|
||||||
resource ret
|
resource ret
|
||||||
|
@ -1527,13 +1527,13 @@ rec_expr : '{' ident ':' expr
|
||||||
A _[record](#record-types) expression_ is one or more comma-separated
|
A _[record](#record-types) expression_ is one or more comma-separated
|
||||||
name-value pairs enclosed by braces. A fieldname can be any identifier
|
name-value pairs enclosed by braces. A fieldname can be any identifier
|
||||||
(including keywords), and is separated from its value expression by a
|
(including keywords), and is separated from its value expression by a
|
||||||
colon. To indicate that a field is mutable, the `mutable` keyword is
|
colon. To indicate that a field is mutable, the `mut` keyword is
|
||||||
written before its name.
|
written before its name.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
{x: 10f, y: 20f};
|
{x: 10f, y: 20f};
|
||||||
{name: "Joe", age: 35u, score: 100_000};
|
{name: "Joe", age: 35u, score: 100_000};
|
||||||
{ident: "X", mutable count: 0u};
|
{ident: "X", mut count: 0u};
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
The order of the fields in a record expression is significant, and
|
The order of the fields in a record expression is significant, and
|
||||||
|
@ -1586,19 +1586,19 @@ expression on the left of the dot.
|
||||||
### Vector expressions
|
### Vector expressions
|
||||||
|
|
||||||
~~~~~~~~{.ebnf .gram}
|
~~~~~~~~{.ebnf .gram}
|
||||||
vec_expr : '[' "mutable" ? [ expr [ ',' expr ] * ] ? ']'
|
vec_expr : '[' "mut" ? [ expr [ ',' expr ] * ] ? ']'
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
A _[vector](#vector-types) expression_ is written by enclosing zero or
|
A _[vector](#vector-types) expression_ is written by enclosing zero or
|
||||||
more comma-separated expressions of uniform type in square brackets.
|
more comma-separated expressions of uniform type in square brackets.
|
||||||
The keyword `mutable` can be written after the opening bracket to
|
The keyword `mut` can be written after the opening bracket to
|
||||||
indicate that the elements of the resulting vector may be mutated.
|
indicate that the elements of the resulting vector may be mutated.
|
||||||
When no mutability is specified, the vector is immutable.
|
When no mutability is specified, the vector is immutable.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
[1, 2, 3, 4];
|
[1, 2, 3, 4];
|
||||||
["a", "b", "c", "d"];
|
["a", "b", "c", "d"];
|
||||||
[mutable 0u8, 0u8, 0u8, 0u8];
|
[mut 0u8, 0u8, 0u8, 0u8];
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
### Index expressions
|
### Index expressions
|
||||||
|
@ -1622,7 +1622,7 @@ task in a _failing state_.
|
||||||
# task::run(builder) {||
|
# task::run(builder) {||
|
||||||
|
|
||||||
[1, 2, 3, 4][0];
|
[1, 2, 3, 4][0];
|
||||||
[mutable 'x', 'y'][1] = 'z';
|
[mut 'x', 'y'][1] = 'z';
|
||||||
["a", "b"][10]; // fails
|
["a", "b"][10]; // fails
|
||||||
|
|
||||||
# }
|
# }
|
||||||
|
@ -1904,11 +1904,11 @@ argument to a function to be copied and passed by value.
|
||||||
An example of a copy expression:
|
An example of a copy expression:
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
fn mutate(vec: [mutable int]) {
|
fn mutate(vec: [mut int]) {
|
||||||
vec[0] = 10;
|
vec[0] = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
let v = [mutable 1,2,3];
|
let v = [mut 1,2,3];
|
||||||
|
|
||||||
mutate(copy v); // Pass a copy
|
mutate(copy v); // Pass a copy
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ more detail later on (the `T`s here stand for any other type):
|
||||||
`[T]`
|
`[T]`
|
||||||
: Vector type.
|
: Vector type.
|
||||||
|
|
||||||
`[mutable T]`
|
`[mut T]`
|
||||||
: Mutable vector type.
|
: Mutable vector type.
|
||||||
|
|
||||||
`(T1, T2)`
|
`(T1, T2)`
|
||||||
|
@ -994,10 +994,10 @@ Fields that you want to mutate must be explicitly marked as such. For
|
||||||
example...
|
example...
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
type stack = {content: [int], mutable head: uint};
|
type stack = {content: [int], mut head: uint};
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
With such a type, you can do `mystack.head += 1u`. If `mutable` were
|
With such a type, you can do `mystack.head += 1u`. If `mut` were
|
||||||
omitted from the type, such an assignment would result in a type
|
omitted from the type, such an assignment would result in a type
|
||||||
error.
|
error.
|
||||||
|
|
||||||
|
@ -1240,12 +1240,12 @@ become the sole owner of the box.
|
||||||
|
|
||||||
### Mutability
|
### Mutability
|
||||||
|
|
||||||
All pointer types have a mutable variant, written `@mutable TYPE` or
|
All pointer types have a mutable variant, written `@mut TYPE` or
|
||||||
`~mutable TYPE`. Given such a pointer, you can write to its contents
|
`~mut TYPE`. Given such a pointer, you can write to its contents
|
||||||
by combining the dereference operator with a mutating action.
|
by combining the dereference operator with a mutating action.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
fn increase_contents(pt: @mutable int) {
|
fn increase_contents(pt: @mut int) {
|
||||||
*pt += 1;
|
*pt += 1;
|
||||||
}
|
}
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -1268,9 +1268,9 @@ if myvec[1] { io::println("boom"); }
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
By default, vectors are immutable—you can not replace their elements.
|
By default, vectors are immutable—you can not replace their elements.
|
||||||
The type written as `[mutable TYPE]` is a vector with mutable
|
The type written as `[mut TYPE]` is a vector with mutable
|
||||||
elements. Mutable vector literals are written `[mutable]` (empty) or
|
elements. Mutable vector literals are written `[mut]` (empty) or
|
||||||
`[mutable 1, 2, 3]` (with elements).
|
`[mut 1, 2, 3]` (with elements).
|
||||||
|
|
||||||
The `+` operator means concatenation when applied to vector types.
|
The `+` operator means concatenation when applied to vector types.
|
||||||
Growing a vector in Rust is not as inefficient as it looks :
|
Growing a vector in Rust is not as inefficient as it looks :
|
||||||
|
@ -1398,7 +1398,7 @@ to pessimistically assume a value will get mutated, even though it is
|
||||||
not sure.
|
not sure.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
fn for_each(v: [mutable @int], iter: fn(@int)) {
|
fn for_each(v: [mut @int], iter: fn(@int)) {
|
||||||
for elt in v { iter(elt); }
|
for elt in v { iter(elt); }
|
||||||
}
|
}
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -1413,15 +1413,15 @@ reference count is considered cheap enough to not warn about it).
|
||||||
## The copy operator
|
## The copy operator
|
||||||
|
|
||||||
If the `for_each` function given above were to take a vector of
|
If the `for_each` function given above were to take a vector of
|
||||||
`{mutable a: int}` instead of `@int`, it would not be able to
|
`{mut a: int}` instead of `@int`, it would not be able to
|
||||||
implicitly copy, since if the `iter` function changes a copy of a
|
implicitly copy, since if the `iter` function changes a copy of a
|
||||||
mutable record, the changes won't be visible in the record itself. If
|
mutable record, the changes won't be visible in the record itself. If
|
||||||
we *do* want to allow copies there, we have to explicitly allow it
|
we *do* want to allow copies there, we have to explicitly allow it
|
||||||
with the `copy` operator:
|
with the `copy` operator:
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
type mutrec = {mutable x: int};
|
type mutrec = {mut x: int};
|
||||||
fn for_each(v: [mutable mutrec], iter: fn(mutrec)) {
|
fn for_each(v: [mut mutrec], iter: fn(mutrec)) {
|
||||||
for elt in v { iter(copy elt); }
|
for elt in v { iter(copy elt); }
|
||||||
}
|
}
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -1529,7 +1529,7 @@ Generic `type` and `enum` declarations follow the same pattern:
|
||||||
~~~~
|
~~~~
|
||||||
type circular_buf<T> = {start: uint,
|
type circular_buf<T> = {start: uint,
|
||||||
end: uint,
|
end: uint,
|
||||||
buf: [mutable T]};
|
buf: [mut T]};
|
||||||
|
|
||||||
enum option<T> { some(T), none }
|
enum option<T> { some(T), none }
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -2315,14 +2315,14 @@ microsecond-resolution timer.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
use std;
|
use std;
|
||||||
type timeval = {mutable tv_sec: uint,
|
type timeval = {mut tv_sec: uint,
|
||||||
mutable tv_usec: uint};
|
mut tv_usec: uint};
|
||||||
#[nolink]
|
#[nolink]
|
||||||
native mod libc {
|
native mod libc {
|
||||||
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
|
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
|
||||||
}
|
}
|
||||||
fn unix_time_in_microseconds() -> u64 unsafe {
|
fn unix_time_in_microseconds() -> u64 unsafe {
|
||||||
let x = {mutable tv_sec: 0u, mutable tv_usec: 0u};
|
let x = {mut tv_sec: 0u, mut tv_usec: 0u};
|
||||||
libc::gettimeofday(ptr::addr_of(x), ptr::null());
|
libc::gettimeofday(ptr::addr_of(x), ptr::null());
|
||||||
ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
|
ret (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ type source = {
|
||||||
sig: option<str>,
|
sig: option<str>,
|
||||||
key: option<str>,
|
key: option<str>,
|
||||||
keyfp: option<str>,
|
keyfp: option<str>,
|
||||||
mutable packages: [package]
|
mut packages: [package]
|
||||||
};
|
};
|
||||||
|
|
||||||
type cargo = {
|
type cargo = {
|
||||||
|
@ -117,10 +117,10 @@ fn load_pkg(filename: str) -> option<pkg> {
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
let sess = @{
|
let sess = @{
|
||||||
cm: cm,
|
cm: cm,
|
||||||
mutable next_id: 1,
|
mut next_id: 1,
|
||||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
};
|
};
|
||||||
let c = parser::parse_crate_from_crate_file(filename, [], sess);
|
let c = parser::parse_crate_from_crate_file(filename, [], sess);
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ fn parse_source(name: str, j: json::json) -> source {
|
||||||
_ { none }
|
_ { none }
|
||||||
};
|
};
|
||||||
ret { name: name, url: url, sig: sig, key: key, keyfp: keyfp,
|
ret { name: name, url: url, sig: sig, key: key, keyfp: keyfp,
|
||||||
mutable packages: [] };
|
mut packages: [] };
|
||||||
}
|
}
|
||||||
_ { fail "Needed dict value in source."; }
|
_ { fail "Needed dict value in source."; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -119,7 +119,7 @@ fn safe_to_steal_ty(t: @ast::ty, tm: test_mode) -> bool {
|
||||||
|
|
||||||
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
|
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
|
||||||
fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
|
fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
|
||||||
es: @mutable [ast::expr],
|
es: @mut [ast::expr],
|
||||||
e: @ast::expr,
|
e: @ast::expr,
|
||||||
tm: test_mode) {
|
tm: test_mode) {
|
||||||
if c(e, tm) {
|
if c(e, tm) {
|
||||||
|
@ -128,7 +128,7 @@ fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stash_ty_if(c: fn@(@ast::ty, test_mode)->bool,
|
fn stash_ty_if(c: fn@(@ast::ty, test_mode)->bool,
|
||||||
es: @mutable [ast::ty],
|
es: @mut [ast::ty],
|
||||||
e: @ast::ty,
|
e: @ast::ty,
|
||||||
tm: test_mode) {
|
tm: test_mode) {
|
||||||
if c(e, tm) {
|
if c(e, tm) {
|
||||||
|
@ -139,8 +139,8 @@ fn stash_ty_if(c: fn@(@ast::ty, test_mode)->bool,
|
||||||
type stolen_stuff = {exprs: [ast::expr], tys: [ast::ty]};
|
type stolen_stuff = {exprs: [ast::expr], tys: [ast::ty]};
|
||||||
|
|
||||||
fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff {
|
fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff {
|
||||||
let exprs = @mutable [];
|
let exprs = @mut [];
|
||||||
let tys = @mutable [];
|
let tys = @mut [];
|
||||||
let v = visit::mk_simple_visitor(@{
|
let v = visit::mk_simple_visitor(@{
|
||||||
visit_expr: bind stash_expr_if(safe_to_steal_expr, exprs, _, tm),
|
visit_expr: bind stash_expr_if(safe_to_steal_expr, exprs, _, tm),
|
||||||
visit_ty: bind stash_ty_if(safe_to_steal_ty, tys, _, tm)
|
visit_ty: bind stash_ty_if(safe_to_steal_ty, tys, _, tm)
|
||||||
|
@ -176,8 +176,8 @@ fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
|
||||||
// Replace the |i|th expr (in fold order) of |crate| with |newexpr|.
|
// Replace the |i|th expr (in fold order) of |crate| with |newexpr|.
|
||||||
fn replace_expr_in_crate(crate: ast::crate, i: uint, newexpr: ast::expr, tm: test_mode) ->
|
fn replace_expr_in_crate(crate: ast::crate, i: uint, newexpr: ast::expr, tm: test_mode) ->
|
||||||
ast::crate {
|
ast::crate {
|
||||||
let j: @mutable uint = @mutable 0u;
|
let j: @mut uint = @mut 0u;
|
||||||
fn fold_expr_rep(j_: @mutable uint, i_: uint, newexpr_: ast::expr_,
|
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
|
||||||
original: ast::expr_, fld: fold::ast_fold, tm_: test_mode) ->
|
original: ast::expr_, fld: fold::ast_fold, tm_: test_mode) ->
|
||||||
ast::expr_ {
|
ast::expr_ {
|
||||||
*j_ += 1u;
|
*j_ += 1u;
|
||||||
|
@ -199,8 +199,8 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint, newexpr: ast::expr, tm: tes
|
||||||
// Replace the |i|th ty (in fold order) of |crate| with |newty|.
|
// Replace the |i|th ty (in fold order) of |crate| with |newty|.
|
||||||
fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::ty, tm: test_mode) ->
|
fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::ty, tm: test_mode) ->
|
||||||
ast::crate {
|
ast::crate {
|
||||||
let j: @mutable uint = @mutable 0u;
|
let j: @mut uint = @mut 0u;
|
||||||
fn fold_ty_rep(j_: @mutable uint, i_: uint, newty_: ast::ty_,
|
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
|
||||||
original: ast::ty_, fld: fold::ast_fold, tm_: test_mode) ->
|
original: ast::ty_, fld: fold::ast_fold, tm_: test_mode) ->
|
||||||
ast::ty_ {
|
ast::ty_ {
|
||||||
*j_ += 1u;
|
*j_ += 1u;
|
||||||
|
@ -403,10 +403,10 @@ fn parse_and_print(code: @str) -> str {
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
let sess = @{
|
let sess = @{
|
||||||
cm: cm,
|
cm: cm,
|
||||||
mutable next_id: 1,
|
mut next_id: 1,
|
||||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
};
|
};
|
||||||
write_file(filename, *code);
|
write_file(filename, *code);
|
||||||
let crate = parser::parse_crate_from_source_str(
|
let crate = parser::parse_crate_from_source_str(
|
||||||
|
@ -422,8 +422,8 @@ fn parse_and_print(code: @str) -> str {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_raw_pointers(c: ast::crate) -> bool {
|
fn has_raw_pointers(c: ast::crate) -> bool {
|
||||||
let has_rp = @mutable false;
|
let has_rp = @mut false;
|
||||||
fn visit_ty(flag: @mutable bool, t: @ast::ty) {
|
fn visit_ty(flag: @mut bool, t: @ast::ty) {
|
||||||
alt t.node {
|
alt t.node {
|
||||||
ast::ty_ptr(_) { *flag = true; }
|
ast::ty_ptr(_) { *flag = true; }
|
||||||
_ { }
|
_ { }
|
||||||
|
@ -549,10 +549,10 @@ fn check_variants(files: [str], cx: context) {
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
let sess = @{
|
let sess = @{
|
||||||
cm: cm,
|
cm: cm,
|
||||||
mutable next_id: 1,
|
mut next_id: 1,
|
||||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
};
|
};
|
||||||
let crate =
|
let crate =
|
||||||
parser::parse_crate_from_source_str(
|
parser::parse_crate_from_source_str(
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn choice<T: copy>(r : rand::rng, v : [T]) -> T { assert vec::len(v) != 0u; v[un
|
||||||
fn unlikely(r : rand::rng, n : uint) -> bool { under(r, n) == 0u }
|
fn unlikely(r : rand::rng, n : uint) -> bool { under(r, n) == 0u }
|
||||||
|
|
||||||
// shuffle a vec in place
|
// shuffle a vec in place
|
||||||
fn shuffle<T>(r : rand::rng, &v : [mutable T]) {
|
fn shuffle<T>(r : rand::rng, &v : [mut T]) {
|
||||||
let i = vec::len(v);
|
let i = vec::len(v);
|
||||||
while i >= 2u {
|
while i >= 2u {
|
||||||
// Loop invariant: elements with index >= i have been locked in place.
|
// Loop invariant: elements with index >= i have been locked in place.
|
||||||
|
@ -73,7 +73,7 @@ fn main()
|
||||||
log(error, choice(r, [10, 20, 30]));
|
log(error, choice(r, [10, 20, 30]));
|
||||||
log(error, if unlikely(r, 5u) { "unlikely" } else { "likely" });
|
log(error, if unlikely(r, 5u) { "unlikely" } else { "likely" });
|
||||||
|
|
||||||
let a = [mutable 1, 2, 3];
|
let a = [mut 1, 2, 3];
|
||||||
shuffle(r, a);
|
shuffle(r, a);
|
||||||
log(error, a);
|
log(error, a);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ export spawn;
|
||||||
|
|
||||||
#[doc = "The future type"]
|
#[doc = "The future type"]
|
||||||
enum future<A> = {
|
enum future<A> = {
|
||||||
mutable v: either<@A, fn@() -> A>
|
mut v: either<@A, fn@() -> A>
|
||||||
};
|
};
|
||||||
|
|
||||||
#[doc = "Methods on the `future` type"]
|
#[doc = "Methods on the `future` type"]
|
||||||
|
@ -52,7 +52,7 @@ fn from_value<A>(+val: A) -> future<A> {
|
||||||
"];
|
"];
|
||||||
|
|
||||||
future({
|
future({
|
||||||
mutable v: either::left(@val)
|
mut v: either::left(@val)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ fn from_fn<A>(f: fn@() -> A) -> future<A> {
|
||||||
"];
|
"];
|
||||||
|
|
||||||
future({
|
future({
|
||||||
mutable v: either::right(f)
|
mut v: either::right(f)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,10 @@ fn convert_whence(whence: seek_style) -> i32 {
|
||||||
|
|
||||||
impl of reader for *libc::FILE {
|
impl of reader for *libc::FILE {
|
||||||
fn read_bytes(len: uint) -> [u8] unsafe {
|
fn read_bytes(len: uint) -> [u8] unsafe {
|
||||||
let mut buf : [mutable u8] = [mutable];
|
let mut buf : [mut u8] = [mut];
|
||||||
vec::reserve(buf, len);
|
vec::reserve(buf, len);
|
||||||
vec::as_mut_buf(buf) {|b|
|
vec::as_mut_buf(buf) {|b|
|
||||||
let read = libc::fread(b as *mutable c_void, 1u,
|
let read = libc::fread(b as *mut c_void, 1u,
|
||||||
len, self);
|
len, self);
|
||||||
vec::unsafe::set_len(buf, read);
|
vec::unsafe::set_len(buf, read);
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ fn file_reader(path: str) -> result<reader, str> {
|
||||||
// Byte buffer readers
|
// Byte buffer readers
|
||||||
|
|
||||||
// TODO: const u8, but this fails with rustboot.
|
// TODO: const u8, but this fails with rustboot.
|
||||||
type byte_buf = {buf: [u8], mutable pos: uint, len: uint};
|
type byte_buf = {buf: [u8], mut pos: uint, len: uint};
|
||||||
|
|
||||||
impl of reader for byte_buf {
|
impl of reader for byte_buf {
|
||||||
fn read_bytes(len: uint) -> [u8] {
|
fn read_bytes(len: uint) -> [u8] {
|
||||||
|
@ -268,7 +268,7 @@ fn bytes_reader(bytes: [u8]) -> reader {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bytes_reader_between(bytes: [u8], start: uint, end: uint) -> reader {
|
fn bytes_reader_between(bytes: [u8], start: uint, end: uint) -> reader {
|
||||||
{buf: bytes, mutable pos: start, len: end} as reader
|
{buf: bytes, mut pos: start, len: end} as reader
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_bytes_reader<t>(bytes: [u8], f: fn(reader) -> t) -> t {
|
fn with_bytes_reader<t>(bytes: [u8], f: fn(reader) -> t) -> t {
|
||||||
|
@ -514,14 +514,14 @@ fn stderr() -> writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
|
||||||
fn print(s: str) { stdout().write_str(s); }
|
fn print(s: str) { stdout().write_str(s); }
|
||||||
fn println(s: str) { stdout().write_line(s); }
|
fn println(s: str) { stdout().write_line(s); }
|
||||||
|
|
||||||
type mem_buffer = @{mutable buf: [mutable u8],
|
type mem_buffer = @{mut buf: [mut u8],
|
||||||
mutable pos: uint};
|
mut pos: uint};
|
||||||
|
|
||||||
impl of writer for mem_buffer {
|
impl of writer for mem_buffer {
|
||||||
fn write(v: [const u8]) {
|
fn write(v: [const u8]) {
|
||||||
// Fast path.
|
// Fast path.
|
||||||
if self.pos == vec::len(self.buf) {
|
if self.pos == vec::len(self.buf) {
|
||||||
for b: u8 in v { self.buf += [mutable b]; }
|
for b: u8 in v { self.buf += [mut b]; }
|
||||||
self.pos += vec::len(v);
|
self.pos += vec::len(v);
|
||||||
ret;
|
ret;
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ impl of writer for mem_buffer {
|
||||||
while vpos < vlen {
|
while vpos < vlen {
|
||||||
let b = v[vpos];
|
let b = v[vpos];
|
||||||
if self.pos == vec::len(self.buf) {
|
if self.pos == vec::len(self.buf) {
|
||||||
self.buf += [mutable b];
|
self.buf += [mut b];
|
||||||
} else { self.buf[self.pos] = b; }
|
} else { self.buf[self.pos] = b; }
|
||||||
self.pos += 1u;
|
self.pos += 1u;
|
||||||
vpos += 1u;
|
vpos += 1u;
|
||||||
|
@ -547,7 +547,7 @@ impl of writer for mem_buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mem_buffer() -> mem_buffer {
|
fn mem_buffer() -> mem_buffer {
|
||||||
@{mutable buf: [mutable], mutable pos: 0u}
|
@{mut buf: [mut], mut pos: 0u}
|
||||||
}
|
}
|
||||||
fn mem_buffer_writer(b: mem_buffer) -> writer { b as writer }
|
fn mem_buffer_writer(b: mem_buffer) -> writer { b as writer }
|
||||||
fn mem_buffer_buf(b: mem_buffer) -> [u8] { vec::from_mut(b.buf) }
|
fn mem_buffer_buf(b: mem_buffer) -> [u8] { vec::from_mut(b.buf) }
|
||||||
|
|
|
@ -346,17 +346,17 @@ mod types {
|
||||||
type LPCWSTR = *WCHAR;
|
type LPCWSTR = *WCHAR;
|
||||||
type LPCSTR = *CHAR;
|
type LPCSTR = *CHAR;
|
||||||
|
|
||||||
type LPWSTR = *mutable WCHAR;
|
type LPWSTR = *mut WCHAR;
|
||||||
type LPSTR = *mutable CHAR;
|
type LPSTR = *mut CHAR;
|
||||||
|
|
||||||
// Not really, but opaque to us.
|
// Not really, but opaque to us.
|
||||||
type LPSECURITY_ATTRIBUTES = LPVOID;
|
type LPSECURITY_ATTRIBUTES = LPVOID;
|
||||||
|
|
||||||
type LPVOID = *mutable c_void;
|
type LPVOID = *mut c_void;
|
||||||
type LPWORD = *mutable WORD;
|
type LPWORD = *mut WORD;
|
||||||
|
|
||||||
type LRESULT = LONG_PTR;
|
type LRESULT = LONG_PTR;
|
||||||
type PBOOL = *mutable BOOL;
|
type PBOOL = *mut BOOL;
|
||||||
type WCHAR = wchar_t;
|
type WCHAR = wchar_t;
|
||||||
type WORD = u16;
|
type WORD = u16;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +757,7 @@ mod funcs {
|
||||||
fn setbuf(stream: *FILE, buf: *c_char);
|
fn setbuf(stream: *FILE, buf: *c_char);
|
||||||
// Omitted: printf and scanf variants.
|
// Omitted: printf and scanf variants.
|
||||||
fn fgetc(stream: *FILE) -> c_int;
|
fn fgetc(stream: *FILE) -> c_int;
|
||||||
fn fgets(buf: *mutable c_char, n: c_int,
|
fn fgets(buf: *mut c_char, n: c_int,
|
||||||
stream: *FILE) -> *c_char;
|
stream: *FILE) -> *c_char;
|
||||||
fn fputc(c: c_int, stream: *FILE) -> c_int;
|
fn fputc(c: c_int, stream: *FILE) -> c_int;
|
||||||
fn fputs(s: *c_char, stream: *FILE) -> *c_char;
|
fn fputs(s: *c_char, stream: *FILE) -> *c_char;
|
||||||
|
@ -769,7 +769,7 @@ mod funcs {
|
||||||
// Omitted: putc, putchar (might be macros).
|
// Omitted: putc, putchar (might be macros).
|
||||||
fn puts(s: *c_char) -> c_int;
|
fn puts(s: *c_char) -> c_int;
|
||||||
fn ungetc(c: c_int, stream: *FILE) -> c_int;
|
fn ungetc(c: c_int, stream: *FILE) -> c_int;
|
||||||
fn fread(ptr: *mutable c_void, size: size_t,
|
fn fread(ptr: *mut c_void, size: size_t,
|
||||||
nobj: size_t, stream: *FILE) -> size_t;
|
nobj: size_t, stream: *FILE) -> size_t;
|
||||||
fn fwrite(ptr: *c_void, size: size_t,
|
fn fwrite(ptr: *c_void, size: size_t,
|
||||||
nobj: size_t, stream: *FILE) -> size_t;
|
nobj: size_t, stream: *FILE) -> size_t;
|
||||||
|
@ -933,11 +933,11 @@ mod funcs {
|
||||||
fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long;
|
fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long;
|
||||||
|
|
||||||
#[link_name = "_pipe"]
|
#[link_name = "_pipe"]
|
||||||
fn pipe(fds: *mutable c_int, psize: c_uint,
|
fn pipe(fds: *mut c_int, psize: c_uint,
|
||||||
textmode: c_int) -> c_int;
|
textmode: c_int) -> c_int;
|
||||||
|
|
||||||
#[link_name = "_read"]
|
#[link_name = "_read"]
|
||||||
fn read(fd: c_int, buf: *mutable c_void, count: c_uint) -> c_int;
|
fn read(fd: c_int, buf: *mut c_void, count: c_uint) -> c_int;
|
||||||
|
|
||||||
#[link_name = "_rmdir"]
|
#[link_name = "_rmdir"]
|
||||||
fn rmdir(path: *c_char) -> c_int;
|
fn rmdir(path: *c_char) -> c_int;
|
||||||
|
@ -1013,7 +1013,7 @@ mod funcs {
|
||||||
fn getegid() -> gid_t;
|
fn getegid() -> gid_t;
|
||||||
fn geteuid() -> uid_t;
|
fn geteuid() -> uid_t;
|
||||||
fn getgid() -> gid_t ;
|
fn getgid() -> gid_t ;
|
||||||
fn getgroups(ngroups_max: c_int, groups: *mutable gid_t) -> c_int;
|
fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int;
|
||||||
fn getlogin() -> *c_char;
|
fn getlogin() -> *c_char;
|
||||||
fn getopt(argc: c_int, argv: **c_char, optstr: *c_char) -> c_int;
|
fn getopt(argc: c_int, argv: **c_char, optstr: *c_char) -> c_int;
|
||||||
fn getpgrp() -> pid_t;
|
fn getpgrp() -> pid_t;
|
||||||
|
@ -1025,8 +1025,8 @@ mod funcs {
|
||||||
fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
|
fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
|
||||||
fn pathconf(path: *c_char, name: c_int) -> c_long;
|
fn pathconf(path: *c_char, name: c_int) -> c_long;
|
||||||
fn pause() -> c_int;
|
fn pause() -> c_int;
|
||||||
fn pipe(fds: *mutable c_int) -> c_int;
|
fn pipe(fds: *mut c_int) -> c_int;
|
||||||
fn read(fd: c_int, buf: *mutable c_void,
|
fn read(fd: c_int, buf: *mut c_void,
|
||||||
count: size_t) -> ssize_t;
|
count: size_t) -> ssize_t;
|
||||||
fn rmdir(path: *c_char) -> c_int;
|
fn rmdir(path: *c_char) -> c_int;
|
||||||
fn setgid(gid: gid_t) -> c_int;
|
fn setgid(gid: gid_t) -> c_int;
|
||||||
|
@ -1050,7 +1050,7 @@ mod funcs {
|
||||||
#[nolink]
|
#[nolink]
|
||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
native mod unistd {
|
native mod unistd {
|
||||||
fn readlink(path: *c_char, buf: *mutable c_char,
|
fn readlink(path: *c_char, buf: *mut c_char,
|
||||||
bufsz: size_t) -> ssize_t;
|
bufsz: size_t) -> ssize_t;
|
||||||
|
|
||||||
fn fsync(fd: c_int) -> c_int;
|
fn fsync(fd: c_int) -> c_int;
|
||||||
|
@ -1067,7 +1067,7 @@ mod funcs {
|
||||||
#[nolink]
|
#[nolink]
|
||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
native mod wait {
|
native mod wait {
|
||||||
fn waitpid(pid: pid_t, status: *mutable c_int,
|
fn waitpid(pid: pid_t, status: *mut c_int,
|
||||||
options: c_int) -> pid_t;
|
options: c_int) -> pid_t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1096,15 +1096,15 @@ mod funcs {
|
||||||
native mod bsd44 {
|
native mod bsd44 {
|
||||||
|
|
||||||
fn sysctl(name: *c_int, namelen: c_uint,
|
fn sysctl(name: *c_int, namelen: c_uint,
|
||||||
oldp: *mutable c_void, oldlenp: *mutable size_t,
|
oldp: *mut c_void, oldlenp: *mut size_t,
|
||||||
newp: *c_void, newlen: size_t) -> c_int;
|
newp: *c_void, newlen: size_t) -> c_int;
|
||||||
|
|
||||||
fn sysctlbyname(name: *c_char,
|
fn sysctlbyname(name: *c_char,
|
||||||
oldp: *mutable c_void, oldlenp: *mutable size_t,
|
oldp: *mut c_void, oldlenp: *mut size_t,
|
||||||
newp: *c_void, newlen: size_t) -> c_int;
|
newp: *c_void, newlen: size_t) -> c_int;
|
||||||
|
|
||||||
fn sysctlnametomib(name: *c_char, mibp: *mutable c_int,
|
fn sysctlnametomib(name: *c_char, mibp: *mut c_int,
|
||||||
sizep: *mutable size_t) -> c_int;
|
sizep: *mut size_t) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1118,8 +1118,8 @@ mod funcs {
|
||||||
#[nolink]
|
#[nolink]
|
||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
native mod extra {
|
native mod extra {
|
||||||
fn _NSGetExecutablePath(buf: *mutable c_char,
|
fn _NSGetExecutablePath(buf: *mut c_char,
|
||||||
bufsize: *mutable u32) -> c_int;
|
bufsize: *mut u32) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
|
|
|
@ -109,10 +109,10 @@ fn test_unwrap_str() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unwrap_resource() {
|
fn test_unwrap_resource() {
|
||||||
resource r(i: @mutable int) {
|
resource r(i: @mut int) {
|
||||||
*i += 1;
|
*i += 1;
|
||||||
}
|
}
|
||||||
let i = @mutable 0;
|
let i = @mut 0;
|
||||||
{
|
{
|
||||||
let x = r(i);
|
let x = r(i);
|
||||||
let opt = some(x);
|
let opt = some(x);
|
||||||
|
|
|
@ -61,7 +61,7 @@ fn as_c_charp<T>(s: str, f: fn(*c_char) -> T) -> T {
|
||||||
str::as_c_str(s) {|b| f(b as *c_char) }
|
str::as_c_str(s) {|b| f(b as *c_char) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_charp_buf(f: fn(*mutable c_char, size_t) -> bool)
|
fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
|
||||||
-> option<str> {
|
-> option<str> {
|
||||||
let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
|
let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
|
||||||
vec::as_mut_buf(buf) { |b|
|
vec::as_mut_buf(buf) { |b|
|
||||||
|
@ -77,7 +77,7 @@ fn fill_charp_buf(f: fn(*mutable c_char, size_t) -> bool)
|
||||||
mod win32 {
|
mod win32 {
|
||||||
import dword = libc::types::os::arch::extra::DWORD;
|
import dword = libc::types::os::arch::extra::DWORD;
|
||||||
|
|
||||||
fn fill_utf16_buf_and_decode(f: fn(*mutable u16, dword) -> dword)
|
fn fill_utf16_buf_and_decode(f: fn(*mut u16, dword) -> dword)
|
||||||
-> option<str> {
|
-> option<str> {
|
||||||
|
|
||||||
// FIXME: remove these when export globs work properly.
|
// FIXME: remove these when export globs work properly.
|
||||||
|
@ -241,8 +241,8 @@ fn waitpid(pid: pid_t) -> c_int {
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn pipe() -> {in: c_int, out: c_int} {
|
fn pipe() -> {in: c_int, out: c_int} {
|
||||||
let fds = {mutable in: 0 as c_int,
|
let fds = {mut in: 0 as c_int,
|
||||||
mutable out: 0 as c_int };
|
mut out: 0 as c_int };
|
||||||
assert (libc::pipe(ptr::mut_addr_of(fds.in)) == (0 as c_int));
|
assert (libc::pipe(ptr::mut_addr_of(fds.in)) == (0 as c_int));
|
||||||
ret {in: fds.in, out: fds.out};
|
ret {in: fds.in, out: fds.out};
|
||||||
}
|
}
|
||||||
|
@ -258,8 +258,8 @@ fn pipe() -> {in: c_int, out: c_int} {
|
||||||
// understand. Here we explicitly make the pipe non-inheritable, which
|
// understand. Here we explicitly make the pipe non-inheritable, which
|
||||||
// means to pass it to a subprocess they need to be duplicated first, as
|
// means to pass it to a subprocess they need to be duplicated first, as
|
||||||
// in rust_run_program.
|
// in rust_run_program.
|
||||||
let fds = { mutable in: 0 as c_int,
|
let fds = { mut in: 0 as c_int,
|
||||||
mutable out: 0 as c_int };
|
mut out: 0 as c_int };
|
||||||
let res = libc::pipe(ptr::mut_addr_of(fds.in),
|
let res = libc::pipe(ptr::mut_addr_of(fds.in),
|
||||||
1024 as c_uint,
|
1024 as c_uint,
|
||||||
(O_BINARY | O_NOINHERIT) as c_int);
|
(O_BINARY | O_NOINHERIT) as c_int);
|
||||||
|
@ -294,7 +294,7 @@ fn self_exe_path() -> option<path> {
|
||||||
KERN_PROC as c_int,
|
KERN_PROC as c_int,
|
||||||
KERN_PROC_PATHNAME as c_int, -1 as c_int];
|
KERN_PROC_PATHNAME as c_int, -1 as c_int];
|
||||||
sysctl(vec::unsafe::to_ptr(mib), vec::len(mib) as c_uint,
|
sysctl(vec::unsafe::to_ptr(mib), vec::len(mib) as c_uint,
|
||||||
buf as *mutable c_void, ptr::mut_addr_of(sz),
|
buf as *mut c_void, ptr::mut_addr_of(sz),
|
||||||
ptr::null(), 0u as size_t) == (0 as c_int)
|
ptr::null(), 0u as size_t) == (0 as c_int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ native mod rusti {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn addr_of<T>(val: T) -> *T { rusti::addr_of(val) }
|
fn addr_of<T>(val: T) -> *T { rusti::addr_of(val) }
|
||||||
|
|
||||||
#[doc = "Get an unsafe mutable pointer to a value"]
|
#[doc = "Get an unsafe mut pointer to a value"]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mut_addr_of<T>(val: T) -> *mutable T unsafe {
|
fn mut_addr_of<T>(val: T) -> *mut T unsafe {
|
||||||
unsafe::reinterpret_cast(rusti::addr_of(val))
|
unsafe::reinterpret_cast(rusti::addr_of(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@ fn offset<T>(ptr: *T, count: uint) -> *T unsafe {
|
||||||
(ptr as uint + count * sys::size_of::<T>()) as *T
|
(ptr as uint + count * sys::size_of::<T>()) as *T
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Calculate the offset from a mutable pointer"]
|
#[doc = "Calculate the offset from a mut pointer"]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mut_offset<T>(ptr: *mutable T, count: uint) -> *mutable T {
|
fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
|
||||||
(ptr as uint + count * sys::size_of::<T>()) as *mutable T
|
(ptr as uint + count * sys::size_of::<T>()) as *mut T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,16 +77,16 @@ unsafe fn memmove<T>(dst: *T, src: *T, count: uint) {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() unsafe {
|
fn test() unsafe {
|
||||||
type pair = {mutable fst: int, mutable snd: int};
|
type pair = {mut fst: int, mut snd: int};
|
||||||
let p = {mutable fst: 10, mutable snd: 20};
|
let p = {mut fst: 10, mut snd: 20};
|
||||||
let pptr: *mutable pair = mut_addr_of(p);
|
let pptr: *mut pair = mut_addr_of(p);
|
||||||
let iptr: *mutable int = unsafe::reinterpret_cast(pptr);
|
let iptr: *mut int = unsafe::reinterpret_cast(pptr);
|
||||||
assert (*iptr == 10);;
|
assert (*iptr == 10);;
|
||||||
*iptr = 30;
|
*iptr = 30;
|
||||||
assert (*iptr == 30);
|
assert (*iptr == 30);
|
||||||
assert (p.fst == 30);;
|
assert (p.fst == 30);;
|
||||||
|
|
||||||
*pptr = {mutable fst: 50, mutable snd: 60};
|
*pptr = {mut fst: 50, mut snd: 60};
|
||||||
assert (*iptr == 50);
|
assert (*iptr == 50);
|
||||||
assert (p.fst == 50);
|
assert (p.fst == 50);
|
||||||
assert (p.snd == 60);
|
assert (p.snd == 60);
|
||||||
|
|
|
@ -198,10 +198,10 @@ fn start_program(prog: str, args: [str]) -> program {
|
||||||
libc::close(pipe_err.out);
|
libc::close(pipe_err.out);
|
||||||
|
|
||||||
type prog_repr = {pid: pid_t,
|
type prog_repr = {pid: pid_t,
|
||||||
mutable in_fd: c_int,
|
mut in_fd: c_int,
|
||||||
out_file: *libc::FILE,
|
out_file: *libc::FILE,
|
||||||
err_file: *libc::FILE,
|
err_file: *libc::FILE,
|
||||||
mutable finished: bool};
|
mut finished: bool};
|
||||||
|
|
||||||
fn close_repr_input(r: prog_repr) {
|
fn close_repr_input(r: prog_repr) {
|
||||||
let invalid_fd = -1i32;
|
let invalid_fd = -1i32;
|
||||||
|
@ -233,10 +233,10 @@ fn start_program(prog: str, args: [str]) -> program {
|
||||||
fn destroy() { destroy_repr(*self); }
|
fn destroy() { destroy_repr(*self); }
|
||||||
}
|
}
|
||||||
let repr = {pid: pid,
|
let repr = {pid: pid,
|
||||||
mutable in_fd: pipe_input.out,
|
mut in_fd: pipe_input.out,
|
||||||
out_file: os::fdopen(pipe_output.in),
|
out_file: os::fdopen(pipe_output.in),
|
||||||
err_file: os::fdopen(pipe_err.in),
|
err_file: os::fdopen(pipe_err.in),
|
||||||
mutable finished: false};
|
mut finished: false};
|
||||||
ret prog_res(repr) as program;
|
ret prog_res(repr) as program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,8 @@ Provides detailed control over the properties and behavior of new tasks.
|
||||||
// the run function move them in.
|
// the run function move them in.
|
||||||
enum task_builder {
|
enum task_builder {
|
||||||
task_builder_({
|
task_builder_({
|
||||||
mutable opts: task_opts,
|
mut opts: task_opts,
|
||||||
mutable gen_body: fn@(+fn~()) -> fn~(),
|
mut gen_body: fn@(+fn~()) -> fn~(),
|
||||||
can_not_copy: option<comm::port<()>>
|
can_not_copy: option<comm::port<()>>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,8 @@ fn task_builder() -> task_builder {
|
||||||
let body_identity = fn@(+body: fn~()) -> fn~() { body };
|
let body_identity = fn@(+body: fn~()) -> fn~() { body };
|
||||||
|
|
||||||
task_builder_({
|
task_builder_({
|
||||||
mutable opts: default_task_opts(),
|
mut opts: default_task_opts(),
|
||||||
mutable gen_body: body_identity,
|
mut gen_body: body_identity,
|
||||||
can_not_copy: none
|
can_not_copy: none
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,15 +150,15 @@ fn from_elem<T: copy>(n_elts: uint, t: T) -> [T] {
|
||||||
ret v;
|
ret v;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Produces a mutable vector from an immutable vector."]
|
#[doc = "Produces a mut vector from an immutable vector."]
|
||||||
fn to_mut<T>(+v: [T]) -> [mutable T] unsafe {
|
fn to_mut<T>(+v: [T]) -> [mut T] unsafe {
|
||||||
let r = ::unsafe::reinterpret_cast(v);
|
let r = ::unsafe::reinterpret_cast(v);
|
||||||
::unsafe::forget(v);
|
::unsafe::forget(v);
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Produces an immutable vector from a mutable vector."]
|
#[doc = "Produces an immutable vector from a mut vector."]
|
||||||
fn from_mut<T>(+v: [mutable T]) -> [T] unsafe {
|
fn from_mut<T>(+v: [mut T]) -> [T] unsafe {
|
||||||
let r = ::unsafe::reinterpret_cast(v);
|
let r = ::unsafe::reinterpret_cast(v);
|
||||||
::unsafe::forget(v);
|
::unsafe::forget(v);
|
||||||
r
|
r
|
||||||
|
@ -396,7 +396,7 @@ Sets the element at position `index` to `val`. If `index` is past the end
|
||||||
of the vector, expands the vector by replicating `initval` to fill the
|
of the vector, expands the vector by replicating `initval` to fill the
|
||||||
intervening space.
|
intervening space.
|
||||||
"]
|
"]
|
||||||
fn grow_set<T: copy>(&v: [mutable T], index: uint, initval: T, val: T) {
|
fn grow_set<T: copy>(&v: [mut T], index: uint, initval: T, val: T) {
|
||||||
if index >= len(v) { grow(v, index - len(v) + 1u, initval); }
|
if index >= len(v) { grow(v, index - len(v) + 1u, initval); }
|
||||||
v[index] = val;
|
v[index] = val;
|
||||||
}
|
}
|
||||||
|
@ -729,12 +729,12 @@ Swaps two elements in a vector
|
||||||
* a - The index of the first element
|
* a - The index of the first element
|
||||||
* b - The index of the second element
|
* b - The index of the second element
|
||||||
"]
|
"]
|
||||||
fn swap<T>(v: [mutable T], a: uint, b: uint) {
|
fn swap<T>(v: [mut T], a: uint, b: uint) {
|
||||||
v[a] <-> v[b];
|
v[a] <-> v[b];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Reverse the order of elements in a vector, in place"]
|
#[doc = "Reverse the order of elements in a vector, in place"]
|
||||||
fn reverse<T>(v: [mutable T]) {
|
fn reverse<T>(v: [mut T]) {
|
||||||
let mut i: uint = 0u;
|
let mut i: uint = 0u;
|
||||||
let ln = len::<T>(v);
|
let ln = len::<T>(v);
|
||||||
while i < ln / 2u { v[i] <-> v[ln - i - 1u]; i += 1u; }
|
while i < ln / 2u { v[i] <-> v[ln - i - 1u]; i += 1u; }
|
||||||
|
@ -890,8 +890,8 @@ fn as_buf<E,T>(v: [const E], f: fn(*E) -> T) -> T unsafe {
|
||||||
let buf = unsafe::to_ptr(v); f(buf)
|
let buf = unsafe::to_ptr(v); f(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_mut_buf<E,T>(v: [mutable E], f: fn(*mutable E) -> T) -> T unsafe {
|
fn as_mut_buf<E,T>(v: [mut E], f: fn(*mut E) -> T) -> T unsafe {
|
||||||
let buf = unsafe::to_ptr(v) as *mutable E; f(buf)
|
let buf = unsafe::to_ptr(v) as *mut E; f(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "An extension implementation providing a `len` method"]
|
#[doc = "An extension implementation providing a `len` method"]
|
||||||
|
@ -905,7 +905,7 @@ impl vec_len<T> for [const T] {
|
||||||
mod unsafe {
|
mod unsafe {
|
||||||
// FIXME: This should have crate visibility
|
// FIXME: This should have crate visibility
|
||||||
#[doc = "The internal representation of a vector"]
|
#[doc = "The internal representation of a vector"]
|
||||||
type vec_repr = {mutable fill: uint, mutable alloc: uint, data: u8};
|
type vec_repr = {mut fill: uint, mut alloc: uint, data: u8};
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
Constructs a vector from an unsafe pointer to a buffer
|
Constructs a vector from an unsafe pointer to a buffer
|
||||||
|
@ -1212,7 +1212,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_grow_set() {
|
fn test_grow_set() {
|
||||||
let mut v = [mutable 1, 2, 3];
|
let mut v = [mut 1, 2, 3];
|
||||||
grow_set(v, 4u, 4, 5);
|
grow_set(v, 4u, 4, 5);
|
||||||
assert (len(v) == 5u);
|
assert (len(v) == 5u);
|
||||||
assert (v[0] == 1);
|
assert (v[0] == 1);
|
||||||
|
@ -1619,7 +1619,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reverse_and_reversed() {
|
fn reverse_and_reversed() {
|
||||||
let v: [mutable int] = [mutable 10, 20];
|
let v: [mut int] = [mut 10, 20];
|
||||||
assert (v[0] == 10);
|
assert (v[0] == 10);
|
||||||
assert (v[1] == 20);
|
assert (v[1] == 20);
|
||||||
reverse(v);
|
reverse(v);
|
||||||
|
@ -1634,13 +1634,13 @@ mod tests {
|
||||||
|
|
||||||
let v4 = reversed::<int>([]);
|
let v4 = reversed::<int>([]);
|
||||||
assert (v4 == []);
|
assert (v4 == []);
|
||||||
let v3: [mutable int] = [mutable];
|
let v3: [mut int] = [mut];
|
||||||
reverse::<int>(v3);
|
reverse::<int>(v3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reversed_mut() {
|
fn reversed_mut() {
|
||||||
let v2 = reversed::<int>([mutable 10, 20]);
|
let v2 = reversed::<int>([mut 10, 20]);
|
||||||
assert (v2[0] == 20);
|
assert (v2[0] == 20);
|
||||||
assert (v2[1] == 10);
|
assert (v2[1] == 10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export eq_vec;
|
||||||
// for the case where nbits <= 32.
|
// for the case where nbits <= 32.
|
||||||
|
|
||||||
#[doc = "The bitvector type"]
|
#[doc = "The bitvector type"]
|
||||||
type bitv = @{storage: [mutable uint], nbits: uint};
|
type bitv = @{storage: [mut uint], nbits: uint};
|
||||||
|
|
||||||
const uint_bits: uint = 32u + (1u << 32u >> 27u);
|
const uint_bits: uint = 32u + (1u << 32u >> 27u);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Library to interface with chunks of memory allocated in C.
|
||||||
It is often desirable to safely interface with memory allocated from C,
|
It is often desirable to safely interface with memory allocated from C,
|
||||||
encapsulating the unsafety into allocation and destruction time. Indeed,
|
encapsulating the unsafety into allocation and destruction time. Indeed,
|
||||||
allocating memory externally is currently the only way to give Rust shared
|
allocating memory externally is currently the only way to give Rust shared
|
||||||
mutable state with C programs that keep their own references; vectors are
|
mut state with C programs that keep their own references; vectors are
|
||||||
unsuitable because they could be reallocated or moved at any time, and
|
unsuitable because they could be reallocated or moved at any time, and
|
||||||
importing C memory into a vector takes a one-time snapshot of the memory.
|
importing C memory into a vector takes a one-time snapshot of the memory.
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ Wrapped in a enum for opacity; FIXME #818 when it is possible to have
|
||||||
truly opaque types, this should be revisited.
|
truly opaque types, this should be revisited.
|
||||||
"]
|
"]
|
||||||
enum c_vec<T> {
|
enum c_vec<T> {
|
||||||
c_vec_({ base: *mutable T, len: uint, rsrc: @dtor_res})
|
c_vec_({ base: *mut T, len: uint, rsrc: @dtor_res})
|
||||||
}
|
}
|
||||||
|
|
||||||
resource dtor_res(dtor: option<fn@()>) {
|
resource dtor_res(dtor: option<fn@()>) {
|
||||||
|
@ -60,7 +60,7 @@ Create a `c_vec` from a native buffer with a given length.
|
||||||
* base - A native pointer to a buffer
|
* base - A native pointer to a buffer
|
||||||
* len - The number of elements in the buffer
|
* len - The number of elements in the buffer
|
||||||
"]
|
"]
|
||||||
unsafe fn c_vec<T>(base: *mutable T, len: uint) -> c_vec<T> {
|
unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> {
|
||||||
ret c_vec_({
|
ret c_vec_({
|
||||||
base: base,
|
base: base,
|
||||||
len: len,
|
len: len,
|
||||||
|
@ -79,7 +79,7 @@ and a function to run upon destruction.
|
||||||
* dtor - A function to run when the value is destructed, useful
|
* dtor - A function to run when the value is destructed, useful
|
||||||
for freeing the buffer, etc.
|
for freeing the buffer, etc.
|
||||||
"]
|
"]
|
||||||
unsafe fn c_vec_with_dtor<T>(base: *mutable T, len: uint, dtor: fn@())
|
unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@())
|
||||||
-> c_vec<T> {
|
-> c_vec<T> {
|
||||||
ret c_vec_({
|
ret c_vec_({
|
||||||
base: base,
|
base: base,
|
||||||
|
@ -122,7 +122,7 @@ fn len<T>(t: c_vec<T>) -> uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Returns a pointer to the first element of the vector"]
|
#[doc = "Returns a pointer to the first element of the vector"]
|
||||||
unsafe fn ptr<T>(t: c_vec<T>) -> *mutable T {
|
unsafe fn ptr<T>(t: c_vec<T>) -> *mut T {
|
||||||
ret (*t).base;
|
ret (*t).base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ mod tests {
|
||||||
|
|
||||||
assert mem as int != 0;
|
assert mem as int != 0;
|
||||||
|
|
||||||
ret unsafe { c_vec_with_dtor(mem as *mutable u8, n,
|
ret unsafe { c_vec_with_dtor(mem as *mut u8, n,
|
||||||
bind free(mem)) };
|
bind free(mem)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,30 +23,30 @@ fn create<T: copy>() -> t<T> {
|
||||||
* Grow is only called on full elts, so nelts is also len(elts), unlike
|
* Grow is only called on full elts, so nelts is also len(elts), unlike
|
||||||
* elsewhere.
|
* elsewhere.
|
||||||
*/
|
*/
|
||||||
fn grow<T: copy>(nelts: uint, lo: uint, elts: [mutable cell<T>]) ->
|
fn grow<T: copy>(nelts: uint, lo: uint, elts: [mut cell<T>]) ->
|
||||||
[mutable cell<T>] {
|
[mut cell<T>] {
|
||||||
assert (nelts == vec::len(elts));
|
assert (nelts == vec::len(elts));
|
||||||
let mut rv = [mutable];
|
let mut rv = [mut];
|
||||||
|
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
let nalloc = uint::next_power_of_two(nelts + 1u);
|
let nalloc = uint::next_power_of_two(nelts + 1u);
|
||||||
while i < nalloc {
|
while i < nalloc {
|
||||||
if i < nelts {
|
if i < nelts {
|
||||||
rv += [mutable elts[(lo + i) % nelts]];
|
rv += [mut elts[(lo + i) % nelts]];
|
||||||
} else { rv += [mutable none]; }
|
} else { rv += [mut none]; }
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret rv;
|
ret rv;
|
||||||
}
|
}
|
||||||
fn get<T: copy>(elts: [mutable cell<T>], i: uint) -> T {
|
fn get<T: copy>(elts: [mut cell<T>], i: uint) -> T {
|
||||||
ret alt elts[i] { some(t) { t } _ { fail } };
|
ret alt elts[i] { some(t) { t } _ { fail } };
|
||||||
}
|
}
|
||||||
|
|
||||||
type repr<T> = {mutable nelts: uint,
|
type repr<T> = {mut nelts: uint,
|
||||||
mutable lo: uint,
|
mut lo: uint,
|
||||||
mutable hi: uint,
|
mut hi: uint,
|
||||||
mutable elts: [mutable cell<T>]};
|
mut elts: [mut cell<T>]};
|
||||||
|
|
||||||
impl <T: copy> of t<T> for repr<T> {
|
impl <T: copy> of t<T> for repr<T> {
|
||||||
fn size() -> uint { ret self.nelts; }
|
fn size() -> uint { ret self.nelts; }
|
||||||
|
@ -102,10 +102,10 @@ fn create<T: copy>() -> t<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let repr: repr<T> = {
|
let repr: repr<T> = {
|
||||||
mutable nelts: 0u,
|
mut nelts: 0u,
|
||||||
mutable lo: 0u,
|
mut lo: 0u,
|
||||||
mutable hi: 0u,
|
mut hi: 0u,
|
||||||
mutable elts: vec::to_mut(vec::from_elem(initial_capacity, none))
|
mut elts: vec::to_mut(vec::from_elem(initial_capacity, none))
|
||||||
};
|
};
|
||||||
repr as t::<T>
|
repr as t::<T>
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ fn doc_as_i32(d: doc) -> i32 { doc_as_u32(d) as i32 }
|
||||||
fn doc_as_i64(d: doc) -> i64 { doc_as_u64(d) as i64 }
|
fn doc_as_i64(d: doc) -> i64 { doc_as_u64(d) as i64 }
|
||||||
|
|
||||||
// ebml writing
|
// ebml writing
|
||||||
type writer = {writer: io::writer, mutable size_positions: [uint]};
|
type writer = {writer: io::writer, mut size_positions: [uint]};
|
||||||
|
|
||||||
fn write_sized_vuint(w: io::writer, n: uint, size: uint) {
|
fn write_sized_vuint(w: io::writer, n: uint, size: uint) {
|
||||||
let buf: [u8] = alt size {
|
let buf: [u8] = alt size {
|
||||||
|
@ -178,7 +178,7 @@ fn write_vuint(w: io::writer, n: uint) {
|
||||||
|
|
||||||
fn writer(w: io::writer) -> writer {
|
fn writer(w: io::writer) -> writer {
|
||||||
let size_positions: [uint] = [];
|
let size_positions: [uint] = [];
|
||||||
ret {writer: w, mutable size_positions: size_positions};
|
ret {writer: w, mut size_positions: size_positions};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Provide a function to write the standard ebml header.
|
// TODO: Provide a function to write the standard ebml header.
|
||||||
|
@ -361,11 +361,11 @@ impl serializer of serialization::serializer for ebml::writer {
|
||||||
fn emit_tup_elt(_idx: uint, f: fn()) { f() }
|
fn emit_tup_elt(_idx: uint, f: fn()) { f() }
|
||||||
}
|
}
|
||||||
|
|
||||||
type ebml_deserializer = {mutable parent: ebml::doc,
|
type ebml_deserializer = {mut parent: ebml::doc,
|
||||||
mutable pos: uint};
|
mut pos: uint};
|
||||||
|
|
||||||
fn ebml_deserializer(d: ebml::doc) -> ebml_deserializer {
|
fn ebml_deserializer(d: ebml::doc) -> ebml_deserializer {
|
||||||
{mutable parent: d, mutable pos: d.start}
|
{mut parent: d, mut pos: d.start}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl deserializer of serialization::deserializer for ebml_deserializer {
|
impl deserializer of serialization::deserializer for ebml_deserializer {
|
||||||
|
|
|
@ -114,7 +114,7 @@ enum optval { val(str), given, }
|
||||||
The result of checking command line arguments. Contains a vector
|
The result of checking command line arguments. Contains a vector
|
||||||
of matches and a vector of free strings.
|
of matches and a vector of free strings.
|
||||||
"]
|
"]
|
||||||
type match = {opts: [opt], vals: [mutable [optval]], free: [str]};
|
type match = {opts: [opt], vals: [mut [optval]], free: [str]};
|
||||||
|
|
||||||
fn is_arg(arg: str) -> bool {
|
fn is_arg(arg: str) -> bool {
|
||||||
ret str::len(arg) > 1u && arg[0] == '-' as u8;
|
ret str::len(arg) > 1u && arg[0] == '-' as u8;
|
||||||
|
|
|
@ -109,9 +109,9 @@ fn to_str(j: json) -> str {
|
||||||
|
|
||||||
type parser = {
|
type parser = {
|
||||||
rdr: io::reader,
|
rdr: io::reader,
|
||||||
mutable ch: char,
|
mut ch: char,
|
||||||
mutable line: uint,
|
mut line: uint,
|
||||||
mutable col: uint,
|
mut col: uint,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl parser for parser {
|
impl parser for parser {
|
||||||
|
@ -458,9 +458,9 @@ impl parser for parser {
|
||||||
fn from_reader(rdr: io::reader) -> result<json, error> {
|
fn from_reader(rdr: io::reader) -> result<json, error> {
|
||||||
let parser = {
|
let parser = {
|
||||||
rdr: rdr,
|
rdr: rdr,
|
||||||
mutable ch: rdr.read_char(),
|
mut ch: rdr.read_char(),
|
||||||
mutable line: 1u,
|
mut line: 1u,
|
||||||
mutable col: 1u,
|
mut col: 1u,
|
||||||
};
|
};
|
||||||
|
|
||||||
parser.parse()
|
parser.parse()
|
||||||
|
|
|
@ -164,7 +164,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_vec_mut() {
|
fn test_from_vec_mut() {
|
||||||
let l = from_vec([mutable 0, 1, 2]);
|
let l = from_vec([mut 0, 1, 2]);
|
||||||
|
|
||||||
assert (head(l) == 0);
|
assert (head(l) == 0);
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ mod chained {
|
||||||
type entry<K, V> = {
|
type entry<K, V> = {
|
||||||
hash: uint,
|
hash: uint,
|
||||||
key: K,
|
key: K,
|
||||||
mutable value: V,
|
mut value: V,
|
||||||
mutable next: chain<K, V>
|
mut next: chain<K, V>
|
||||||
};
|
};
|
||||||
|
|
||||||
enum chain<K, V> {
|
enum chain<K, V> {
|
||||||
|
@ -81,8 +81,8 @@ mod chained {
|
||||||
}
|
}
|
||||||
|
|
||||||
type t<K, V> = @{
|
type t<K, V> = @{
|
||||||
mutable count: uint,
|
mut count: uint,
|
||||||
mutable chains: [mutable chain<K,V>],
|
mut chains: [mut chain<K,V>],
|
||||||
hasher: hashfn<K>,
|
hasher: hashfn<K>,
|
||||||
eqer: eqfn<K>
|
eqer: eqfn<K>
|
||||||
};
|
};
|
||||||
|
@ -152,8 +152,8 @@ mod chained {
|
||||||
tbl.chains[idx] = present(@{
|
tbl.chains[idx] = present(@{
|
||||||
hash: hash,
|
hash: hash,
|
||||||
key: k,
|
key: k,
|
||||||
mutable value: v,
|
mut value: v,
|
||||||
mutable next: old_chain});
|
mut next: old_chain});
|
||||||
ret true;
|
ret true;
|
||||||
}
|
}
|
||||||
found_first(_, entry) {
|
found_first(_, entry) {
|
||||||
|
@ -203,7 +203,7 @@ mod chained {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn chains<K: copy, V: copy>(nchains: uint) -> [mutable chain<K,V>] {
|
fn chains<K: copy, V: copy>(nchains: uint) -> [mut chain<K,V>] {
|
||||||
ret vec::to_mut(vec::from_elem(nchains, absent));
|
ret vec::to_mut(vec::from_elem(nchains, absent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,8 +286,8 @@ mod chained {
|
||||||
|
|
||||||
fn mk<K: copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) -> t<K,V> {
|
fn mk<K: copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) -> t<K,V> {
|
||||||
let initial_capacity: uint = 32u; // 2^5
|
let initial_capacity: uint = 32u; // 2^5
|
||||||
let slf: t<K, V> = @{mutable count: 0u,
|
let slf: t<K, V> = @{mut count: 0u,
|
||||||
mutable chains: chains(initial_capacity),
|
mut chains: chains(initial_capacity),
|
||||||
hasher: hasher,
|
hasher: hasher,
|
||||||
eqer: eqer};
|
eqer: eqer};
|
||||||
slf
|
slf
|
||||||
|
|
|
@ -154,7 +154,7 @@ rope remains balanced. However, this function does not take any further
|
||||||
measure to ensure that the result is balanced.
|
measure to ensure that the result is balanced.
|
||||||
"]
|
"]
|
||||||
fn concat(v: [rope]) -> rope {
|
fn concat(v: [rope]) -> rope {
|
||||||
//Copy `v` into a mutable vector
|
//Copy `v` into a mut vector
|
||||||
let mut len = vec::len(v);
|
let mut len = vec::len(v);
|
||||||
if len == 0u { ret node::empty; }
|
if len == 0u { ret node::empty; }
|
||||||
let ropes = vec::to_mut(vec::from_elem(len, v[0]));
|
let ropes = vec::to_mut(vec::from_elem(len, v[0]));
|
||||||
|
@ -752,7 +752,7 @@ mod node {
|
||||||
* forest - The forest. This vector is progressively rewritten during
|
* forest - The forest. This vector is progressively rewritten during
|
||||||
execution and should be discarded as meaningless afterwards.
|
execution and should be discarded as meaningless afterwards.
|
||||||
"]
|
"]
|
||||||
fn tree_from_forest_destructive(forest: [mutable @node]) -> @node {
|
fn tree_from_forest_destructive(forest: [mut @node]) -> @node {
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
let mut len = vec::len(forest);
|
let mut len = vec::len(forest);
|
||||||
while len > 1u {
|
while len > 1u {
|
||||||
|
@ -861,12 +861,12 @@ mod node {
|
||||||
fn bal(node: @node) -> option<@node> {
|
fn bal(node: @node) -> option<@node> {
|
||||||
if height(node) < hint_max_node_height { ret option::none; }
|
if height(node) < hint_max_node_height { ret option::none; }
|
||||||
//1. Gather all leaves as a forest
|
//1. Gather all leaves as a forest
|
||||||
let mut forest = [mutable];
|
let mut forest = [mut];
|
||||||
let it = leaf_iterator::start(node);
|
let it = leaf_iterator::start(node);
|
||||||
loop {
|
loop {
|
||||||
alt (leaf_iterator::next(it)) {
|
alt (leaf_iterator::next(it)) {
|
||||||
option::none { break; }
|
option::none { break; }
|
||||||
option::some(x) { forest += [mutable @leaf(x)]; }
|
option::some(x) { forest += [mut @leaf(x)]; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//2. Rebuild tree from forest
|
//2. Rebuild tree from forest
|
||||||
|
@ -1117,20 +1117,20 @@ mod node {
|
||||||
|
|
||||||
mod leaf_iterator {
|
mod leaf_iterator {
|
||||||
type t = {
|
type t = {
|
||||||
stack: [mutable @node],
|
stack: [mut @node],
|
||||||
mutable stackpos: int
|
mut stackpos: int
|
||||||
};
|
};
|
||||||
|
|
||||||
fn empty() -> t {
|
fn empty() -> t {
|
||||||
let stack : [mutable @node] = [mutable];
|
let stack : [mut @node] = [mut];
|
||||||
ret {stack: stack, mutable stackpos: -1}
|
ret {stack: stack, mut stackpos: -1}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(node: @node) -> t {
|
fn start(node: @node) -> t {
|
||||||
let stack = vec::to_mut(vec::from_elem(height(node)+1u, node));
|
let stack = vec::to_mut(vec::from_elem(height(node)+1u, node));
|
||||||
ret {
|
ret {
|
||||||
stack: stack,
|
stack: stack,
|
||||||
mutable stackpos: 0
|
mut stackpos: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,23 +1157,23 @@ mod node {
|
||||||
mod char_iterator {
|
mod char_iterator {
|
||||||
type t = {
|
type t = {
|
||||||
leaf_iterator: leaf_iterator::t,
|
leaf_iterator: leaf_iterator::t,
|
||||||
mutable leaf: option<leaf>,
|
mut leaf: option<leaf>,
|
||||||
mutable leaf_byte_pos: uint
|
mut leaf_byte_pos: uint
|
||||||
};
|
};
|
||||||
|
|
||||||
fn start(node: @node) -> t {
|
fn start(node: @node) -> t {
|
||||||
ret {
|
ret {
|
||||||
leaf_iterator: leaf_iterator::start(node),
|
leaf_iterator: leaf_iterator::start(node),
|
||||||
mutable leaf: option::none,
|
mut leaf: option::none,
|
||||||
mutable leaf_byte_pos: 0u
|
mut leaf_byte_pos: 0u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn empty() -> t {
|
fn empty() -> t {
|
||||||
ret {
|
ret {
|
||||||
leaf_iterator: leaf_iterator::empty(),
|
leaf_iterator: leaf_iterator::empty(),
|
||||||
mutable leaf: option::none,
|
mut leaf: option::none,
|
||||||
mutable leaf_byte_pos: 0u
|
mut leaf_byte_pos: 0u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,8 +1242,8 @@ mod tests {
|
||||||
alt(r) {
|
alt(r) {
|
||||||
node::empty { ret "" }
|
node::empty { ret "" }
|
||||||
node::content(x) {
|
node::content(x) {
|
||||||
let str = @mutable "";
|
let str = @mut "";
|
||||||
fn aux(str: @mutable str, node: @node::node) unsafe {
|
fn aux(str: @mut str, node: @node::node) unsafe {
|
||||||
alt(*node) {
|
alt(*node) {
|
||||||
node::leaf(x) {
|
node::leaf(x) {
|
||||||
*str += str::slice(
|
*str += str::slice(
|
||||||
|
@ -1280,7 +1280,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn of_string2() {
|
fn of_string2() {
|
||||||
let buf = @ mutable "1234567890";
|
let buf = @ mut "1234567890";
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < 10 { *buf = *buf + *buf; i+=1;}
|
while i < 10 { *buf = *buf + *buf; i+=1;}
|
||||||
let sample = @*buf;
|
let sample = @*buf;
|
||||||
|
@ -1313,7 +1313,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn iter1() {
|
fn iter1() {
|
||||||
let buf = @ mutable "1234567890";
|
let buf = @ mut "1234567890";
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < 10 { *buf = *buf + *buf; i+=1;}
|
while i < 10 { *buf = *buf + *buf; i+=1;}
|
||||||
let sample = @*buf;
|
let sample = @*buf;
|
||||||
|
@ -1334,7 +1334,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn bal1() {
|
fn bal1() {
|
||||||
let init = @ "1234567890";
|
let init = @ "1234567890";
|
||||||
let buf = @ mutable * init;
|
let buf = @ mut * init;
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < 8 { *buf = *buf + *buf; i+=1;}
|
while i < 8 { *buf = *buf + *buf; i+=1;}
|
||||||
let sample = @*buf;
|
let sample = @*buf;
|
||||||
|
|
|
@ -52,13 +52,13 @@ const k3: u32 = 0xCA62C1D6u32;
|
||||||
#[doc = "Construct a `sha` object"]
|
#[doc = "Construct a `sha` object"]
|
||||||
fn sha1() -> sha1 {
|
fn sha1() -> sha1 {
|
||||||
type sha1state =
|
type sha1state =
|
||||||
{h: [mutable u32],
|
{h: [mut u32],
|
||||||
mutable len_low: u32,
|
mut len_low: u32,
|
||||||
mutable len_high: u32,
|
mut len_high: u32,
|
||||||
msg_block: [mutable u8],
|
msg_block: [mut u8],
|
||||||
mutable msg_block_idx: uint,
|
mut msg_block_idx: uint,
|
||||||
mutable computed: bool,
|
mut computed: bool,
|
||||||
work_buf: [mutable u32]};
|
work_buf: [mut u32]};
|
||||||
|
|
||||||
fn add_input(st: sha1state, msg: [u8]) {
|
fn add_input(st: sha1state, msg: [u8]) {
|
||||||
// FIXME: Should be typestate precondition
|
// FIXME: Should be typestate precondition
|
||||||
|
@ -244,11 +244,11 @@ fn sha1() -> sha1 {
|
||||||
}
|
}
|
||||||
let st = {
|
let st = {
|
||||||
h: vec::to_mut(vec::from_elem(digest_buf_len, 0u32)),
|
h: vec::to_mut(vec::from_elem(digest_buf_len, 0u32)),
|
||||||
mutable len_low: 0u32,
|
mut len_low: 0u32,
|
||||||
mutable len_high: 0u32,
|
mut len_high: 0u32,
|
||||||
msg_block: vec::to_mut(vec::from_elem(msg_block_len, 0u8)),
|
msg_block: vec::to_mut(vec::from_elem(msg_block_len, 0u8)),
|
||||||
mutable msg_block_idx: 0u,
|
mut msg_block_idx: 0u,
|
||||||
mutable computed: false,
|
mut computed: false,
|
||||||
work_buf: vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
work_buf: vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
||||||
};
|
};
|
||||||
let sh = st as sha1;
|
let sh = st as sha1;
|
||||||
|
|
|
@ -7,12 +7,12 @@ import core::option::{some, none};
|
||||||
|
|
||||||
// FIXME: Should not be @; there's a bug somewhere in rustc that requires this
|
// FIXME: Should not be @; there's a bug somewhere in rustc that requires this
|
||||||
// to be.
|
// to be.
|
||||||
type smallintmap<T: copy> = @{mutable v: [mutable option<T>]};
|
type smallintmap<T: copy> = @{mut v: [mut option<T>]};
|
||||||
|
|
||||||
#[doc = "Create a smallintmap"]
|
#[doc = "Create a smallintmap"]
|
||||||
fn mk<T: copy>() -> smallintmap<T> {
|
fn mk<T: copy>() -> smallintmap<T> {
|
||||||
let v: [mutable option<T>] = [mutable];
|
let v: [mut option<T>] = [mut];
|
||||||
ret @{mutable v: v};
|
ret @{mut v: v};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
|
|
|
@ -51,7 +51,7 @@ fn merge_sort<T: copy>(le: le<T>, v: [const T]) -> [T] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part<T: copy>(compare_func: le<T>, arr: [mutable T], left: uint,
|
fn part<T: copy>(compare_func: le<T>, arr: [mut T], left: uint,
|
||||||
right: uint, pivot: uint) -> uint {
|
right: uint, pivot: uint) -> uint {
|
||||||
let pivot_value = arr[pivot];
|
let pivot_value = arr[pivot];
|
||||||
arr[pivot] <-> arr[right];
|
arr[pivot] <-> arr[right];
|
||||||
|
@ -68,7 +68,7 @@ fn part<T: copy>(compare_func: le<T>, arr: [mutable T], left: uint,
|
||||||
ret storage_index;
|
ret storage_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn qsort<T: copy>(compare_func: le<T>, arr: [mutable T], left: uint,
|
fn qsort<T: copy>(compare_func: le<T>, arr: [mut T], left: uint,
|
||||||
right: uint) {
|
right: uint) {
|
||||||
if right > left {
|
if right > left {
|
||||||
let pivot = (left + right) / 2u;
|
let pivot = (left + right) / 2u;
|
||||||
|
@ -82,18 +82,18 @@ fn qsort<T: copy>(compare_func: le<T>, arr: [mutable T], left: uint,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
Quicksort. Sorts a mutable vector in place.
|
Quicksort. Sorts a mut vector in place.
|
||||||
|
|
||||||
Has worst case O(n^2) performance, average case O(n log n).
|
Has worst case O(n^2) performance, average case O(n log n).
|
||||||
This is an unstable sort.
|
This is an unstable sort.
|
||||||
"]
|
"]
|
||||||
fn quick_sort<T: copy>(compare_func: le<T>, arr: [mutable T]) {
|
fn quick_sort<T: copy>(compare_func: le<T>, arr: [mut T]) {
|
||||||
if len::<T>(arr) == 0u { ret; }
|
if len::<T>(arr) == 0u { ret; }
|
||||||
qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u);
|
qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
|
fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
|
||||||
arr: [mutable T], left: int, right: int) {
|
arr: [mut T], left: int, right: int) {
|
||||||
if right <= left { ret; }
|
if right <= left { ret; }
|
||||||
let v: T = arr[right];
|
let v: T = arr[right];
|
||||||
let mut i: int = left - 1;
|
let mut i: int = left - 1;
|
||||||
|
@ -142,7 +142,7 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
|
||||||
|
|
||||||
// FIXME: This should take lt and eq types
|
// FIXME: This should take lt and eq types
|
||||||
#[doc = "
|
#[doc = "
|
||||||
Fancy quicksort. Sorts a mutable vector in place.
|
Fancy quicksort. Sorts a mut vector in place.
|
||||||
|
|
||||||
Based on algorithm presented by [Sedgewick and Bentley]
|
Based on algorithm presented by [Sedgewick and Bentley]
|
||||||
(http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf).
|
(http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf).
|
||||||
|
@ -152,7 +152,7 @@ According to these slides this is the algorithm of choice for
|
||||||
This is an unstable sort.
|
This is an unstable sort.
|
||||||
"]
|
"]
|
||||||
fn quick_sort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
|
fn quick_sort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
|
||||||
arr: [mutable T]) {
|
arr: [mut T]) {
|
||||||
if len::<T>(arr) == 0u { ret; }
|
if len::<T>(arr) == 0u { ret; }
|
||||||
qsort3::<T>(compare_func_lt, compare_func_eq, arr, 0,
|
qsort3::<T>(compare_func_lt, compare_func_eq, arr, 0,
|
||||||
(len::<T>(arr) as int) - 1);
|
(len::<T>(arr) as int) - 1);
|
||||||
|
@ -160,7 +160,7 @@ fn quick_sort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_qsort3 {
|
mod test_qsort3 {
|
||||||
fn check_sort(v1: [mutable int], v2: [mutable int]) {
|
fn check_sort(v1: [mut int], v2: [mut int]) {
|
||||||
let len = vec::len::<int>(v1);
|
let len = vec::len::<int>(v1);
|
||||||
fn lt(&&a: int, &&b: int) -> bool { ret a < b; }
|
fn lt(&&a: int, &&b: int) -> bool { ret a < b; }
|
||||||
fn equal(&&a: int, &&b: int) -> bool { ret a == b; }
|
fn equal(&&a: int, &&b: int) -> bool { ret a == b; }
|
||||||
|
@ -178,24 +178,24 @@ mod test_qsort3 {
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
{
|
{
|
||||||
let v1 = [mutable 3, 7, 4, 5, 2, 9, 5, 8];
|
let v1 = [mut 3, 7, 4, 5, 2, 9, 5, 8];
|
||||||
let v2 = [mutable 2, 3, 4, 5, 5, 7, 8, 9];
|
let v2 = [mut 2, 3, 4, 5, 5, 7, 8, 9];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let v1 = [mutable 1, 1, 1];
|
let v1 = [mut 1, 1, 1];
|
||||||
let v2 = [mutable 1, 1, 1];
|
let v2 = [mut 1, 1, 1];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let v1: [mutable int] = [mutable];
|
let v1: [mut int] = [mut];
|
||||||
let v2: [mutable int] = [mutable];
|
let v2: [mut int] = [mut];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
{ let v1 = [mutable 9]; let v2 = [mutable 9]; check_sort(v1, v2); }
|
{ let v1 = [mut 9]; let v2 = [mut 9]; check_sort(v1, v2); }
|
||||||
{
|
{
|
||||||
let v1 = [mutable 9, 3, 3, 3, 9];
|
let v1 = [mut 9, 3, 3, 3, 9];
|
||||||
let v2 = [mutable 3, 3, 3, 9, 9];
|
let v2 = [mut 3, 3, 3, 9, 9];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ mod test_qsort3 {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_qsort {
|
mod test_qsort {
|
||||||
fn check_sort(v1: [mutable int], v2: [mutable int]) {
|
fn check_sort(v1: [mut int], v2: [mut int]) {
|
||||||
let len = vec::len::<int>(v1);
|
let len = vec::len::<int>(v1);
|
||||||
fn leual(&&a: int, &&b: int) -> bool { ret a <= b; }
|
fn leual(&&a: int, &&b: int) -> bool { ret a <= b; }
|
||||||
let f = leual;
|
let f = leual;
|
||||||
|
@ -219,24 +219,24 @@ mod test_qsort {
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
{
|
{
|
||||||
let v1 = [mutable 3, 7, 4, 5, 2, 9, 5, 8];
|
let v1 = [mut 3, 7, 4, 5, 2, 9, 5, 8];
|
||||||
let v2 = [mutable 2, 3, 4, 5, 5, 7, 8, 9];
|
let v2 = [mut 2, 3, 4, 5, 5, 7, 8, 9];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let v1 = [mutable 1, 1, 1];
|
let v1 = [mut 1, 1, 1];
|
||||||
let v2 = [mutable 1, 1, 1];
|
let v2 = [mut 1, 1, 1];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let v1: [mutable int] = [mutable];
|
let v1: [mut int] = [mut];
|
||||||
let v2: [mutable int] = [mutable];
|
let v2: [mut int] = [mut];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
{ let v1 = [mutable 9]; let v2 = [mutable 9]; check_sort(v1, v2); }
|
{ let v1 = [mut 9]; let v2 = [mut 9]; check_sort(v1, v2); }
|
||||||
{
|
{
|
||||||
let v1 = [mutable 9, 3, 3, 3, 9];
|
let v1 = [mut 9, 3, 3, 3, 9];
|
||||||
let v2 = [mutable 3, 3, 3, 9, 9];
|
let v2 = [mut 3, 3, 3, 9, 9];
|
||||||
check_sort(v1, v2);
|
check_sort(v1, v2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ mod test_qsort {
|
||||||
// Regression test for #750
|
// Regression test for #750
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simple() {
|
fn test_simple() {
|
||||||
let names = [mutable 2, 1, 3];
|
let names = [mut 2, 1, 3];
|
||||||
|
|
||||||
let expected = [1, 2, 3];
|
let expected = [1, 2, 3];
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_merge_sort_mutable() {
|
fn test_merge_sort_mutable() {
|
||||||
fn le(&&a: int, &&b: int) -> bool { ret a <= b; }
|
fn le(&&a: int, &&b: int) -> bool { ret a <= b; }
|
||||||
let v1 = [mutable 3, 2, 1];
|
let v1 = [mut 3, 2, 1];
|
||||||
let v2 = merge_sort(le, v1);
|
let v2 = merge_sort(le, v1);
|
||||||
assert v2 == [1, 2, 3];
|
assert v2 == [1, 2, 3];
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,11 +88,11 @@ enum test_result { tr_ok, tr_failed, tr_ignored, }
|
||||||
type console_test_state =
|
type console_test_state =
|
||||||
@{out: io::writer,
|
@{out: io::writer,
|
||||||
use_color: bool,
|
use_color: bool,
|
||||||
mutable total: uint,
|
mut total: uint,
|
||||||
mutable passed: uint,
|
mut passed: uint,
|
||||||
mutable failed: uint,
|
mut failed: uint,
|
||||||
mutable ignored: uint,
|
mut ignored: uint,
|
||||||
mutable failures: [test_desc]};
|
mut failures: [test_desc]};
|
||||||
|
|
||||||
// A simple console test runner
|
// A simple console test runner
|
||||||
fn run_tests_console(opts: test_opts,
|
fn run_tests_console(opts: test_opts,
|
||||||
|
@ -131,11 +131,11 @@ fn run_tests_console(opts: test_opts,
|
||||||
let st =
|
let st =
|
||||||
@{out: io::stdout(),
|
@{out: io::stdout(),
|
||||||
use_color: use_color(),
|
use_color: use_color(),
|
||||||
mutable total: 0u,
|
mut total: 0u,
|
||||||
mutable passed: 0u,
|
mut passed: 0u,
|
||||||
mutable failed: 0u,
|
mut failed: 0u,
|
||||||
mutable ignored: 0u,
|
mut ignored: 0u,
|
||||||
mutable failures: []};
|
mut failures: []};
|
||||||
|
|
||||||
run_tests(opts, tests, bind callback(_, st));
|
run_tests(opts, tests, bind callback(_, st));
|
||||||
|
|
||||||
|
@ -210,11 +210,11 @@ fn should_sort_failures_before_printing_them() {
|
||||||
let st =
|
let st =
|
||||||
@{out: writer,
|
@{out: writer,
|
||||||
use_color: false,
|
use_color: false,
|
||||||
mutable total: 0u,
|
mut total: 0u,
|
||||||
mutable passed: 0u,
|
mut passed: 0u,
|
||||||
mutable failed: 0u,
|
mut failed: 0u,
|
||||||
mutable ignored: 0u,
|
mut ignored: 0u,
|
||||||
mutable failures: [test_b, test_a]};
|
mut failures: [test_b, test_a]};
|
||||||
|
|
||||||
print_failures(st);
|
print_failures(st);
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,17 @@ export insert;
|
||||||
export find;
|
export find;
|
||||||
export traverse;
|
export traverse;
|
||||||
|
|
||||||
type treemap<K, V> = @mutable tree_node<K, V>;
|
type treemap<K, V> = @mut tree_node<K, V>;
|
||||||
|
|
||||||
enum tree_node<K, V> { empty, node(@K, @V, treemap<K, V>, treemap<K, V>) }
|
enum tree_node<K, V> { empty, node(@K, @V, treemap<K, V>, treemap<K, V>) }
|
||||||
|
|
||||||
#[doc = "Create a treemap"]
|
#[doc = "Create a treemap"]
|
||||||
fn treemap<K, V>() -> treemap<K, V> { @mutable empty }
|
fn treemap<K, V>() -> treemap<K, V> { @mut empty }
|
||||||
|
|
||||||
#[doc = "Insert a value into the map"]
|
#[doc = "Insert a value into the map"]
|
||||||
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) {
|
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) {
|
||||||
alt m {
|
alt m {
|
||||||
@empty { *m = node(@k, @v, @mutable empty, @mutable empty); }
|
@empty { *m = node(@k, @v, @mut empty, @mut empty); }
|
||||||
@node(@kk, _, _, _) {
|
@node(@kk, _, _, _) {
|
||||||
|
|
||||||
// We have to name left and right individually, because
|
// We have to name left and right individually, because
|
||||||
|
@ -114,8 +114,8 @@ mod tests {
|
||||||
insert(m, 2, ());
|
insert(m, 2, ());
|
||||||
insert(m, 1, ());
|
insert(m, 1, ());
|
||||||
|
|
||||||
let n = @mutable 0;
|
let n = @mut 0;
|
||||||
fn t(n: @mutable int, &&k: int, &&_v: ()) {
|
fn t(n: @mut int, &&k: int, &&_v: ()) {
|
||||||
assert (*n == k); *n += 1;
|
assert (*n == k); *n += 1;
|
||||||
}
|
}
|
||||||
traverse(m, bind t(n, _, _));
|
traverse(m, bind t(n, _, _));
|
||||||
|
|
|
@ -8,13 +8,13 @@ import option::{some, none};
|
||||||
// than the node itself.
|
// than the node itself.
|
||||||
type node = option<uint>;
|
type node = option<uint>;
|
||||||
|
|
||||||
type ufind = {mutable nodes: [mutable node]};
|
type ufind = {mut nodes: [mut node]};
|
||||||
|
|
||||||
fn make() -> ufind { ret {mutable nodes: [mutable]}; }
|
fn make() -> ufind { ret {mut nodes: [mut]}; }
|
||||||
|
|
||||||
fn make_set(ufnd: ufind) -> uint {
|
fn make_set(ufnd: ufind) -> uint {
|
||||||
let idx = vec::len(ufnd.nodes);
|
let idx = vec::len(ufnd.nodes);
|
||||||
ufnd.nodes += [mutable none::<uint>];
|
ufnd.nodes += [mut none::<uint>];
|
||||||
ret idx;
|
ret idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ iface handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
type handler_t = @{
|
type handler_t = @{
|
||||||
mutable err_count: uint,
|
mut err_count: uint,
|
||||||
_emit: emitter
|
_emit: emitter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ fn mk_handler(emitter: option<emitter>) -> handler {
|
||||||
};
|
};
|
||||||
|
|
||||||
@{
|
@{
|
||||||
mutable err_count: 0u,
|
mut err_count: 0u,
|
||||||
_emit: emit
|
_emit: emit
|
||||||
} as handler
|
} as handler
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,17 +479,17 @@ fn build_session_(
|
||||||
cstore: cstore,
|
cstore: cstore,
|
||||||
parse_sess: @{
|
parse_sess: @{
|
||||||
cm: codemap,
|
cm: codemap,
|
||||||
mutable next_id: 1,
|
mut next_id: 1,
|
||||||
span_diagnostic: span_diagnostic_handler,
|
span_diagnostic: span_diagnostic_handler,
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
},
|
},
|
||||||
codemap: codemap,
|
codemap: codemap,
|
||||||
// For a library crate, this is always none
|
// For a library crate, this is always none
|
||||||
mutable main_fn: none,
|
mut main_fn: none,
|
||||||
span_diagnostic: span_diagnostic_handler,
|
span_diagnostic: span_diagnostic_handler,
|
||||||
filesearch: filesearch,
|
filesearch: filesearch,
|
||||||
mutable building_library: false,
|
mut building_library: false,
|
||||||
working_dir: os::getcwd()}
|
working_dir: os::getcwd()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,10 @@ type session = @{targ_cfg: @config,
|
||||||
parse_sess: parse_sess,
|
parse_sess: parse_sess,
|
||||||
codemap: codemap::codemap,
|
codemap: codemap::codemap,
|
||||||
// For a library crate, this is always none
|
// For a library crate, this is always none
|
||||||
mutable main_fn: option<(node_id, codemap::span)>,
|
mut main_fn: option<(node_id, codemap::span)>,
|
||||||
span_diagnostic: diagnostic::span_handler,
|
span_diagnostic: diagnostic::span_handler,
|
||||||
filesearch: filesearch::filesearch,
|
filesearch: filesearch::filesearch,
|
||||||
mutable building_library: bool,
|
mut building_library: bool,
|
||||||
working_dir: str};
|
working_dir: str};
|
||||||
|
|
||||||
impl session for session {
|
impl session for session {
|
||||||
|
|
|
@ -198,8 +198,8 @@ fn sort_meta_items(items: [@ast::meta_item]) -> [@ast::meta_item] {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is sort of stupid here, converting to a vec of mutables and back
|
// This is sort of stupid here, converting to a vec of mutables and back
|
||||||
let mut v: [mutable @ast::meta_item] = [mutable];
|
let mut v: [mut @ast::meta_item] = [mut];
|
||||||
for mi: @ast::meta_item in items { v += [mutable mi]; }
|
for mi: @ast::meta_item in items { v += [mut mi]; }
|
||||||
|
|
||||||
std::sort::quick_sort(lteq, v);
|
std::sort::quick_sort(lteq, v);
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ type test = {span: span, path: [ast::ident], ignore: bool, should_fail: bool};
|
||||||
type test_ctxt =
|
type test_ctxt =
|
||||||
@{sess: session::session,
|
@{sess: session::session,
|
||||||
crate: @ast::crate,
|
crate: @ast::crate,
|
||||||
mutable path: [ast::ident],
|
mut path: [ast::ident],
|
||||||
mutable testfns: [test]};
|
mut testfns: [test]};
|
||||||
|
|
||||||
// Traverse the crate, collecting all the test functions, eliding any
|
// Traverse the crate, collecting all the test functions, eliding any
|
||||||
// existing main functions, and synthesizing a main test harness
|
// existing main functions, and synthesizing a main test harness
|
||||||
|
@ -39,8 +39,8 @@ fn generate_test_harness(sess: session::session,
|
||||||
let cx: test_ctxt =
|
let cx: test_ctxt =
|
||||||
@{sess: sess,
|
@{sess: sess,
|
||||||
crate: crate,
|
crate: crate,
|
||||||
mutable path: [],
|
mut path: [],
|
||||||
mutable testfns: []};
|
mut testfns: []};
|
||||||
|
|
||||||
let precursor =
|
let precursor =
|
||||||
{fold_crate: fold::wrap(bind fold_crate(cx, _, _)),
|
{fold_crate: fold::wrap(bind fold_crate(cx, _, _)),
|
||||||
|
|
|
@ -234,8 +234,8 @@ fn visit_ids(item: ast::inlined_item, vfn: fn@(ast::node_id)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_id_range(item: ast::inlined_item) -> id_range {
|
fn compute_id_range(item: ast::inlined_item) -> id_range {
|
||||||
let min = @mutable int::max_value;
|
let min = @mut int::max_value;
|
||||||
let max = @mutable int::min_value;
|
let max = @mut int::min_value;
|
||||||
visit_ids(item) {|id|
|
visit_ids(item) {|id|
|
||||||
*min = int::min(*min, id);
|
*min = int::min(*min, id);
|
||||||
*max = int::max(*max, id + 1);
|
*max = int::max(*max, id + 1);
|
||||||
|
@ -684,7 +684,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
|
||||||
ebml_w.wr_tag(c::tag_table as uint) {||
|
ebml_w.wr_tag(c::tag_table as uint) {||
|
||||||
visit_ids(ii, fn@(id: ast::node_id) {
|
visit_ids(ii, fn@(id: ast::node_id) {
|
||||||
// Note: this will cause a copy of ebml_w, which is bad as
|
// Note: this will cause a copy of ebml_w, which is bad as
|
||||||
// it has mutable fields. But I believe it's harmless since
|
// it has mut fields. But I believe it's harmless since
|
||||||
// we generate balanced EBML.
|
// we generate balanced EBML.
|
||||||
encode_side_tables_for_id(ecx, ebml_w, id)
|
encode_side_tables_for_id(ecx, ebml_w, id)
|
||||||
});
|
});
|
||||||
|
@ -943,10 +943,10 @@ fn new_parse_sess() -> parser::parse_sess {
|
||||||
let handler = diagnostic::mk_handler(option::none);
|
let handler = diagnostic::mk_handler(option::none);
|
||||||
let sess = @{
|
let sess = @{
|
||||||
cm: cm,
|
cm: cm,
|
||||||
mutable next_id: 1,
|
mut next_id: 1,
|
||||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
};
|
};
|
||||||
ret sess;
|
ret sess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export list_file_metadata;
|
||||||
fn read_crates(sess: session::session, crate: ast::crate) {
|
fn read_crates(sess: session::session, crate: ast::crate) {
|
||||||
let e = @{sess: sess,
|
let e = @{sess: sess,
|
||||||
crate_cache: std::map::str_hash::<int>(),
|
crate_cache: std::map::str_hash::<int>(),
|
||||||
mutable next_crate_num: 1};
|
mut next_crate_num: 1};
|
||||||
let v =
|
let v =
|
||||||
visit::mk_simple_visitor(@{visit_view_item:
|
visit::mk_simple_visitor(@{visit_view_item:
|
||||||
bind visit_view_item(e, _),
|
bind visit_view_item(e, _),
|
||||||
|
@ -32,7 +32,7 @@ fn read_crates(sess: session::session, crate: ast::crate) {
|
||||||
|
|
||||||
type env = @{sess: session::session,
|
type env = @{sess: session::session,
|
||||||
crate_cache: hashmap<str, int>,
|
crate_cache: hashmap<str, int>,
|
||||||
mutable next_crate_num: ast::crate_num};
|
mut next_crate_num: ast::crate_num};
|
||||||
|
|
||||||
fn visit_view_item(e: env, i: @ast::view_item) {
|
fn visit_view_item(e: env, i: @ast::view_item) {
|
||||||
alt i.node {
|
alt i.node {
|
||||||
|
|
|
@ -53,9 +53,9 @@ type cstore_private =
|
||||||
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
|
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
|
||||||
use_crate_map: use_crate_map,
|
use_crate_map: use_crate_map,
|
||||||
mod_path_map: mod_path_map,
|
mod_path_map: mod_path_map,
|
||||||
mutable used_crate_files: [str],
|
mut used_crate_files: [str],
|
||||||
mutable used_libraries: [str],
|
mut used_libraries: [str],
|
||||||
mutable used_link_args: [str]};
|
mut used_link_args: [str]};
|
||||||
|
|
||||||
// Map from node_id's of local use statements to crate numbers
|
// Map from node_id's of local use statements to crate numbers
|
||||||
type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
|
type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
|
||||||
|
@ -70,9 +70,9 @@ fn mk_cstore() -> cstore {
|
||||||
ret private(@{metas: meta_cache,
|
ret private(@{metas: meta_cache,
|
||||||
use_crate_map: crate_map,
|
use_crate_map: crate_map,
|
||||||
mod_path_map: mod_path_map,
|
mod_path_map: mod_path_map,
|
||||||
mutable used_crate_files: [],
|
mut used_crate_files: [],
|
||||||
mutable used_libraries: [],
|
mut used_libraries: [],
|
||||||
mutable used_link_args: []});
|
mut used_link_args: []});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata {
|
fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata {
|
||||||
|
|
|
@ -283,7 +283,7 @@ fn encode_parent_item(ebml_w: ebml::writer, id: def_id) {
|
||||||
|
|
||||||
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
id: node_id, variants: [variant],
|
id: node_id, variants: [variant],
|
||||||
path: ast_map::path, index: @mutable [entry<int>],
|
path: ast_map::path, index: @mut [entry<int>],
|
||||||
ty_params: [ty_param]) {
|
ty_params: [ty_param]) {
|
||||||
let mut disr_val = 0;
|
let mut disr_val = 0;
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
@ -362,9 +362,9 @@ fn encode_privacy(ebml_w: ebml::writer, privacy: privacy) {
|
||||||
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
id: node_id, path: ast_map::path,
|
id: node_id, path: ast_map::path,
|
||||||
items: [@class_item],
|
items: [@class_item],
|
||||||
global_index: @mutable[entry<int>])
|
global_index: @mut[entry<int>])
|
||||||
-> [entry<int>] {
|
-> [entry<int>] {
|
||||||
let index = @mutable [];
|
let index = @mut [];
|
||||||
let tcx = ecx.ccx.tcx;
|
let tcx = ecx.ccx.tcx;
|
||||||
for ci in items {
|
for ci in items {
|
||||||
/* We encode both private and public fields -- need to include
|
/* We encode both private and public fields -- need to include
|
||||||
|
@ -466,14 +466,14 @@ fn should_inline(attrs: [attribute]) -> bool {
|
||||||
|
|
||||||
|
|
||||||
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||||
index: @mutable [entry<int>], path: ast_map::path) {
|
index: @mut [entry<int>], path: ast_map::path) {
|
||||||
|
|
||||||
let tcx = ecx.ccx.tcx;
|
let tcx = ecx.ccx.tcx;
|
||||||
let must_write = alt item.node { item_enum(_, _) { true } _ { false } };
|
let must_write = alt item.node { item_enum(_, _) { true } _ { false } };
|
||||||
if !must_write && !ecx.ccx.reachable.contains_key(item.id) { ret; }
|
if !must_write && !ecx.ccx.reachable.contains_key(item.id) { ret; }
|
||||||
|
|
||||||
fn add_to_index_(item: @item, ebml_w: ebml::writer,
|
fn add_to_index_(item: @item, ebml_w: ebml::writer,
|
||||||
index: @mutable [entry<int>]) {
|
index: @mut [entry<int>]) {
|
||||||
*index += [{val: item.id, pos: ebml_w.writer.tell()}];
|
*index += [{val: item.id, pos: ebml_w.writer.tell()}];
|
||||||
}
|
}
|
||||||
let add_to_index = bind add_to_index_(item, ebml_w, index);
|
let add_to_index = bind add_to_index_(item, ebml_w, index);
|
||||||
|
@ -678,7 +678,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||||
|
|
||||||
fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
nitem: @native_item,
|
nitem: @native_item,
|
||||||
index: @mutable [entry<int>],
|
index: @mut [entry<int>],
|
||||||
path: ast_map::path, abi: native_abi) {
|
path: ast_map::path, abi: native_abi) {
|
||||||
if !ecx.ccx.reachable.contains_key(nitem.id) { ret; }
|
if !ecx.ccx.reachable.contains_key(nitem.id) { ret; }
|
||||||
*index += [{val: nitem.id, pos: ebml_w.writer.tell()}];
|
*index += [{val: nitem.id, pos: ebml_w.writer.tell()}];
|
||||||
|
@ -704,7 +704,7 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
|
|
||||||
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
crate: @crate) -> [entry<int>] {
|
crate: @crate) -> [entry<int>] {
|
||||||
let index = @mutable [];
|
let index = @mut [];
|
||||||
ebml_w.start_tag(tag_items_data);
|
ebml_w.start_tag(tag_items_data);
|
||||||
*index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
|
*index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
|
||||||
encode_info_for_mod(ecx, ebml_w, crate.node.module,
|
encode_info_for_mod(ecx, ebml_w, crate.node.module,
|
||||||
|
@ -752,15 +752,15 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
|
|
||||||
fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) ->
|
fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) ->
|
||||||
[@[entry<T>]] {
|
[@[entry<T>]] {
|
||||||
let mut buckets: [@mutable [entry<T>]] = [];
|
let mut buckets: [@mut [entry<T>]] = [];
|
||||||
uint::range(0u, 256u) {|_i| buckets += [@mutable []]; };
|
uint::range(0u, 256u) {|_i| buckets += [@mut []]; };
|
||||||
for elt: entry<T> in index {
|
for elt: entry<T> in index {
|
||||||
let h = hash_fn(elt.val);
|
let h = hash_fn(elt.val);
|
||||||
*buckets[h % 256u] += [elt];
|
*buckets[h % 256u] += [elt];
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buckets_frozen = [];
|
let mut buckets_frozen = [];
|
||||||
for bucket: @mutable [entry<T>] in buckets {
|
for bucket: @mut [entry<T>] in buckets {
|
||||||
buckets_frozen += [@*bucket];
|
buckets_frozen += [@*bucket];
|
||||||
}
|
}
|
||||||
ret buckets_frozen;
|
ret buckets_frozen;
|
||||||
|
@ -901,9 +901,9 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
||||||
type numname = {crate: crate_num, ident: str};
|
type numname = {crate: crate_num, ident: str};
|
||||||
|
|
||||||
// Pull the cnums and names out of cstore
|
// Pull the cnums and names out of cstore
|
||||||
let mut pairs: [mutable numname] = [mutable];
|
let mut pairs: [mut numname] = [mut];
|
||||||
cstore::iter_crate_data(cstore) {|key, val|
|
cstore::iter_crate_data(cstore) {|key, val|
|
||||||
pairs += [mutable {crate: key, ident: val.name}];
|
pairs += [mut {crate: key, ident: val.name}];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sort by cnum
|
// Sort by cnum
|
||||||
|
@ -919,7 +919,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
||||||
|
|
||||||
// Return just the names
|
// Return just the names
|
||||||
fn name(kv: numname) -> str { kv.ident }
|
fn name(kv: numname) -> str { kv.ident }
|
||||||
// mutable -> immutable hack for vec::map
|
// mut -> immutable hack for vec::map
|
||||||
let immpairs = vec::slice(pairs, 0u, vec::len(pairs));
|
let immpairs = vec::slice(pairs, 0u, vec::len(pairs));
|
||||||
ret vec::map(immpairs, name);
|
ret vec::map(immpairs, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ export parse_bounds_data;
|
||||||
// Callback to translate defs to strs or back:
|
// Callback to translate defs to strs or back:
|
||||||
type conv_did = fn(ast::def_id) -> ast::def_id;
|
type conv_did = fn(ast::def_id) -> ast::def_id;
|
||||||
|
|
||||||
type pstate = {data: @[u8], crate: int, mutable pos: uint, tcx: ty::ctxt};
|
type pstate = {data: @[u8], crate: int, mut pos: uint, tcx: ty::ctxt};
|
||||||
|
|
||||||
fn peek(st: @pstate) -> char {
|
fn peek(st: @pstate) -> char {
|
||||||
st.data[st.pos] as char
|
st.data[st.pos] as char
|
||||||
|
@ -52,7 +52,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
|
||||||
|
|
||||||
fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||||
conv: conv_did) -> ty::t {
|
conv: conv_did) -> ty::t {
|
||||||
let st = @{data: data, crate: crate_num, mutable pos: pos, tcx: tcx};
|
let st = @{data: data, crate: crate_num, mut pos: pos, tcx: tcx};
|
||||||
parse_ty(st, conv)
|
parse_ty(st, conv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ fn parse_def_id(buf: [u8]) -> ast::def_id {
|
||||||
fn parse_bounds_data(data: @[u8], start: uint,
|
fn parse_bounds_data(data: @[u8], start: uint,
|
||||||
crate_num: int, tcx: ty::ctxt, conv: conv_did)
|
crate_num: int, tcx: ty::ctxt, conv: conv_did)
|
||||||
-> @[ty::param_bound] {
|
-> @[ty::param_bound] {
|
||||||
let st = @{data: data, crate: crate_num, mutable pos: start, tcx: tcx};
|
let st = @{data: data, crate: crate_num, mut pos: start, tcx: tcx};
|
||||||
parse_bounds(st, conv)
|
parse_bounds(st, conv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ type binding = @{node_id: node_id,
|
||||||
root_var: option<node_id>,
|
root_var: option<node_id>,
|
||||||
local_id: uint,
|
local_id: uint,
|
||||||
unsafe_tys: [unsafe_ty],
|
unsafe_tys: [unsafe_ty],
|
||||||
mutable copied: copied};
|
mut copied: copied};
|
||||||
|
|
||||||
// FIXME it may be worthwhile to use a linked list of bindings instead
|
// FIXME it may be worthwhile to use a linked list of bindings instead
|
||||||
type scope = {bs: [binding],
|
type scope = {bs: [binding],
|
||||||
invalid: @mutable list<@invalid>};
|
invalid: @mut list<@invalid>};
|
||||||
|
|
||||||
fn mk_binding(cx: ctx, id: node_id, span: span, root_var: option<node_id>,
|
fn mk_binding(cx: ctx, id: node_id, span: span, root_var: option<node_id>,
|
||||||
unsafe_tys: [unsafe_ty]) -> binding {
|
unsafe_tys: [unsafe_ty]) -> binding {
|
||||||
|
@ -45,7 +45,7 @@ fn mk_binding(cx: ctx, id: node_id, span: span, root_var: option<node_id>,
|
||||||
ret @{node_id: id, span: span, root_var: root_var,
|
ret @{node_id: id, span: span, root_var: root_var,
|
||||||
local_id: local_id_of_node(cx, id),
|
local_id: local_id_of_node(cx, id),
|
||||||
unsafe_tys: unsafe_tys,
|
unsafe_tys: unsafe_tys,
|
||||||
mutable copied: not_copied};
|
mut copied: not_copied};
|
||||||
}
|
}
|
||||||
|
|
||||||
enum local_info { local(uint), }
|
enum local_info { local(uint), }
|
||||||
|
@ -56,7 +56,7 @@ type ref_map = std::map::hashmap<node_id, node_id>;
|
||||||
type ctx = {tcx: ty::ctxt,
|
type ctx = {tcx: ty::ctxt,
|
||||||
copy_map: copy_map,
|
copy_map: copy_map,
|
||||||
ref_map: ref_map,
|
ref_map: ref_map,
|
||||||
mutable silent: bool};
|
mut silent: bool};
|
||||||
|
|
||||||
fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
|
fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
|
||||||
// Stores information about function arguments that's otherwise not easily
|
// Stores information about function arguments that's otherwise not easily
|
||||||
|
@ -64,12 +64,12 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
|
||||||
let cx = @{tcx: tcx,
|
let cx = @{tcx: tcx,
|
||||||
copy_map: std::map::int_hash(),
|
copy_map: std::map::int_hash(),
|
||||||
ref_map: std::map::int_hash(),
|
ref_map: std::map::int_hash(),
|
||||||
mutable silent: false};
|
mut silent: false};
|
||||||
let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _),
|
let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _),
|
||||||
visit_expr: bind visit_expr(cx, _, _, _),
|
visit_expr: bind visit_expr(cx, _, _, _),
|
||||||
visit_block: bind visit_block(cx, _, _, _)
|
visit_block: bind visit_block(cx, _, _, _)
|
||||||
with *visit::default_visitor::<scope>()};
|
with *visit::default_visitor::<scope>()};
|
||||||
let sc = {bs: [], invalid: @mutable list::nil};
|
let sc = {bs: [], invalid: @mut list::nil};
|
||||||
visit::visit_crate(*crate, sc, visit::mk_vt(v));
|
visit::visit_crate(*crate, sc, visit::mk_vt(v));
|
||||||
tcx.sess.abort_if_errors();
|
tcx.sess.abort_if_errors();
|
||||||
ret (cx.copy_map, cx.ref_map);
|
ret (cx.copy_map, cx.ref_map);
|
||||||
|
@ -89,7 +89,7 @@ fn visit_fn(cx: @ctx, _fk: visit::fn_kind, decl: ast::fn_decl,
|
||||||
check_loop(*cx, sc) {|| v.visit_block(body, sc, v);}
|
check_loop(*cx, sc) {|| v.visit_block(body, sc, v);}
|
||||||
}
|
}
|
||||||
ast::proto_box | ast::proto_uniq | ast::proto_bare {
|
ast::proto_box | ast::proto_uniq | ast::proto_bare {
|
||||||
let sc = {bs: [], invalid: @mutable list::nil};
|
let sc = {bs: [], invalid: @mut list::nil};
|
||||||
v.visit_block(body, sc, v);
|
v.visit_block(body, sc, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
|
||||||
root_var: root_var,
|
root_var: root_var,
|
||||||
local_id: 0u,
|
local_id: 0u,
|
||||||
unsafe_tys: unsafe_set(root.mutbl),
|
unsafe_tys: unsafe_set(root.mutbl),
|
||||||
mutable copied: arg_copied}];
|
mut copied: arg_copied}];
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
let f_may_close =
|
let f_may_close =
|
||||||
|
@ -291,7 +291,7 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
|
||||||
}
|
}
|
||||||
j += 1u;
|
j += 1u;
|
||||||
}
|
}
|
||||||
// Ensure we're not passing a root by mutable alias.
|
// Ensure we're not passing a root by mut alias.
|
||||||
|
|
||||||
for {node: node, arg: arg} in mut_roots {
|
for {node: node, arg: arg} in mut_roots {
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
|
@ -301,7 +301,7 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
|
||||||
some(root) {
|
some(root) {
|
||||||
if node == root && cant_copy(cx, b) {
|
if node == root && cant_copy(cx, b) {
|
||||||
err(cx, args[arg].span,
|
err(cx, args[arg].span,
|
||||||
"passing a mutable reference to a \
|
"passing a mut reference to a \
|
||||||
variable that roots another reference");
|
variable that roots another reference");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ fn check_alt(cx: ctx, input: @ast::expr, arms: [ast::arm], sc: scope,
|
||||||
let pat_id_map = pat_util::pat_id_map(cx.tcx.def_map, a.pats[0]);
|
let pat_id_map = pat_util::pat_id_map(cx.tcx.def_map, a.pats[0]);
|
||||||
type info = {
|
type info = {
|
||||||
id: node_id,
|
id: node_id,
|
||||||
mutable unsafe_tys: [unsafe_ty],
|
mut unsafe_tys: [unsafe_ty],
|
||||||
span: span};
|
span: span};
|
||||||
let mut binding_info: [info] = [];
|
let mut binding_info: [info] = [];
|
||||||
for pat in a.pats {
|
for pat in a.pats {
|
||||||
|
@ -338,7 +338,7 @@ fn check_alt(cx: ctx, input: @ast::expr, arms: [ast::arm], sc: scope,
|
||||||
none {
|
none {
|
||||||
binding_info += [
|
binding_info += [
|
||||||
{id: canon_id,
|
{id: canon_id,
|
||||||
mutable unsafe_tys: unsafe_set(proot.mutbl),
|
mut unsafe_tys: unsafe_set(proot.mutbl),
|
||||||
span: proot.span}];
|
span: proot.span}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ fn check_for(cx: ctx, local: @ast::local, seq: @ast::expr, blk: ast::blk,
|
||||||
sc: scope, v: vt<scope>) {
|
sc: scope, v: vt<scope>) {
|
||||||
let root = expr_root(cx, seq, false);
|
let root = expr_root(cx, seq, false);
|
||||||
|
|
||||||
// If this is a mutable vector, don't allow it to be touched.
|
// If this is a mut vector, don't allow it to be touched.
|
||||||
let seq_t = ty::expr_ty(cx.tcx, seq);
|
let seq_t = ty::expr_ty(cx.tcx, seq);
|
||||||
let mut cur_mutbl = root.mutbl;
|
let mut cur_mutbl = root.mutbl;
|
||||||
alt ty::get(seq_t).struct {
|
alt ty::get(seq_t).struct {
|
||||||
|
@ -522,7 +522,7 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
|
||||||
ty::ty_fn(_) | ty::ty_iface(_, _) { ret true; }
|
ty::ty_fn(_) | ty::ty_iface(_, _) { ret true; }
|
||||||
// A type param may include everything, but can only be
|
// A type param may include everything, but can only be
|
||||||
// treated as opaque downstream, and is thus safe unless we
|
// treated as opaque downstream, and is thus safe unless we
|
||||||
// saw mutable fields, in which case the whole thing can be
|
// saw mut fields, in which case the whole thing can be
|
||||||
// overwritten.
|
// overwritten.
|
||||||
ty::ty_param(_, _) { ret mutbl; }
|
ty::ty_param(_, _) { ret mutbl; }
|
||||||
_ { ret false; }
|
_ { ret false; }
|
||||||
|
|
|
@ -40,8 +40,8 @@ enum ast_node {
|
||||||
}
|
}
|
||||||
|
|
||||||
type map = std::map::hashmap<node_id, ast_node>;
|
type map = std::map::hashmap<node_id, ast_node>;
|
||||||
type ctx = {map: map, mutable path: path,
|
type ctx = {map: map, mut path: path,
|
||||||
mutable local_id: uint, sess: session};
|
mut local_id: uint, sess: session};
|
||||||
type vt = visit::vt<ctx>;
|
type vt = visit::vt<ctx>;
|
||||||
|
|
||||||
fn extend(cx: ctx, elt: str) -> @path {
|
fn extend(cx: ctx, elt: str) -> @path {
|
||||||
|
@ -63,8 +63,8 @@ fn mk_ast_map_visitor() -> vt {
|
||||||
|
|
||||||
fn map_crate(sess: session, c: crate) -> map {
|
fn map_crate(sess: session, c: crate) -> map {
|
||||||
let cx = {map: std::map::int_hash(),
|
let cx = {map: std::map::int_hash(),
|
||||||
mutable path: [],
|
mut path: [],
|
||||||
mutable local_id: 0u,
|
mut local_id: 0u,
|
||||||
sess: sess};
|
sess: sess};
|
||||||
visit::visit_crate(c, cx, mk_ast_map_visitor());
|
visit::visit_crate(c, cx, mk_ast_map_visitor());
|
||||||
ret cx.map;
|
ret cx.map;
|
||||||
|
@ -81,8 +81,8 @@ fn map_decoded_item(sess: session, map: map, path: path, ii: inlined_item) {
|
||||||
// even if we did I think it only needs an ordering between local
|
// even if we did I think it only needs an ordering between local
|
||||||
// variables that are simultaneously in scope).
|
// variables that are simultaneously in scope).
|
||||||
let cx = {map: map,
|
let cx = {map: map,
|
||||||
mutable path: path,
|
mut path: path,
|
||||||
mutable local_id: 0u,
|
mut local_id: 0u,
|
||||||
sess: sess};
|
sess: sess};
|
||||||
let v = mk_ast_map_visitor();
|
let v = mk_ast_map_visitor();
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@ import syntax::visit;
|
||||||
import syntax::ast::*;
|
import syntax::ast::*;
|
||||||
import driver::session::session;
|
import driver::session::session;
|
||||||
|
|
||||||
type ctx = {tcx: ty::ctxt, mutable allow_block: bool};
|
type ctx = {tcx: ty::ctxt, mut allow_block: bool};
|
||||||
|
|
||||||
fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
||||||
let cx = {tcx: tcx, mutable allow_block: false};
|
let cx = {tcx: tcx, mut allow_block: false};
|
||||||
let v = visit::mk_vt(@{visit_expr: visit_expr
|
let v = visit::mk_vt(@{visit_expr: visit_expr
|
||||||
with *visit::default_visitor()});
|
with *visit::default_visitor()});
|
||||||
visit::visit_crate(*crate, cx, v);
|
visit::visit_crate(*crate, cx, v);
|
||||||
|
|
|
@ -101,8 +101,8 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) {
|
||||||
vec::iter(cols) {|col| check_exhaustive(tcx, sp, col); }
|
vec::iter(cols) {|col| check_exhaustive(tcx, sp, col); }
|
||||||
}
|
}
|
||||||
ty::ty_rec(fs) {
|
ty::ty_rec(fs) {
|
||||||
let cols = vec::from_elem(fs.len(), {mutable wild: false,
|
let cols = vec::from_elem(fs.len(), {mut wild: false,
|
||||||
mutable pats: []});
|
mut pats: []});
|
||||||
for p in pats {
|
for p in pats {
|
||||||
alt raw_pat(p).node {
|
alt raw_pat(p).node {
|
||||||
pat_rec(sub, _) {
|
pat_rec(sub, _) {
|
||||||
|
@ -156,7 +156,7 @@ fn check_exhaustive_enum(tcx: ty::ctxt, enum_id: def_id, sp: span,
|
||||||
pats: [@pat]) {
|
pats: [@pat]) {
|
||||||
let variants = enum_variants(tcx, enum_id);
|
let variants = enum_variants(tcx, enum_id);
|
||||||
let columns_by_variant = vec::map(*variants, {|v|
|
let columns_by_variant = vec::map(*variants, {|v|
|
||||||
{mutable seen: false,
|
{mut seen: false,
|
||||||
cols: vec::to_mut(vec::from_elem(v.args.len(), []))}
|
cols: vec::to_mut(vec::from_elem(v.args.len(), []))}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ type freevar_map = hashmap<ast::node_id, freevar_info>;
|
||||||
fn collect_freevars(def_map: resolve::def_map, blk: ast::blk)
|
fn collect_freevars(def_map: resolve::def_map, blk: ast::blk)
|
||||||
-> freevar_info {
|
-> freevar_info {
|
||||||
let seen = int_hash();
|
let seen = int_hash();
|
||||||
let refs = @mutable [];
|
let refs = @mut [];
|
||||||
|
|
||||||
fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
|
fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
|
||||||
|
|
||||||
|
|
|
@ -424,8 +424,8 @@ impl unify_methods for infer_ctxt {
|
||||||
|
|
||||||
alt b.mutbl {
|
alt b.mutbl {
|
||||||
ast::m_mutbl {
|
ast::m_mutbl {
|
||||||
// If supertype is mutable, subtype must match exactly
|
// If supertype is mut, subtype must match exactly
|
||||||
// (i.e., invariant if mutable):
|
// (i.e., invariant if mut):
|
||||||
self.eq_tys(a.ty, b.ty)
|
self.eq_tys(a.ty, b.ty)
|
||||||
}
|
}
|
||||||
ast::m_imm | ast::m_const {
|
ast::m_imm | ast::m_const {
|
||||||
|
@ -751,7 +751,7 @@ impl resolve_methods for infer_ctxt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subst_vars(unresolved: @mutable option<int>,
|
fn subst_vars(unresolved: @mut option<int>,
|
||||||
vars_seen: std::list::list<int>,
|
vars_seen: std::list::list<int>,
|
||||||
vid: int) -> ty::t {
|
vid: int) -> ty::t {
|
||||||
// Should really return a fixup_result instead of a t, but fold_ty
|
// Should really return a fixup_result instead of a t, but fold_ty
|
||||||
|
@ -785,7 +785,7 @@ impl resolve_methods for infer_ctxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fixup_vars(typ: ty::t) -> fres<ty::t> {
|
fn fixup_vars(typ: ty::t) -> fres<ty::t> {
|
||||||
let unresolved = @mutable none::<int>;
|
let unresolved = @mut none::<int>;
|
||||||
let rty =
|
let rty =
|
||||||
ty::fold_ty(self.tcx,
|
ty::fold_ty(self.tcx,
|
||||||
ty::fm_var(
|
ty::fm_var(
|
||||||
|
@ -802,7 +802,7 @@ impl resolve_methods for infer_ctxt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subst_regions(unresolved: @mutable option<int>,
|
fn subst_regions(unresolved: @mut option<int>,
|
||||||
regions_seen: std::list::list<int>,
|
regions_seen: std::list::list<int>,
|
||||||
rid: int) -> ty::region {
|
rid: int) -> ty::region {
|
||||||
// Should really return a fixup_result instead of a t, but fold_ty
|
// Should really return a fixup_result instead of a t, but fold_ty
|
||||||
|
@ -826,7 +826,7 @@ impl resolve_methods for infer_ctxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fixup_regions(typ: ty::t) -> fres<ty::t> {
|
fn fixup_regions(typ: ty::t) -> fres<ty::t> {
|
||||||
let unresolved = @mutable none::<int>;
|
let unresolved = @mut none::<int>;
|
||||||
let rty = ty::fold_ty(self.tcx, ty::fm_rptr({ |region, _under_rptr|
|
let rty = ty::fold_ty(self.tcx, ty::fm_rptr({ |region, _under_rptr|
|
||||||
alt region {
|
alt region {
|
||||||
ty::re_var(rid) {
|
ty::re_var(rid) {
|
||||||
|
@ -1346,8 +1346,8 @@ impl of combine for glb {
|
||||||
mt_to_str(tcx, b));
|
mt_to_str(tcx, b));
|
||||||
|
|
||||||
alt (a.mutbl, b.mutbl) {
|
alt (a.mutbl, b.mutbl) {
|
||||||
// If one side or both is mutable, then the GLB must use
|
// If one side or both is mut, then the GLB must use
|
||||||
// the precise type from the mutable side.
|
// the precise type from the mut side.
|
||||||
(ast::m_mutbl, ast::m_const) {
|
(ast::m_mutbl, ast::m_const) {
|
||||||
self.infcx().tys(a.ty, b.ty).then {||
|
self.infcx().tys(a.ty, b.ty).then {||
|
||||||
ok({ty: a.ty, mutbl: ast::m_mutbl})
|
ok({ty: a.ty, mutbl: ast::m_mutbl})
|
||||||
|
|
|
@ -38,7 +38,7 @@ enum block_type { func, lp, }
|
||||||
|
|
||||||
enum use { var_use(node_id), close_over(node_id), }
|
enum use { var_use(node_id), close_over(node_id), }
|
||||||
type set = [{def: node_id, uses: list<use>}];
|
type set = [{def: node_id, uses: list<use>}];
|
||||||
type bl = @{type: block_type, mutable second: bool, mutable exits: [set]};
|
type bl = @{type: block_type, mut second: bool, mut exits: [set]};
|
||||||
|
|
||||||
enum use_id { path(node_id), close(node_id, node_id) }
|
enum use_id { path(node_id), close(node_id, node_id) }
|
||||||
fn hash_use_id(id: use_id) -> uint {
|
fn hash_use_id(id: use_id) -> uint {
|
||||||
|
@ -51,8 +51,8 @@ type ctx = {last_uses: std::map::hashmap<use_id, bool>,
|
||||||
ref_map: alias::ref_map,
|
ref_map: alias::ref_map,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
// The current set of local last uses
|
// The current set of local last uses
|
||||||
mutable current: set,
|
mut current: set,
|
||||||
mutable blocks: list<bl>};
|
mut blocks: list<bl>};
|
||||||
|
|
||||||
fn find_last_uses(c: @crate, def_map: resolve::def_map,
|
fn find_last_uses(c: @crate, def_map: resolve::def_map,
|
||||||
ref_map: alias::ref_map, tcx: ty::ctxt)
|
ref_map: alias::ref_map, tcx: ty::ctxt)
|
||||||
|
@ -66,8 +66,8 @@ fn find_last_uses(c: @crate, def_map: resolve::def_map,
|
||||||
def_map: def_map,
|
def_map: def_map,
|
||||||
ref_map: ref_map,
|
ref_map: ref_map,
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
mutable current: [],
|
mut current: [],
|
||||||
mutable blocks: nil};
|
mut blocks: nil};
|
||||||
visit::visit_crate(*c, cx, v);
|
visit::visit_crate(*c, cx, v);
|
||||||
let mini_table = std::map::int_hash();
|
let mini_table = std::map::int_hash();
|
||||||
cx.last_uses.items {|key, val|
|
cx.last_uses.items {|key, val|
|
||||||
|
@ -268,7 +268,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_block(tp: block_type, cx: ctx, visit: fn()) {
|
fn visit_block(tp: block_type, cx: ctx, visit: fn()) {
|
||||||
let local = @{type: tp, mutable second: false, mutable exits: []};
|
let local = @{type: tp, mut second: false, mut exits: []};
|
||||||
cx.blocks = cons(local, @cx.blocks);
|
cx.blocks = cons(local, @cx.blocks);
|
||||||
visit();
|
visit();
|
||||||
local.second = true;
|
local.second = true;
|
||||||
|
|
|
@ -131,7 +131,7 @@ fn mk_err(cx: @ctx, span: syntax::codemap::span, msg: msg, name: str) {
|
||||||
cx.tcx.sess.span_err(span, alt msg {
|
cx.tcx.sess.span_err(span, alt msg {
|
||||||
msg_assign { "assigning to " + name }
|
msg_assign { "assigning to " + name }
|
||||||
msg_move_out { "moving out of " + name }
|
msg_move_out { "moving out of " + name }
|
||||||
msg_mutbl_ref { "passing " + name + " by mutable reference" }
|
msg_mutbl_ref { "passing " + name + " by mut reference" }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ fn check_bind(cx: @ctx, f: @expr, args: [option<@expr>]) {
|
||||||
alt arg {
|
alt arg {
|
||||||
some(expr) {
|
some(expr) {
|
||||||
let o_msg = alt ty::resolved_mode(cx.tcx, arg_ts[i].mode) {
|
let o_msg = alt ty::resolved_mode(cx.tcx, arg_ts[i].mode) {
|
||||||
by_mutbl_ref { some("by mutable reference") }
|
by_mutbl_ref { some("by mut reference") }
|
||||||
by_move { some("by move") }
|
by_move { some("by move") }
|
||||||
_ { none }
|
_ { none }
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,7 @@ enum scope {
|
||||||
scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]),
|
scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]),
|
||||||
scope_native_item(@ast::native_item),
|
scope_native_item(@ast::native_item),
|
||||||
scope_loop(@ast::local), // there's only 1 decl per loop.
|
scope_loop(@ast::local), // there's only 1 decl per loop.
|
||||||
scope_block(ast::blk, @mutable uint, @mutable uint),
|
scope_block(ast::blk, @mut uint, @mut uint),
|
||||||
scope_arm(ast::arm),
|
scope_arm(ast::arm),
|
||||||
scope_method(node_id, [ast::ty_param]),
|
scope_method(node_id, [ast::ty_param]),
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ type glob_imp_def = {def: def, path: @ast::view_path};
|
||||||
type indexed_mod = {
|
type indexed_mod = {
|
||||||
m: option<ast::_mod>,
|
m: option<ast::_mod>,
|
||||||
index: mod_index,
|
index: mod_index,
|
||||||
mutable glob_imports: [glob_imp_def],
|
mut glob_imports: [glob_imp_def],
|
||||||
mutable globbed_exports: [ident],
|
mut globbed_exports: [ident],
|
||||||
glob_imported_names: hashmap<str, glob_import_state>,
|
glob_imported_names: hashmap<str, glob_import_state>,
|
||||||
path: str
|
path: str
|
||||||
};
|
};
|
||||||
|
@ -127,19 +127,19 @@ type env =
|
||||||
def_map: def_map,
|
def_map: def_map,
|
||||||
ast_map: ast_map::map,
|
ast_map: ast_map::map,
|
||||||
imports: hashmap<node_id, import_state>,
|
imports: hashmap<node_id, import_state>,
|
||||||
mutable exp_map: exp_map,
|
mut exp_map: exp_map,
|
||||||
mod_map: hashmap<node_id, @indexed_mod>,
|
mod_map: hashmap<node_id, @indexed_mod>,
|
||||||
block_map: hashmap<node_id, [glob_imp_def]>,
|
block_map: hashmap<node_id, [glob_imp_def]>,
|
||||||
ext_map: ext_map,
|
ext_map: ext_map,
|
||||||
impl_map: impl_map,
|
impl_map: impl_map,
|
||||||
impl_cache: impl_cache,
|
impl_cache: impl_cache,
|
||||||
ext_cache: ext_hash,
|
ext_cache: ext_hash,
|
||||||
used_imports: {mutable track: bool,
|
used_imports: {mut track: bool,
|
||||||
mutable data: [node_id]},
|
mut data: [node_id]},
|
||||||
mutable reported: [{ident: str, sc: scope}],
|
mut reported: [{ident: str, sc: scope}],
|
||||||
mutable ignored_imports: [node_id],
|
mut ignored_imports: [node_id],
|
||||||
mutable current_tp: option<uint>,
|
mut current_tp: option<uint>,
|
||||||
mutable resolve_unexported: bool,
|
mut resolve_unexported: bool,
|
||||||
sess: session};
|
sess: session};
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,18 +171,18 @@ fn create_env(sess: session, amap: ast_map::map) -> @env {
|
||||||
def_map: int_hash(),
|
def_map: int_hash(),
|
||||||
ast_map: amap,
|
ast_map: amap,
|
||||||
imports: int_hash(),
|
imports: int_hash(),
|
||||||
mutable exp_map: int_hash(),
|
mut exp_map: int_hash(),
|
||||||
mod_map: int_hash(),
|
mod_map: int_hash(),
|
||||||
block_map: int_hash(),
|
block_map: int_hash(),
|
||||||
ext_map: new_def_hash(),
|
ext_map: new_def_hash(),
|
||||||
impl_map: int_hash(),
|
impl_map: int_hash(),
|
||||||
impl_cache: new_def_hash(),
|
impl_cache: new_def_hash(),
|
||||||
ext_cache: new_ext_hash(),
|
ext_cache: new_ext_hash(),
|
||||||
used_imports: {mutable track: false, mutable data: []},
|
used_imports: {mut track: false, mut data: []},
|
||||||
mutable reported: [],
|
mut reported: [],
|
||||||
mutable ignored_imports: [],
|
mut ignored_imports: [],
|
||||||
mutable current_tp: none,
|
mut current_tp: none,
|
||||||
mutable resolve_unexported: false,
|
mut resolve_unexported: false,
|
||||||
sess: sess}
|
sess: sess}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,8 +268,8 @@ fn map_crate(e: @env, c: @ast::crate) {
|
||||||
e.mod_map.insert(i.id,
|
e.mod_map.insert(i.id,
|
||||||
@{m: some(md),
|
@{m: some(md),
|
||||||
index: index_mod(md),
|
index: index_mod(md),
|
||||||
mutable glob_imports: [],
|
mut glob_imports: [],
|
||||||
mutable globbed_exports: [],
|
mut globbed_exports: [],
|
||||||
glob_imported_names: str_hash(),
|
glob_imported_names: str_hash(),
|
||||||
path: path_from_scope(sc, i.ident)});
|
path: path_from_scope(sc, i.ident)});
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,8 @@ fn map_crate(e: @env, c: @ast::crate) {
|
||||||
e.mod_map.insert(i.id,
|
e.mod_map.insert(i.id,
|
||||||
@{m: none::<ast::_mod>,
|
@{m: none::<ast::_mod>,
|
||||||
index: index_nmod(nmd),
|
index: index_nmod(nmd),
|
||||||
mutable glob_imports: [],
|
mut glob_imports: [],
|
||||||
mutable globbed_exports: [],
|
mut globbed_exports: [],
|
||||||
glob_imported_names: str_hash(),
|
glob_imported_names: str_hash(),
|
||||||
path: path_from_scope(sc, i.ident)});
|
path: path_from_scope(sc, i.ident)});
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ fn map_crate(e: @env, c: @ast::crate) {
|
||||||
e.mod_map.insert(ast::crate_node_id,
|
e.mod_map.insert(ast::crate_node_id,
|
||||||
@{m: some(c.node.module),
|
@{m: some(c.node.module),
|
||||||
index: index_mod(c.node.module),
|
index: index_mod(c.node.module),
|
||||||
mutable glob_imports: [],
|
mut glob_imports: [],
|
||||||
mutable globbed_exports: [],
|
mut globbed_exports: [],
|
||||||
glob_imported_names: str_hash(),
|
glob_imported_names: str_hash(),
|
||||||
path: ""});
|
path: ""});
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt<scopes>) {
|
fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt<scopes>) {
|
||||||
let pos = @mutable 0u, loc = @mutable 0u;
|
let pos = @mut 0u, loc = @mut 0u;
|
||||||
let block_sc = cons(scope_block(b, pos, loc), @sc);
|
let block_sc = cons(scope_block(b, pos, loc), @sc);
|
||||||
for vi in b.node.view_items { v.visit_view_item(vi, block_sc, v); }
|
for vi in b.node.view_items { v.visit_view_item(vi, block_sc, v); }
|
||||||
for stmt in b.node.stmts {
|
for stmt in b.node.stmts {
|
||||||
|
@ -594,7 +594,7 @@ fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt<scopes>) {
|
||||||
fn visit_decl_with_scope(d: @decl, sc: scopes, v: vt<scopes>) {
|
fn visit_decl_with_scope(d: @decl, sc: scopes, v: vt<scopes>) {
|
||||||
let loc_pos = alt list::head(sc) {
|
let loc_pos = alt list::head(sc) {
|
||||||
scope_block(_, _, pos) { pos }
|
scope_block(_, _, pos) { pos }
|
||||||
_ { @mutable 0u }
|
_ { @mut 0u }
|
||||||
};
|
};
|
||||||
alt d.node {
|
alt d.node {
|
||||||
decl_local(locs) {
|
decl_local(locs) {
|
||||||
|
@ -1894,11 +1894,11 @@ fn check_ty(e: @env, ty: @ast::ty, &&x: (), v: vt<()>) {
|
||||||
visit::visit_ty(ty, x, v);
|
visit::visit_ty(ty, x, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
type checker = @{mutable seen: [ident], kind: str, sess: session};
|
type checker = @{mut seen: [ident], kind: str, sess: session};
|
||||||
|
|
||||||
fn checker(e: env, kind: str) -> checker {
|
fn checker(e: env, kind: str) -> checker {
|
||||||
let seen: [ident] = [];
|
let seen: [ident] = [];
|
||||||
ret @{mutable seen: seen, kind: kind, sess: e.sess};
|
ret @{mut seen: seen, kind: kind, sess: e.sess};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_name(ch: checker, sp: span, name: ident) {
|
fn check_name(ch: checker, sp: span, name: ident) {
|
||||||
|
|
|
@ -640,9 +640,9 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm],
|
||||||
let mk_fail = alt mode {
|
let mk_fail = alt mode {
|
||||||
ast::alt_check {
|
ast::alt_check {
|
||||||
// Cached fail-on-fallthrough block
|
// Cached fail-on-fallthrough block
|
||||||
let fail_cx = @mutable none;
|
let fail_cx = @mut none;
|
||||||
fn mk_fail(bcx: block, sp: span,
|
fn mk_fail(bcx: block, sp: span,
|
||||||
done: @mutable option<BasicBlockRef>) -> BasicBlockRef {
|
done: @mut option<BasicBlockRef>) -> BasicBlockRef {
|
||||||
alt *done { some(bb) { ret bb; } _ { } }
|
alt *done { some(bb) { ret bb; } _ { } }
|
||||||
let fail_cx = sub_block(bcx, "case_fallthrough");
|
let fail_cx = sub_block(bcx, "case_fallthrough");
|
||||||
trans_fail(fail_cx, some(sp), "non-exhaustive match failure");;
|
trans_fail(fail_cx, some(sp), "non-exhaustive match failure");;
|
||||||
|
|
|
@ -56,7 +56,7 @@ import std::smallintmap;
|
||||||
// destination of a computation's value.
|
// destination of a computation's value.
|
||||||
|
|
||||||
enum dest {
|
enum dest {
|
||||||
by_val(@mutable ValueRef),
|
by_val(@mut ValueRef),
|
||||||
save_in(ValueRef),
|
save_in(ValueRef),
|
||||||
ignore,
|
ignore,
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ fn dest_str(ccx: @crate_ctxt, d: dest) -> str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn empty_dest_cell() -> @mutable ValueRef {
|
fn empty_dest_cell() -> @mut ValueRef {
|
||||||
ret @mutable llvm::LLVMGetUndef(T_nil());
|
ret @mut llvm::LLVMGetUndef(T_nil());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dup_for_join(dest: dest) -> dest {
|
fn dup_for_join(dest: dest) -> dest {
|
||||||
|
@ -454,9 +454,9 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
|
||||||
tydesc: gvar,
|
tydesc: gvar,
|
||||||
size: llsize,
|
size: llsize,
|
||||||
align: llalign,
|
align: llalign,
|
||||||
mutable take_glue: none,
|
mut take_glue: none,
|
||||||
mutable drop_glue: none,
|
mut drop_glue: none,
|
||||||
mutable free_glue: none};
|
mut free_glue: none};
|
||||||
log(debug, "--- declare_tydesc " + ty_to_str(ccx.tcx, t));
|
log(debug, "--- declare_tydesc " + ty_to_str(ccx.tcx, t));
|
||||||
ret info;
|
ret info;
|
||||||
}
|
}
|
||||||
|
@ -3516,11 +3516,11 @@ fn new_block(cx: fn_ctxt, parent: block_parent, kind: block_kind,
|
||||||
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
|
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
|
||||||
});
|
});
|
||||||
let bcx = @{llbb: llbb,
|
let bcx = @{llbb: llbb,
|
||||||
mutable terminated: false,
|
mut terminated: false,
|
||||||
mutable unreachable: false,
|
mut unreachable: false,
|
||||||
parent: parent,
|
parent: parent,
|
||||||
kind: kind,
|
kind: kind,
|
||||||
mutable block_span: block_span,
|
mut block_span: block_span,
|
||||||
fcx: cx};
|
fcx: cx};
|
||||||
alt parent {
|
alt parent {
|
||||||
parent_some(cx) {
|
parent_some(cx) {
|
||||||
|
@ -3532,8 +3532,8 @@ fn new_block(cx: fn_ctxt, parent: block_parent, kind: block_kind,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simple_block_scope() -> block_kind {
|
fn simple_block_scope() -> block_kind {
|
||||||
block_scope({is_loop: none, mutable cleanups: [],
|
block_scope({is_loop: none, mut cleanups: [],
|
||||||
mutable cleanup_paths: [], mutable landing_pad: none})
|
mut cleanup_paths: [], mut landing_pad: none})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this when you're at the top block of a function or the like.
|
// Use this when you're at the top block of a function or the like.
|
||||||
|
@ -3552,9 +3552,9 @@ fn loop_scope_block(bcx: block, _cont: loop_cont,
|
||||||
-> block {
|
-> block {
|
||||||
ret new_block(bcx.fcx, parent_some(bcx), block_scope({
|
ret new_block(bcx.fcx, parent_some(bcx), block_scope({
|
||||||
is_loop: some({cnt: _cont, brk: _break}),
|
is_loop: some({cnt: _cont, brk: _break}),
|
||||||
mutable cleanups: [],
|
mut cleanups: [],
|
||||||
mutable cleanup_paths: [],
|
mut cleanup_paths: [],
|
||||||
mutable landing_pad: none
|
mut landing_pad: none
|
||||||
}), n, some(sp));
|
}), n, some(sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3566,11 +3566,11 @@ fn sub_block(bcx: block, n: str) -> block {
|
||||||
|
|
||||||
fn raw_block(fcx: fn_ctxt, llbb: BasicBlockRef) -> block {
|
fn raw_block(fcx: fn_ctxt, llbb: BasicBlockRef) -> block {
|
||||||
ret @{llbb: llbb,
|
ret @{llbb: llbb,
|
||||||
mutable terminated: false,
|
mut terminated: false,
|
||||||
mutable unreachable: false,
|
mut unreachable: false,
|
||||||
parent: parent_none,
|
parent: parent_none,
|
||||||
kind: block_non_scope,
|
kind: block_non_scope,
|
||||||
mutable block_span: none,
|
mut block_span: none,
|
||||||
fcx: fcx};
|
fcx: fcx};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3775,11 +3775,11 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path,
|
||||||
ret @{llfn: llfndecl,
|
ret @{llfn: llfndecl,
|
||||||
llenv: llvm::LLVMGetParam(llfndecl, 1u as c_uint),
|
llenv: llvm::LLVMGetParam(llfndecl, 1u as c_uint),
|
||||||
llretptr: llvm::LLVMGetParam(llfndecl, 0u as c_uint),
|
llretptr: llvm::LLVMGetParam(llfndecl, 0u as c_uint),
|
||||||
mutable llstaticallocas: llbbs.sa,
|
mut llstaticallocas: llbbs.sa,
|
||||||
mutable llloadenv: llbbs.ca,
|
mut llloadenv: llbbs.ca,
|
||||||
mutable llreturn: llbbs.rt,
|
mut llreturn: llbbs.rt,
|
||||||
mutable llself: none,
|
mut llself: none,
|
||||||
mutable personality: none,
|
mut personality: none,
|
||||||
llargs: int_hash::<local_val>(),
|
llargs: int_hash::<local_val>(),
|
||||||
lllocals: int_hash::<local_val>(),
|
lllocals: int_hash::<local_val>(),
|
||||||
llupvars: int_hash::<ValueRef>(),
|
llupvars: int_hash::<ValueRef>(),
|
||||||
|
@ -4766,7 +4766,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
||||||
exp_map: emap,
|
exp_map: emap,
|
||||||
reachable: reachable,
|
reachable: reachable,
|
||||||
item_symbols: int_hash::<str>(),
|
item_symbols: int_hash::<str>(),
|
||||||
mutable main_fn: none::<ValueRef>,
|
mut main_fn: none::<ValueRef>,
|
||||||
link_meta: link_meta,
|
link_meta: link_meta,
|
||||||
enum_sizes: ty::new_ty_hash(),
|
enum_sizes: ty::new_ty_hash(),
|
||||||
discrims: ast_util::new_def_id_hash::<ValueRef>(),
|
discrims: ast_util::new_def_id_hash::<ValueRef>(),
|
||||||
|
@ -4786,13 +4786,13 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
maps: maps,
|
maps: maps,
|
||||||
stats:
|
stats:
|
||||||
{mutable n_static_tydescs: 0u,
|
{mut n_static_tydescs: 0u,
|
||||||
mutable n_glues_created: 0u,
|
mut n_glues_created: 0u,
|
||||||
mutable n_null_glues: 0u,
|
mut n_null_glues: 0u,
|
||||||
mutable n_real_glues: 0u,
|
mut n_real_glues: 0u,
|
||||||
llvm_insn_ctxt: @mutable [],
|
llvm_insn_ctxt: @mut [],
|
||||||
llvm_insns: str_hash(),
|
llvm_insns: str_hash(),
|
||||||
fn_times: @mutable []},
|
fn_times: @mut []},
|
||||||
upcalls:
|
upcalls:
|
||||||
upcall::declare_upcalls(targ_cfg, tn, tydesc_type,
|
upcall::declare_upcalls(targ_cfg, tn, tydesc_type,
|
||||||
llmod),
|
llmod),
|
||||||
|
@ -4806,7 +4806,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
|
||||||
crate_map: crate_map,
|
crate_map: crate_map,
|
||||||
dbg_cx: dbg_cx,
|
dbg_cx: dbg_cx,
|
||||||
class_ctors: int_hash::<int>(),
|
class_ctors: int_hash::<int>(),
|
||||||
mutable do_not_commit_warning_issued: false};
|
mut do_not_commit_warning_issued: false};
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,7 @@ import ast_map::path;
|
||||||
|
|
||||||
type namegen = fn@(str) -> str;
|
type namegen = fn@(str) -> str;
|
||||||
fn new_namegen() -> namegen {
|
fn new_namegen() -> namegen {
|
||||||
let i = @mutable 0;
|
let i = @mut 0;
|
||||||
ret fn@(prefix: str) -> str { *i += 1; prefix + int::str(*i) };
|
ret fn@(prefix: str) -> str { *i += 1; prefix + int::str(*i) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ type tydesc_info =
|
||||||
tydesc: ValueRef,
|
tydesc: ValueRef,
|
||||||
size: ValueRef,
|
size: ValueRef,
|
||||||
align: ValueRef,
|
align: ValueRef,
|
||||||
mutable take_glue: option<ValueRef>,
|
mut take_glue: option<ValueRef>,
|
||||||
mutable drop_glue: option<ValueRef>,
|
mut drop_glue: option<ValueRef>,
|
||||||
mutable free_glue: option<ValueRef>};
|
mut free_glue: option<ValueRef>};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A note on nomenclature of linking: "upcall", "extern" and "native".
|
* A note on nomenclature of linking: "upcall", "extern" and "native".
|
||||||
|
@ -52,13 +52,13 @@ type tydesc_info =
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type stats =
|
type stats =
|
||||||
{mutable n_static_tydescs: uint,
|
{mut n_static_tydescs: uint,
|
||||||
mutable n_glues_created: uint,
|
mut n_glues_created: uint,
|
||||||
mutable n_null_glues: uint,
|
mut n_null_glues: uint,
|
||||||
mutable n_real_glues: uint,
|
mut n_real_glues: uint,
|
||||||
llvm_insn_ctxt: @mutable [str],
|
llvm_insn_ctxt: @mut [str],
|
||||||
llvm_insns: hashmap<str, uint>,
|
llvm_insns: hashmap<str, uint>,
|
||||||
fn_times: @mutable [{ident: str, time: int}]};
|
fn_times: @mut [{ident: str, time: int}]};
|
||||||
|
|
||||||
resource BuilderRef_res(B: BuilderRef) { llvm::LLVMDisposeBuilder(B); }
|
resource BuilderRef_res(B: BuilderRef) { llvm::LLVMDisposeBuilder(B); }
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ type crate_ctxt = {
|
||||||
exp_map: resolve::exp_map,
|
exp_map: resolve::exp_map,
|
||||||
reachable: reachable::map,
|
reachable: reachable::map,
|
||||||
item_symbols: hashmap<ast::node_id, str>,
|
item_symbols: hashmap<ast::node_id, str>,
|
||||||
mutable main_fn: option<ValueRef>,
|
mut main_fn: option<ValueRef>,
|
||||||
link_meta: link::link_meta,
|
link_meta: link::link_meta,
|
||||||
enum_sizes: hashmap<ty::t, uint>,
|
enum_sizes: hashmap<ty::t, uint>,
|
||||||
discrims: hashmap<ast::def_id, ValueRef>,
|
discrims: hashmap<ast::def_id, ValueRef>,
|
||||||
|
@ -122,7 +122,7 @@ type crate_ctxt = {
|
||||||
// Mapping from class constructors to parent class --
|
// Mapping from class constructors to parent class --
|
||||||
// used in base::trans_closure
|
// used in base::trans_closure
|
||||||
class_ctors: hashmap<ast::node_id, ast::node_id>,
|
class_ctors: hashmap<ast::node_id, ast::node_id>,
|
||||||
mutable do_not_commit_warning_issued: bool};
|
mut do_not_commit_warning_issued: bool};
|
||||||
|
|
||||||
// Types used for llself.
|
// Types used for llself.
|
||||||
type val_self_pair = {v: ValueRef, t: ty::t};
|
type val_self_pair = {v: ValueRef, t: ty::t};
|
||||||
|
@ -152,19 +152,19 @@ type fn_ctxt = @{
|
||||||
// the function, due to LLVM's quirks.
|
// the function, due to LLVM's quirks.
|
||||||
// A block for all the function's static allocas, so that LLVM
|
// A block for all the function's static allocas, so that LLVM
|
||||||
// will coalesce them into a single alloca call.
|
// will coalesce them into a single alloca call.
|
||||||
mutable llstaticallocas: BasicBlockRef,
|
mut llstaticallocas: BasicBlockRef,
|
||||||
// A block containing code that copies incoming arguments to space
|
// A block containing code that copies incoming arguments to space
|
||||||
// already allocated by code in one of the llallocas blocks.
|
// already allocated by code in one of the llallocas blocks.
|
||||||
// (LLVM requires that arguments be copied to local allocas before
|
// (LLVM requires that arguments be copied to local allocas before
|
||||||
// allowing most any operation to be performed on them.)
|
// allowing most any operation to be performed on them.)
|
||||||
mutable llloadenv: BasicBlockRef,
|
mut llloadenv: BasicBlockRef,
|
||||||
mutable llreturn: BasicBlockRef,
|
mut llreturn: BasicBlockRef,
|
||||||
// The 'self' value currently in use in this function, if there
|
// The 'self' value currently in use in this function, if there
|
||||||
// is one.
|
// is one.
|
||||||
mutable llself: option<val_self_pair>,
|
mut llself: option<val_self_pair>,
|
||||||
// The a value alloca'd for calls to upcalls.rust_personality. Used when
|
// The a value alloca'd for calls to upcalls.rust_personality. Used when
|
||||||
// outputting the resume instruction.
|
// outputting the resume instruction.
|
||||||
mutable personality: option<ValueRef>,
|
mut personality: option<ValueRef>,
|
||||||
|
|
||||||
// Maps arguments to allocas created for them in llallocas.
|
// Maps arguments to allocas created for them in llallocas.
|
||||||
llargs: hashmap<ast::node_id, local_val>,
|
llargs: hashmap<ast::node_id, local_val>,
|
||||||
|
@ -294,12 +294,12 @@ type scope_info = {
|
||||||
// A list of functions that must be run at when leaving this
|
// A list of functions that must be run at when leaving this
|
||||||
// block, cleaning up any variables that were introduced in the
|
// block, cleaning up any variables that were introduced in the
|
||||||
// block.
|
// block.
|
||||||
mutable cleanups: [cleanup],
|
mut cleanups: [cleanup],
|
||||||
// Existing cleanup paths that may be reused, indexed by destination and
|
// Existing cleanup paths that may be reused, indexed by destination and
|
||||||
// cleared when the set of cleanups changes.
|
// cleared when the set of cleanups changes.
|
||||||
mutable cleanup_paths: [cleanup_path],
|
mut cleanup_paths: [cleanup_path],
|
||||||
// Unwinding landing pad. Also cleared when cleanups change.
|
// Unwinding landing pad. Also cleared when cleanups change.
|
||||||
mutable landing_pad: option<BasicBlockRef>,
|
mut landing_pad: option<BasicBlockRef>,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic block context. We create a block context for each basic block
|
// Basic block context. We create a block context for each basic block
|
||||||
|
@ -314,14 +314,14 @@ type block = @{
|
||||||
// instructions into that block by way of this block context.
|
// instructions into that block by way of this block context.
|
||||||
// The block pointing to this one in the function's digraph.
|
// The block pointing to this one in the function's digraph.
|
||||||
llbb: BasicBlockRef,
|
llbb: BasicBlockRef,
|
||||||
mutable terminated: bool,
|
mut terminated: bool,
|
||||||
mutable unreachable: bool,
|
mut unreachable: bool,
|
||||||
parent: block_parent,
|
parent: block_parent,
|
||||||
// The 'kind' of basic block this is.
|
// The 'kind' of basic block this is.
|
||||||
kind: block_kind,
|
kind: block_kind,
|
||||||
// The source span where the block came from, if it is a block that
|
// The source span where the block came from, if it is a block that
|
||||||
// actually appears in the source code.
|
// actually appears in the source code.
|
||||||
mutable block_span: option<span>,
|
mut block_span: option<span>,
|
||||||
// The function context for the function to which this block is
|
// The function context for the function to which this block is
|
||||||
// attached.
|
// attached.
|
||||||
fcx: fn_ctxt
|
fcx: fn_ctxt
|
||||||
|
|
|
@ -366,8 +366,8 @@ type struct_ctxt = {
|
||||||
file: ValueRef,
|
file: ValueRef,
|
||||||
name: str,
|
name: str,
|
||||||
line: int,
|
line: int,
|
||||||
mutable members: [ValueRef],
|
mut members: [ValueRef],
|
||||||
mutable total_size: int,
|
mut total_size: int,
|
||||||
align: int
|
align: int
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -382,8 +382,8 @@ fn create_structure(file: @metadata<file_md>, name: str, line: int)
|
||||||
let cx = @{file: file.node,
|
let cx = @{file: file.node,
|
||||||
name: name,
|
name: name,
|
||||||
line: line,
|
line: line,
|
||||||
mutable members: [],
|
mut members: [],
|
||||||
mutable total_size: 0,
|
mut total_size: 0,
|
||||||
align: 64 //XXX different alignment per arch?
|
align: 64 //XXX different alignment per arch?
|
||||||
};
|
};
|
||||||
ret cx;
|
ret cx;
|
||||||
|
|
|
@ -23,10 +23,10 @@ import ty_ctxt = middle::ty::ctxt;
|
||||||
type res_info = {did: ast::def_id, tps: [ty::t]};
|
type res_info = {did: ast::def_id, tps: [ty::t]};
|
||||||
|
|
||||||
type ctxt =
|
type ctxt =
|
||||||
{mutable next_tag_id: u16,
|
{mut next_tag_id: u16,
|
||||||
pad: u16,
|
pad: u16,
|
||||||
tag_id_to_index: hashmap<ast::def_id, u16>,
|
tag_id_to_index: hashmap<ast::def_id, u16>,
|
||||||
mutable tag_order: [ast::def_id],
|
mut tag_order: [ast::def_id],
|
||||||
resources: interner::interner<res_info>,
|
resources: interner::interner<res_info>,
|
||||||
llshapetablesty: TypeRef,
|
llshapetablesty: TypeRef,
|
||||||
llshapetables: ValueRef};
|
llshapetables: ValueRef};
|
||||||
|
@ -126,8 +126,8 @@ fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the candidate set to contain all variants.
|
// Initialize the candidate set to contain all variants.
|
||||||
let mut candidates = [mutable];
|
let mut candidates = [mut];
|
||||||
for variant in *variants { candidates += [mutable true]; }
|
for variant in *variants { candidates += [mut true]; }
|
||||||
|
|
||||||
// Do a pairwise comparison among all variants still in the candidate set.
|
// Do a pairwise comparison among all variants still in the candidate set.
|
||||||
// Throw out any variant that we know has size and alignment at least as
|
// Throw out any variant that we know has size and alignment at least as
|
||||||
|
@ -269,10 +269,10 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
||||||
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
|
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
|
||||||
});
|
});
|
||||||
|
|
||||||
ret {mutable next_tag_id: 0u16,
|
ret {mut next_tag_id: 0u16,
|
||||||
pad: 0u16,
|
pad: 0u16,
|
||||||
tag_id_to_index: common::new_def_hash(),
|
tag_id_to_index: common::new_def_hash(),
|
||||||
mutable tag_order: [],
|
mut tag_order: [],
|
||||||
resources: interner::mk(hash_res_info, {|a, b| a == b}),
|
resources: interner::mk(hash_res_info, {|a, b| a == b}),
|
||||||
llshapetablesty: llshapetablesty,
|
llshapetablesty: llshapetablesty,
|
||||||
llshapetables: llshapetables};
|
llshapetables: llshapetables};
|
||||||
|
|
|
@ -29,7 +29,7 @@ const use_repr: uint = 1u; // Dependency on size/alignment and take/drop glue
|
||||||
const use_tydesc: uint = 2u; // Takes the tydesc, or compares
|
const use_tydesc: uint = 2u; // Takes the tydesc, or compares
|
||||||
|
|
||||||
type ctx = {ccx: @crate_ctxt,
|
type ctx = {ccx: @crate_ctxt,
|
||||||
uses: [mutable type_uses]};
|
uses: [mut type_uses]};
|
||||||
|
|
||||||
fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
||||||
-> [type_uses] {
|
-> [type_uses] {
|
||||||
|
|
|
@ -7,11 +7,11 @@ import aux::{num_constraints, get_fn_info, crate_ctxt, add_node};
|
||||||
import ann::empty_ann;
|
import ann::empty_ann;
|
||||||
import pat_util::pat_binding_ids;
|
import pat_util::pat_binding_ids;
|
||||||
|
|
||||||
fn collect_ids_expr(e: @expr, rs: @mutable [node_id]) { *rs += [e.id]; }
|
fn collect_ids_expr(e: @expr, rs: @mut [node_id]) { *rs += [e.id]; }
|
||||||
|
|
||||||
fn collect_ids_block(b: blk, rs: @mutable [node_id]) { *rs += [b.node.id]; }
|
fn collect_ids_block(b: blk, rs: @mut [node_id]) { *rs += [b.node.id]; }
|
||||||
|
|
||||||
fn collect_ids_stmt(s: @stmt, rs: @mutable [node_id]) {
|
fn collect_ids_stmt(s: @stmt, rs: @mut [node_id]) {
|
||||||
alt s.node {
|
alt s.node {
|
||||||
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
|
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
|
||||||
log(debug, "node_id " + int::str(id));
|
log(debug, "node_id " + int::str(id));
|
||||||
|
@ -22,11 +22,11 @@ fn collect_ids_stmt(s: @stmt, rs: @mutable [node_id]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mutable [node_id]) {
|
fn collect_ids_local(tcx: ty::ctxt, l: @local, rs: @mut [node_id]) {
|
||||||
*rs += pat_binding_ids(tcx.def_map, l.node.pat);
|
*rs += pat_binding_ids(tcx.def_map, l.node.pat);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mutable [node_id]) {
|
fn node_ids_in_fn(tcx: ty::ctxt, body: blk, rs: @mut [node_id]) {
|
||||||
let collect_ids =
|
let collect_ids =
|
||||||
visit::mk_simple_visitor(@{visit_expr: bind collect_ids_expr(_, rs),
|
visit::mk_simple_visitor(@{visit_expr: bind collect_ids_expr(_, rs),
|
||||||
visit_block: bind collect_ids_block(_, rs),
|
visit_block: bind collect_ids_block(_, rs),
|
||||||
|
@ -45,7 +45,7 @@ fn init_vecs(ccx: crate_ctxt, node_ids: [node_id], len: uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_fn(ccx: crate_ctxt, num_constraints: uint, body: blk) {
|
fn visit_fn(ccx: crate_ctxt, num_constraints: uint, body: blk) {
|
||||||
let node_ids: @mutable [node_id] = @mutable [];
|
let node_ids: @mut [node_id] = @mut [];
|
||||||
node_ids_in_fn(ccx.tcx, body, node_ids);
|
node_ids_in_fn(ccx.tcx, body, node_ids);
|
||||||
let node_id_vec = *node_ids;
|
let node_id_vec = *node_ids;
|
||||||
init_vecs(ccx, node_id_vec, num_constraints);
|
init_vecs(ccx, node_id_vec, num_constraints);
|
||||||
|
|
|
@ -200,9 +200,9 @@ type constr_arg_use = spanned<constr_arg_general_<inst>>;
|
||||||
enum constraint {
|
enum constraint {
|
||||||
cinit(uint, span, ident),
|
cinit(uint, span, ident),
|
||||||
|
|
||||||
// FIXME: really only want it to be mutable during collect_locals.
|
// FIXME: really only want it to be mut during collect_locals.
|
||||||
// freeze it after that.
|
// freeze it after that.
|
||||||
cpred(@path, @mutable [pred_args]),
|
cpred(@path, @mut [pred_args]),
|
||||||
}
|
}
|
||||||
|
|
||||||
// An ninit variant has a node_id because it refers to a local var.
|
// An ninit variant has a node_id because it refers to a local var.
|
||||||
|
@ -261,7 +261,7 @@ type fn_info =
|
||||||
cf: ret_style,
|
cf: ret_style,
|
||||||
i_return: tsconstr,
|
i_return: tsconstr,
|
||||||
i_diverge: tsconstr,
|
i_diverge: tsconstr,
|
||||||
used_vars: @mutable [node_id]};
|
used_vars: @mut [node_id]};
|
||||||
|
|
||||||
fn tsconstr_to_def_id(t: tsconstr) -> def_id {
|
fn tsconstr_to_def_id(t: tsconstr) -> def_id {
|
||||||
alt t { ninit(id, _) { local_def(id) } npred(_, id, _) { id } }
|
alt t { ninit(id, _) { local_def(id) } npred(_, id, _) { id } }
|
||||||
|
@ -275,7 +275,7 @@ fn tsconstr_to_node_id(t: tsconstr) -> node_id {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mapping from node ID to typestate annotation */
|
/* mapping from node ID to typestate annotation */
|
||||||
type node_ann_table = @mutable [mutable ts_ann];
|
type node_ann_table = @mut [mut ts_ann];
|
||||||
|
|
||||||
|
|
||||||
/* mapping from function name to fn_info map */
|
/* mapping from function name to fn_info map */
|
||||||
|
@ -483,8 +483,8 @@ fn pure_exp(ccx: crate_ctxt, id: node_id, p: prestate) -> bool {
|
||||||
fn num_constraints(m: fn_info) -> uint { ret m.num_constraints; }
|
fn num_constraints(m: fn_info) -> uint { ret m.num_constraints; }
|
||||||
|
|
||||||
fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
|
fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
|
||||||
let na: [mutable ts_ann] = [mutable];
|
let na: [mut ts_ann] = [mut];
|
||||||
ret {tcx: cx, node_anns: @mutable na, fm: int_hash::<fn_info>()};
|
ret {tcx: cx, node_anns: @mut na, fm: int_hash::<fn_info>()};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use e's type to determine whether it returns.
|
/* Use e's type to determine whether it returns.
|
||||||
|
@ -549,7 +549,7 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
|
||||||
// FIXME
|
// FIXME
|
||||||
// Would rather take an immutable vec as an argument,
|
// Would rather take an immutable vec as an argument,
|
||||||
// should freeze it at some earlier point.
|
// should freeze it at some earlier point.
|
||||||
fn match_args(fcx: fn_ctxt, occs: @mutable [pred_args],
|
fn match_args(fcx: fn_ctxt, occs: @mut [pred_args],
|
||||||
occ: [@constr_arg_use]) -> uint {
|
occ: [@constr_arg_use]) -> uint {
|
||||||
#debug("match_args: looking at %s",
|
#debug("match_args: looking at %s",
|
||||||
constr_args_to_str(fn@(i: inst) -> str { ret i.ident; }, occ));
|
constr_args_to_str(fn@(i: inst) -> str { ret i.ident; }, occ));
|
||||||
|
@ -995,7 +995,7 @@ fn args_mention<T>(args: [@constr_arg_use],
|
||||||
fn use_var(fcx: fn_ctxt, v: node_id) { *fcx.enclosing.used_vars += [v]; }
|
fn use_var(fcx: fn_ctxt, v: node_id) { *fcx.enclosing.used_vars += [v]; }
|
||||||
|
|
||||||
// FIXME: This should be a function in vec::.
|
// FIXME: This should be a function in vec::.
|
||||||
fn vec_contains(v: @mutable [node_id], i: node_id) -> bool {
|
fn vec_contains(v: @mut [node_id], i: node_id) -> bool {
|
||||||
for d: node_id in *v { if d == i { ret true; } }
|
for d: node_id in *v { if d == i { ret true; } }
|
||||||
ret false;
|
ret false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import driver::session::session;
|
||||||
import aux::*;
|
import aux::*;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
|
|
||||||
type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt};
|
type ctxt = {cs: @mut [sp_constr], tcx: ty::ctxt};
|
||||||
|
|
||||||
fn collect_local(loc: @local, cx: ctxt, v: visit::vt<ctxt>) {
|
fn collect_local(loc: @local, cx: ctxt, v: visit::vt<ctxt>) {
|
||||||
pat_bindings(cx.tcx.def_map, loc.node.pat) {|p_id, _s, id|
|
pat_bindings(cx.tcx.def_map, loc.node.pat) {|p_id, _s, id|
|
||||||
|
@ -46,7 +46,7 @@ fn find_locals(tcx: ty::ctxt,
|
||||||
f_body: blk,
|
f_body: blk,
|
||||||
sp: span,
|
sp: span,
|
||||||
id: node_id) -> ctxt {
|
id: node_id) -> ctxt {
|
||||||
let cx: ctxt = {cs: @mutable [], tcx: tcx};
|
let cx: ctxt = {cs: @mut [], tcx: tcx};
|
||||||
let visitor = visit::default_visitor::<ctxt>();
|
let visitor = visit::default_visitor::<ctxt>();
|
||||||
let visitor =
|
let visitor =
|
||||||
@{visit_local: collect_local,
|
@{visit_local: collect_local,
|
||||||
|
@ -78,8 +78,8 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
none {
|
none {
|
||||||
let rslt: @mutable [pred_args] =
|
let rslt: @mut [pred_args] =
|
||||||
@mutable [respan(c.span, {args: args, bit_num: next})];
|
@mut [respan(c.span, {args: args, bit_num: next})];
|
||||||
tbl.insert(d_id, cpred(p, rslt));
|
tbl.insert(d_id, cpred(p, rslt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ fn mk_fn_info(ccx: crate_ctxt,
|
||||||
next = add_constraint(cx.tcx, respan(f_sp, diverges_constr), next,
|
next = add_constraint(cx.tcx, respan(f_sp, diverges_constr), next,
|
||||||
res_map);
|
res_map);
|
||||||
|
|
||||||
let v: @mutable [node_id] = @mutable [];
|
let v: @mut [node_id] = @mut [];
|
||||||
let rslt =
|
let rslt =
|
||||||
{constrs: res_map,
|
{constrs: res_map,
|
||||||
num_constraints: next,
|
num_constraints: next,
|
||||||
|
|
|
@ -186,7 +186,7 @@ enum borrowing {
|
||||||
|
|
||||||
type ctxt =
|
type ctxt =
|
||||||
@{interner: hashmap<intern_key, t_box>,
|
@{interner: hashmap<intern_key, t_box>,
|
||||||
mutable next_id: uint,
|
mut next_id: uint,
|
||||||
sess: session::session,
|
sess: session::session,
|
||||||
def_map: resolve::def_map,
|
def_map: resolve::def_map,
|
||||||
region_map: @middle::region::region_map,
|
region_map: @middle::region::region_map,
|
||||||
|
@ -373,7 +373,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
|
||||||
option::maybe(k.o_def_id, 0u, ast_util::hash_def_id)
|
option::maybe(k.o_def_id, 0u, ast_util::hash_def_id)
|
||||||
}, {|&&a, &&b| a == b});
|
}, {|&&a, &&b| a == b});
|
||||||
@{interner: interner,
|
@{interner: interner,
|
||||||
mutable next_id: 0u,
|
mut next_id: 0u,
|
||||||
sess: s,
|
sess: s,
|
||||||
def_map: dm,
|
def_map: dm,
|
||||||
region_map: region_map,
|
region_map: region_map,
|
||||||
|
@ -1027,7 +1027,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true for noncopyable types and types where a copy of a value can be
|
// Returns true for noncopyable types and types where a copy of a value can be
|
||||||
// distinguished from the value itself. I.e. types with mutable content that's
|
// distinguished from the value itself. I.e. types with mut content that's
|
||||||
// not shared through a pointer.
|
// not shared through a pointer.
|
||||||
fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool {
|
fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool {
|
||||||
ret !type_structurally_contains(cx, ty, {|sty|
|
ret !type_structurally_contains(cx, ty, {|sty|
|
||||||
|
@ -2064,7 +2064,7 @@ fn class_field_tys(items: [@class_item]) -> [field_ty] {
|
||||||
fn class_items_as_fields(cx:ctxt, did: ast::def_id) -> [field] {
|
fn class_items_as_fields(cx:ctxt, did: ast::def_id) -> [field] {
|
||||||
let mut rslt = [];
|
let mut rslt = [];
|
||||||
for f in lookup_class_fields(cx, did) {
|
for f in lookup_class_fields(cx, did) {
|
||||||
// consider all instance vars mutable, because the
|
// consider all instance vars mut, because the
|
||||||
// constructor may mutate all vars
|
// constructor may mutate all vars
|
||||||
rslt += [{ident: f.ident, mt: {ty: lookup_field_type(cx, did, f.id),
|
rslt += [{ident: f.ident, mt: {ty: lookup_field_type(cx, did, f.id),
|
||||||
mutbl: m_mutbl}}];
|
mutbl: m_mutbl}}];
|
||||||
|
|
|
@ -51,7 +51,7 @@ type ty_table = hashmap<ast::def_id, ty::t>;
|
||||||
// Used for typechecking the methods of an impl
|
// Used for typechecking the methods of an impl
|
||||||
enum self_info { self_impl(ty::t) }
|
enum self_info { self_impl(ty::t) }
|
||||||
|
|
||||||
type crate_ctxt = {mutable self_infos: [self_info],
|
type crate_ctxt = {mut self_infos: [self_info],
|
||||||
impl_map: resolve::impl_map,
|
impl_map: resolve::impl_map,
|
||||||
method_map: method_map,
|
method_map: method_map,
|
||||||
vtable_map: vtable_map,
|
vtable_map: vtable_map,
|
||||||
|
@ -75,7 +75,7 @@ type fn_ctxt =
|
||||||
proto: ast::proto,
|
proto: ast::proto,
|
||||||
infcx: infer::infer_ctxt,
|
infcx: infer::infer_ctxt,
|
||||||
locals: hashmap<ast::node_id, int>,
|
locals: hashmap<ast::node_id, int>,
|
||||||
next_var_id: @mutable int,
|
next_var_id: @mut int,
|
||||||
ccx: @crate_ctxt};
|
ccx: @crate_ctxt};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1244,13 +1244,13 @@ mod demand {
|
||||||
ty_param_substs_0: [ty::t]) ->
|
ty_param_substs_0: [ty::t]) ->
|
||||||
ty_param_substs_and_ty {
|
ty_param_substs_and_ty {
|
||||||
|
|
||||||
let mut ty_param_substs: [mutable ty::t] = [mutable];
|
let mut ty_param_substs: [mut ty::t] = [mut];
|
||||||
let mut ty_param_subst_var_ids: [int] = [];
|
let mut ty_param_subst_var_ids: [int] = [];
|
||||||
for ty_param_subst: ty::t in ty_param_substs_0 {
|
for ty_param_subst: ty::t in ty_param_substs_0 {
|
||||||
// Generate a type variable and unify it with the type parameter
|
// Generate a type variable and unify it with the type parameter
|
||||||
// substitution. We will then pull out these type variables.
|
// substitution. We will then pull out these type variables.
|
||||||
let t_0 = next_ty_var(fcx);
|
let t_0 = next_ty_var(fcx);
|
||||||
ty_param_substs += [mutable t_0];
|
ty_param_substs += [mut t_0];
|
||||||
ty_param_subst_var_ids += [ty::ty_var_id(t_0)];
|
ty_param_subst_var_ids += [ty::ty_var_id(t_0)];
|
||||||
simple(fcx, sp, ty_param_subst, t_0);
|
simple(fcx, sp, ty_param_subst, t_0);
|
||||||
}
|
}
|
||||||
|
@ -1383,7 +1383,7 @@ mod writeback {
|
||||||
type wb_ctxt =
|
type wb_ctxt =
|
||||||
// As soon as we hit an error we have to stop resolving
|
// As soon as we hit an error we have to stop resolving
|
||||||
// the entire function
|
// the entire function
|
||||||
{fcx: @fn_ctxt, mutable success: bool};
|
{fcx: @fn_ctxt, mut success: bool};
|
||||||
type wb_vt = visit::vt<wb_ctxt>;
|
type wb_vt = visit::vt<wb_ctxt>;
|
||||||
|
|
||||||
fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) {
|
fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) {
|
||||||
|
@ -1461,7 +1461,7 @@ mod writeback {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
||||||
let wbcx = {fcx: fcx, mutable success: true};
|
let wbcx = {fcx: fcx, mut success: true};
|
||||||
let visit =
|
let visit =
|
||||||
visit::mk_vt(@{visit_item: visit_item,
|
visit::mk_vt(@{visit_item: visit_item,
|
||||||
visit_stmt: visit_stmt,
|
visit_stmt: visit_stmt,
|
||||||
|
@ -1475,7 +1475,7 @@ mod writeback {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_type_vars_in_block(fcx: @fn_ctxt, blk: ast::blk) -> bool {
|
fn resolve_type_vars_in_block(fcx: @fn_ctxt, blk: ast::blk) -> bool {
|
||||||
let wbcx = {fcx: fcx, mutable success: true};
|
let wbcx = {fcx: fcx, mut success: true};
|
||||||
let visit =
|
let visit =
|
||||||
visit::mk_vt(@{visit_item: visit_item,
|
visit::mk_vt(@{visit_item: visit_item,
|
||||||
visit_stmt: visit_stmt,
|
visit_stmt: visit_stmt,
|
||||||
|
@ -1536,7 +1536,7 @@ fn check_intrinsic_type(tcx: ty::ctxt, it: @ast::native_item) {
|
||||||
type gather_result =
|
type gather_result =
|
||||||
{infcx: infer::infer_ctxt,
|
{infcx: infer::infer_ctxt,
|
||||||
locals: hashmap<ast::node_id, int>,
|
locals: hashmap<ast::node_id, int>,
|
||||||
next_var_id: @mutable int};
|
next_var_id: @mut int};
|
||||||
|
|
||||||
// Used only as a helper for check_fn.
|
// Used only as a helper for check_fn.
|
||||||
fn gather_locals(ccx: @crate_ctxt,
|
fn gather_locals(ccx: @crate_ctxt,
|
||||||
|
@ -1548,7 +1548,7 @@ fn gather_locals(ccx: @crate_ctxt,
|
||||||
none {
|
none {
|
||||||
{infcx: infer::new_infer_ctxt(ccx.tcx),
|
{infcx: infer::new_infer_ctxt(ccx.tcx),
|
||||||
locals: int_hash::<int>(),
|
locals: int_hash::<int>(),
|
||||||
nvi: @mutable 0}
|
nvi: @mut 0}
|
||||||
}
|
}
|
||||||
some(fcx) {
|
some(fcx) {
|
||||||
{infcx: fcx.infcx,
|
{infcx: fcx.infcx,
|
||||||
|
@ -2544,7 +2544,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||||
// const versions of the vectors in L and R. Next, let T be a
|
// const versions of the vectors in L and R. Next, let T be a
|
||||||
// fresh type variable where TL <: T and TR <: T. Then the result
|
// fresh type variable where TL <: T and TR <: T. Then the result
|
||||||
// type is a fresh type variable T1 where T1 <: [const T]. This
|
// type is a fresh type variable T1 where T1 <: [const T]. This
|
||||||
// allows the result to be either a mutable or immutable vector,
|
// allows the result to be either a mut or immutable vector,
|
||||||
// depending on external demands.
|
// depending on external demands.
|
||||||
let const_vec_t =
|
let const_vec_t =
|
||||||
ty::mk_vec(tcx, {ty: next_ty_var(fcx),
|
ty::mk_vec(tcx, {ty: next_ty_var(fcx),
|
||||||
|
@ -3370,7 +3370,7 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) {
|
||||||
proto: ast::proto_box,
|
proto: ast::proto_box,
|
||||||
infcx: infer::new_infer_ctxt(ccx.tcx),
|
infcx: infer::new_infer_ctxt(ccx.tcx),
|
||||||
locals: int_hash::<int>(),
|
locals: int_hash::<int>(),
|
||||||
next_var_id: @mutable 0,
|
next_var_id: @mut 0,
|
||||||
ccx: ccx};
|
ccx: ccx};
|
||||||
check_expr(fcx, e);
|
check_expr(fcx, e);
|
||||||
let cty = expr_ty(fcx.ccx.tcx, e);
|
let cty = expr_ty(fcx.ccx.tcx, e);
|
||||||
|
@ -3389,7 +3389,7 @@ fn check_enum_variants(ccx: @crate_ctxt, sp: span, vs: [ast::variant],
|
||||||
proto: ast::proto_box,
|
proto: ast::proto_box,
|
||||||
infcx: infer::new_infer_ctxt(ccx.tcx),
|
infcx: infer::new_infer_ctxt(ccx.tcx),
|
||||||
locals: int_hash::<int>(),
|
locals: int_hash::<int>(),
|
||||||
next_var_id: @mutable 0,
|
next_var_id: @mut 0,
|
||||||
ccx: ccx};
|
ccx: ccx};
|
||||||
let mut disr_vals: [int] = [];
|
let mut disr_vals: [int] = [];
|
||||||
let mut disr_val = 0;
|
let mut disr_val = 0;
|
||||||
|
@ -3950,7 +3950,7 @@ fn check_crate(tcx: ty::ctxt, impl_map: resolve::impl_map,
|
||||||
crate: @ast::crate) -> (method_map, vtable_map) {
|
crate: @ast::crate) -> (method_map, vtable_map) {
|
||||||
collect::collect_item_types(tcx, crate);
|
collect::collect_item_types(tcx, crate);
|
||||||
|
|
||||||
let ccx = @{mutable self_infos: [],
|
let ccx = @{mut self_infos: [],
|
||||||
impl_map: impl_map,
|
impl_map: impl_map,
|
||||||
method_map: std::map::int_hash(),
|
method_map: std::map::int_hash(),
|
||||||
vtable_map: std::map::int_hash(),
|
vtable_map: std::map::int_hash(),
|
||||||
|
|
|
@ -86,7 +86,7 @@ enum def {
|
||||||
// first def_id is for parent class
|
// first def_id is for parent class
|
||||||
def_class_field(def_id, def_id),
|
def_class_field(def_id, def_id),
|
||||||
// No purity allowed for now, I guess
|
// No purity allowed for now, I guess
|
||||||
// (simpler this way, b/c presumably methods read mutable state)
|
// (simpler this way, b/c presumably methods read mut state)
|
||||||
def_class_method(def_id, def_id),
|
def_class_method(def_id, def_id),
|
||||||
def_region(node_id)
|
def_region(node_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ enum file_substr {
|
||||||
|
|
||||||
type filemap =
|
type filemap =
|
||||||
@{name: filename, substr: file_substr, src: @str,
|
@{name: filename, substr: file_substr, src: @str,
|
||||||
start_pos: file_pos, mutable lines: [file_pos]};
|
start_pos: file_pos, mut lines: [file_pos]};
|
||||||
|
|
||||||
type codemap = @{mutable files: [filemap]};
|
type codemap = @{mut files: [filemap]};
|
||||||
|
|
||||||
type loc = {file: filemap, line: uint, col: uint};
|
type loc = {file: filemap, line: uint, col: uint};
|
||||||
|
|
||||||
fn new_codemap() -> codemap { @{mutable files: [] } }
|
fn new_codemap() -> codemap { @{mut files: [] } }
|
||||||
|
|
||||||
fn new_filemap_w_substr(filename: filename, substr: file_substr,
|
fn new_filemap_w_substr(filename: filename, substr: file_substr,
|
||||||
src: @str,
|
src: @str,
|
||||||
|
@ -30,7 +30,7 @@ fn new_filemap_w_substr(filename: filename, substr: file_substr,
|
||||||
-> filemap {
|
-> filemap {
|
||||||
ret @{name: filename, substr: substr, src: src,
|
ret @{name: filename, substr: substr, src: src,
|
||||||
start_pos: {ch: start_pos_ch, byte: start_pos_byte},
|
start_pos: {ch: start_pos_ch, byte: start_pos_byte},
|
||||||
mutable lines: [{ch: start_pos_ch, byte: start_pos_byte}]};
|
mut lines: [{ch: start_pos_ch, byte: start_pos_byte}]};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_filemap(filename: filename, src: @str,
|
fn new_filemap(filename: filename, src: @str,
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn mk_ctxt(session: driver::session::session,
|
||||||
type ctxt_repr = {session: driver::session::session,
|
type ctxt_repr = {session: driver::session::session,
|
||||||
parse_sess: parser::parse_sess,
|
parse_sess: parser::parse_sess,
|
||||||
cfg: ast::crate_cfg,
|
cfg: ast::crate_cfg,
|
||||||
mutable backtrace: expn_info};
|
mut backtrace: expn_info};
|
||||||
impl of ext_ctxt for ctxt_repr {
|
impl of ext_ctxt for ctxt_repr {
|
||||||
fn session() -> driver::session::session { self.session }
|
fn session() -> driver::session::session { self.session }
|
||||||
fn codemap() -> codemap { self.parse_sess.cm }
|
fn codemap() -> codemap { self.parse_sess.cm }
|
||||||
|
@ -122,7 +122,7 @@ fn mk_ctxt(session: driver::session::session,
|
||||||
session: session,
|
session: session,
|
||||||
parse_sess: parse_sess,
|
parse_sess: parse_sess,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
mutable backtrace: none
|
mut backtrace: none
|
||||||
};
|
};
|
||||||
ret imp as ext_ctxt
|
ret imp as ext_ctxt
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import io::*;
|
||||||
import codemap::span;
|
import codemap::span;
|
||||||
|
|
||||||
type aq_ctxt = @{lo: uint,
|
type aq_ctxt = @{lo: uint,
|
||||||
mutable gather: [{lo: uint, hi: uint,
|
mut gather: [{lo: uint, hi: uint,
|
||||||
e: @ast::expr,
|
e: @ast::expr,
|
||||||
constr: str}]};
|
constr: str}]};
|
||||||
enum fragment {
|
enum fragment {
|
||||||
|
@ -99,7 +99,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt
|
||||||
let v = @{visit_expr: visit_aq_expr,
|
let v = @{visit_expr: visit_aq_expr,
|
||||||
visit_ty: visit_aq_ty
|
visit_ty: visit_aq_ty
|
||||||
with *default_visitor()};
|
with *default_visitor()};
|
||||||
let cx = @{lo:lo, mutable gather: []};
|
let cx = @{lo:lo, mut gather: []};
|
||||||
node.visit(cx, mk_vt(v));
|
node.visit(cx, mk_vt(v));
|
||||||
// FIXME: Maybe this is an overkill (merge_sort), it might be better
|
// FIXME: Maybe this is an overkill (merge_sort), it might be better
|
||||||
// to just keep the gather array in sorted order ...
|
// to just keep the gather array in sorted order ...
|
||||||
|
|
|
@ -136,7 +136,7 @@ fn compose_sels(s1: selector, s2: selector) -> selector {
|
||||||
|
|
||||||
type binders =
|
type binders =
|
||||||
{real_binders: hashmap<ident, selector>,
|
{real_binders: hashmap<ident, selector>,
|
||||||
mutable literal_ast_matchers: [selector]};
|
mut literal_ast_matchers: [selector]};
|
||||||
type bindings = hashmap<ident, arb_depth<matchable>>;
|
type bindings = hashmap<ident, arb_depth<matchable>>;
|
||||||
|
|
||||||
fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
|
fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
|
||||||
|
@ -148,7 +148,7 @@ fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
|
||||||
fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
|
fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
|
||||||
let res: binders =
|
let res: binders =
|
||||||
{real_binders: str_hash::<selector>(),
|
{real_binders: str_hash::<selector>(),
|
||||||
mutable literal_ast_matchers: []};
|
mut literal_ast_matchers: []};
|
||||||
//this oughta return binders instead, but macro args are a sequence of
|
//this oughta return binders instead, but macro args are a sequence of
|
||||||
//expressions, rather than a single expression
|
//expressions, rather than a single expression
|
||||||
fn trivial_selector(m: matchable) -> match_result { ret some(leaf(m)); }
|
fn trivial_selector(m: matchable) -> match_result { ret some(leaf(m)); }
|
||||||
|
@ -183,7 +183,7 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> {
|
||||||
/* use the bindings on the body to generate the expanded code */
|
/* use the bindings on the body to generate the expanded code */
|
||||||
|
|
||||||
fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr {
|
fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr {
|
||||||
let idx_path: @mutable [uint] = @mutable [];
|
let idx_path: @mut [uint] = @mut [];
|
||||||
fn new_id(_old: node_id, cx: ext_ctxt) -> node_id { ret cx.next_id(); }
|
fn new_id(_old: node_id, cx: ext_ctxt) -> node_id { ret cx.next_id(); }
|
||||||
fn new_span(cx: ext_ctxt, sp: span) -> span {
|
fn new_span(cx: ext_ctxt, sp: span) -> span {
|
||||||
/* this discards information in the case of macro-defining macros */
|
/* this discards information in the case of macro-defining macros */
|
||||||
|
@ -208,7 +208,7 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr {
|
||||||
|
|
||||||
|
|
||||||
/* helper: descend into a matcher */
|
/* helper: descend into a matcher */
|
||||||
fn follow(m: arb_depth<matchable>, idx_path: @mutable [uint]) ->
|
fn follow(m: arb_depth<matchable>, idx_path: @mut [uint]) ->
|
||||||
arb_depth<matchable> {
|
arb_depth<matchable> {
|
||||||
let mut res: arb_depth<matchable> = m;
|
let mut res: arb_depth<matchable> = m;
|
||||||
for idx: uint in *idx_path {
|
for idx: uint in *idx_path {
|
||||||
|
@ -221,7 +221,7 @@ fn follow(m: arb_depth<matchable>, idx_path: @mutable [uint]) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>,
|
fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>,
|
||||||
idx_path: @mutable [uint]) -> option<matchable> {
|
idx_path: @mut [uint]) -> option<matchable> {
|
||||||
alt mmaybe {
|
alt mmaybe {
|
||||||
none { ret none }
|
none { ret none }
|
||||||
some(m) {
|
some(m) {
|
||||||
|
@ -258,7 +258,7 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) {
|
||||||
|
|
||||||
|
|
||||||
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
|
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
|
||||||
fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
|
||||||
recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
|
recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
|
||||||
alt elts_to_ell(cx, exprs) {
|
alt elts_to_ell(cx, exprs) {
|
||||||
{pre: pre, rep: repeat_me_maybe, post: post} {
|
{pre: pre, rep: repeat_me_maybe, post: post} {
|
||||||
|
@ -320,7 +320,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||||
|
|
||||||
|
|
||||||
// substitute, in a position that's required to be an ident
|
// substitute, in a position that's required to be an ident
|
||||||
fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
|
||||||
&&i: ident, _fld: ast_fold) -> ident {
|
&&i: ident, _fld: ast_fold) -> ident {
|
||||||
ret alt follow_for_trans(cx, b.find(i), idx_path) {
|
ret alt follow_for_trans(cx, b.find(i), idx_path) {
|
||||||
some(match_ident(a_id)) { a_id.node }
|
some(match_ident(a_id)) { a_id.node }
|
||||||
|
@ -330,7 +330,7 @@ fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
|
||||||
p: path_, s:span, _fld: ast_fold) -> (path_, span) {
|
p: path_, s:span, _fld: ast_fold) -> (path_, span) {
|
||||||
// Don't substitute into qualified names.
|
// Don't substitute into qualified names.
|
||||||
if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { ret (p, s); }
|
if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { ret (p, s); }
|
||||||
|
@ -345,7 +345,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
|
||||||
e: ast::expr_, s: span, fld: ast_fold,
|
e: ast::expr_, s: span, fld: ast_fold,
|
||||||
orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span))
|
orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span))
|
||||||
-> (ast::expr_, span)
|
-> (ast::expr_, span)
|
||||||
|
@ -373,7 +373,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
|
||||||
t: ast::ty_, s: span, fld: ast_fold,
|
t: ast::ty_, s: span, fld: ast_fold,
|
||||||
orig: fn@(ast::ty_, span, ast_fold) -> (ast::ty_, span))
|
orig: fn@(ast::ty_, span, ast_fold) -> (ast::ty_, span))
|
||||||
-> (ast::ty_, span)
|
-> (ast::ty_, span)
|
||||||
|
@ -399,7 +399,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||||
/* for parsing reasons, syntax variables bound to blocks must be used like
|
/* for parsing reasons, syntax variables bound to blocks must be used like
|
||||||
`{v}` */
|
`{v}` */
|
||||||
|
|
||||||
fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
|
||||||
blk: blk_, s: span, fld: ast_fold,
|
blk: blk_, s: span, fld: ast_fold,
|
||||||
orig: fn@(blk_, span, ast_fold) -> (blk_, span))
|
orig: fn@(blk_, span, ast_fold) -> (blk_, span))
|
||||||
-> (blk_, span)
|
-> (blk_, span)
|
||||||
|
|
|
@ -15,7 +15,7 @@ export noop_fold_block;
|
||||||
export wrap;
|
export wrap;
|
||||||
export fold_ty_param;
|
export fold_ty_param;
|
||||||
|
|
||||||
type ast_fold = @mutable a_f;
|
type ast_fold = @mut a_f;
|
||||||
|
|
||||||
// We may eventually want to be able to fold over type parameters, too
|
// We may eventually want to be able to fold over type parameters, too
|
||||||
|
|
||||||
|
@ -602,9 +602,9 @@ fn default_ast_fold() -> @ast_fold_precursor {
|
||||||
|
|
||||||
fn make_fold(afp: ast_fold_precursor) -> ast_fold {
|
fn make_fold(afp: ast_fold_precursor) -> ast_fold {
|
||||||
// FIXME: Have to bind all the bare functions into shared functions
|
// FIXME: Have to bind all the bare functions into shared functions
|
||||||
// because @mutable is invariant with respect to its contents
|
// because @mut is invariant with respect to its contents
|
||||||
let result: ast_fold =
|
let result: ast_fold =
|
||||||
@mutable {fold_crate: bind nf_crate_dummy(_),
|
@mut {fold_crate: bind nf_crate_dummy(_),
|
||||||
fold_crate_directive: bind nf_crate_directive_dummy(_),
|
fold_crate_directive: bind nf_crate_directive_dummy(_),
|
||||||
fold_view_item: bind nf_view_item_dummy(_),
|
fold_view_item: bind nf_view_item_dummy(_),
|
||||||
fold_native_item: bind nf_native_item_dummy(_),
|
fold_native_item: bind nf_native_item_dummy(_),
|
||||||
|
|
|
@ -8,11 +8,11 @@ type reader = @{
|
||||||
span_diagnostic: diagnostic::span_handler,
|
span_diagnostic: diagnostic::span_handler,
|
||||||
src: @str,
|
src: @str,
|
||||||
len: uint,
|
len: uint,
|
||||||
mutable col: uint,
|
mut col: uint,
|
||||||
mutable pos: uint,
|
mut pos: uint,
|
||||||
mutable curr: char,
|
mut curr: char,
|
||||||
mutable chpos: uint,
|
mut chpos: uint,
|
||||||
mutable strs: [str],
|
mut strs: [str],
|
||||||
filemap: codemap::filemap,
|
filemap: codemap::filemap,
|
||||||
interner: @interner::interner<str>
|
interner: @interner::interner<str>
|
||||||
};
|
};
|
||||||
|
@ -63,8 +63,8 @@ fn new_reader(cm: codemap::codemap,
|
||||||
let r = @{cm: cm,
|
let r = @{cm: cm,
|
||||||
span_diagnostic: span_diagnostic,
|
span_diagnostic: span_diagnostic,
|
||||||
src: filemap.src, len: str::len(*filemap.src),
|
src: filemap.src, len: str::len(*filemap.src),
|
||||||
mutable col: 0u, mutable pos: 0u, mutable curr: -1 as char,
|
mut col: 0u, mut pos: 0u, mut curr: -1 as char,
|
||||||
mutable chpos: filemap.start_pos.ch, mutable strs: [],
|
mut chpos: filemap.start_pos.ch, mut strs: [],
|
||||||
filemap: filemap, interner: itr};
|
filemap: filemap, interner: itr};
|
||||||
if r.pos < r.len {
|
if r.pos < r.len {
|
||||||
let next = str::char_range_at(*r.src, r.pos);
|
let next = str::char_range_at(*r.src, r.pos);
|
||||||
|
|
|
@ -21,11 +21,11 @@ enum file_type { CRATE_FILE, SOURCE_FILE, }
|
||||||
|
|
||||||
type parse_sess = @{
|
type parse_sess = @{
|
||||||
cm: codemap::codemap,
|
cm: codemap::codemap,
|
||||||
mutable next_id: node_id,
|
mut next_id: node_id,
|
||||||
span_diagnostic: diagnostic::span_handler,
|
span_diagnostic: diagnostic::span_handler,
|
||||||
// these two must be kept up to date
|
// these two must be kept up to date
|
||||||
mutable chpos: uint,
|
mut chpos: uint,
|
||||||
mutable byte_pos: uint
|
mut byte_pos: uint
|
||||||
};
|
};
|
||||||
|
|
||||||
fn next_node_id(sess: parse_sess) -> node_id {
|
fn next_node_id(sess: parse_sess) -> node_id {
|
||||||
|
@ -40,11 +40,11 @@ type parser = @{
|
||||||
sess: parse_sess,
|
sess: parse_sess,
|
||||||
cfg: ast::crate_cfg,
|
cfg: ast::crate_cfg,
|
||||||
file_type: file_type,
|
file_type: file_type,
|
||||||
mutable token: token::token,
|
mut token: token::token,
|
||||||
mutable span: span,
|
mut span: span,
|
||||||
mutable last_span: span,
|
mut last_span: span,
|
||||||
mutable buffer: [{tok: token::token, span: span}],
|
mut buffer: [{tok: token::token, span: span}],
|
||||||
mutable restriction: restriction,
|
mut restriction: restriction,
|
||||||
reader: reader,
|
reader: reader,
|
||||||
precs: @[op_spec],
|
precs: @[op_spec],
|
||||||
bad_expr_words: hashmap<str, ()>
|
bad_expr_words: hashmap<str, ()>
|
||||||
|
@ -130,11 +130,11 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader,
|
||||||
@{sess: sess,
|
@{sess: sess,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
file_type: ftype,
|
file_type: ftype,
|
||||||
mutable token: tok0.tok,
|
mut token: tok0.tok,
|
||||||
mutable span: span0,
|
mut span: span0,
|
||||||
mutable last_span: span0,
|
mut last_span: span0,
|
||||||
mutable buffer: [],
|
mut buffer: [],
|
||||||
mutable restriction: UNRESTRICTED,
|
mut restriction: UNRESTRICTED,
|
||||||
reader: rdr,
|
reader: rdr,
|
||||||
precs: prec_table(),
|
precs: prec_table(),
|
||||||
bad_expr_words: bad_expr_word_table()}
|
bad_expr_words: bad_expr_word_table()}
|
||||||
|
@ -149,7 +149,7 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
|
||||||
"class", "const", "cont", "copy", "crust", "do", "else",
|
"class", "const", "cont", "copy", "crust", "do", "else",
|
||||||
"enum", "export", "fail", "fn", "for", "if", "iface",
|
"enum", "export", "fail", "fn", "for", "if", "iface",
|
||||||
"impl", "import", "let", "log", "loop", "mod", "mut",
|
"impl", "import", "let", "log", "loop", "mod", "mut",
|
||||||
"mutable", "native", "pure", "resource", "ret", "trait",
|
"mut", "native", "pure", "resource", "ret", "trait",
|
||||||
"type", "unchecked", "unsafe", "while", "new"] {
|
"type", "unchecked", "unsafe", "while", "new"] {
|
||||||
words.insert(word, ());
|
words.insert(word, ());
|
||||||
}
|
}
|
||||||
|
@ -735,7 +735,7 @@ fn parse_path_and_ty_param_substs(p: parser, colons: bool) -> @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, "mut") {
|
||||||
ast::m_mutbl
|
ast::m_mutbl
|
||||||
} else if eat_word(p, "mut") {
|
} else if eat_word(p, "mut") {
|
||||||
ast::m_mutbl
|
ast::m_mutbl
|
||||||
|
@ -831,7 +831,7 @@ fn parse_bottom_expr(p: parser) -> pexpr {
|
||||||
ret mk_pexpr(p, lo, hi, ast::expr_tup(es));
|
ret mk_pexpr(p, lo, hi, ast::expr_tup(es));
|
||||||
} else if p.token == token::LBRACE {
|
} else if p.token == token::LBRACE {
|
||||||
p.bump();
|
p.bump();
|
||||||
if is_word(p, "mut") || is_word(p, "mutable") ||
|
if is_word(p, "mut") ||
|
||||||
is_plain_ident(p) && p.look_ahead(1u) == token::COLON {
|
is_plain_ident(p) && p.look_ahead(1u) == token::COLON {
|
||||||
let mut fields = [parse_field(p, token::COLON)];
|
let mut fields = [parse_field(p, token::COLON)];
|
||||||
let mut base = none;
|
let mut base = none;
|
||||||
|
@ -1660,7 +1660,7 @@ fn parse_let(p: parser) -> @ast::decl {
|
||||||
fn parse_instance_var(p:parser) -> (ast::class_member, codemap::span) {
|
fn parse_instance_var(p:parser) -> (ast::class_member, codemap::span) {
|
||||||
let mut is_mutbl = ast::class_immutable;
|
let mut is_mutbl = ast::class_immutable;
|
||||||
let lo = p.span.lo;
|
let lo = p.span.lo;
|
||||||
if eat_word(p, "mut") || eat_word(p, "mutable") {
|
if eat_word(p, "mut") {
|
||||||
is_mutbl = ast::class_mutable;
|
is_mutbl = ast::class_mutable;
|
||||||
}
|
}
|
||||||
if !is_plain_ident(p) {
|
if !is_plain_ident(p) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ fn tok_str(t: token) -> str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn buf_str(toks: [mutable token], szs: [mutable int], left: uint, right: uint,
|
fn buf_str(toks: [mut token], szs: [mut int], left: uint, right: uint,
|
||||||
lim: uint) -> str {
|
lim: uint) -> str {
|
||||||
let n = vec::len(toks);
|
let n = vec::len(toks);
|
||||||
assert (n == vec::len(szs));
|
assert (n == vec::len(szs));
|
||||||
|
@ -99,26 +99,26 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
|
||||||
// fall behind.
|
// fall behind.
|
||||||
let n: uint = 3u * linewidth;
|
let n: uint = 3u * linewidth;
|
||||||
#debug("mk_printer %u", linewidth);
|
#debug("mk_printer %u", linewidth);
|
||||||
let token: [mutable token] = vec::to_mut(vec::from_elem(n, EOF));
|
let token: [mut token] = vec::to_mut(vec::from_elem(n, EOF));
|
||||||
let size: [mutable int] = vec::to_mut(vec::from_elem(n, 0));
|
let size: [mut int] = vec::to_mut(vec::from_elem(n, 0));
|
||||||
let scan_stack: [mutable uint] = vec::to_mut(vec::from_elem(n, 0u));
|
let scan_stack: [mut uint] = vec::to_mut(vec::from_elem(n, 0u));
|
||||||
let print_stack: [print_stack_elt] = [];
|
let print_stack: [print_stack_elt] = [];
|
||||||
@{out: out,
|
@{out: out,
|
||||||
buf_len: n,
|
buf_len: n,
|
||||||
mutable margin: linewidth as int,
|
mut margin: linewidth as int,
|
||||||
mutable space: linewidth as int,
|
mut space: linewidth as int,
|
||||||
mutable left: 0u,
|
mut left: 0u,
|
||||||
mutable right: 0u,
|
mut right: 0u,
|
||||||
mutable token: token,
|
mut token: token,
|
||||||
mutable size: size,
|
mut size: size,
|
||||||
mutable left_total: 0,
|
mut left_total: 0,
|
||||||
mutable right_total: 0,
|
mut right_total: 0,
|
||||||
mutable scan_stack: scan_stack,
|
mut scan_stack: scan_stack,
|
||||||
mutable scan_stack_empty: true,
|
mut scan_stack_empty: true,
|
||||||
mutable top: 0u,
|
mut top: 0u,
|
||||||
mutable bottom: 0u,
|
mut bottom: 0u,
|
||||||
mutable print_stack: print_stack,
|
mut print_stack: print_stack,
|
||||||
mutable pending_indentation: 0}
|
mut pending_indentation: 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,28 +202,28 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
|
||||||
type printer = @{
|
type printer = @{
|
||||||
out: io::writer,
|
out: io::writer,
|
||||||
buf_len: uint,
|
buf_len: uint,
|
||||||
mutable margin: int, // width of lines we're constrained to
|
mut margin: int, // width of lines we're constrained to
|
||||||
mutable space: int, // number of spaces left on line
|
mut space: int, // number of spaces left on line
|
||||||
mutable left: uint, // index of left side of input stream
|
mut left: uint, // index of left side of input stream
|
||||||
mutable right: uint, // index of right side of input stream
|
mut right: uint, // index of right side of input stream
|
||||||
mutable token: [mutable token], // ring-buffr stream goes through
|
mut token: [mut token], // ring-buffr stream goes through
|
||||||
mutable size: [mutable int], // ring-buffer of calculated sizes
|
mut size: [mut int], // ring-buffer of calculated sizes
|
||||||
mutable left_total: int, // running size of stream "...left"
|
mut left_total: int, // running size of stream "...left"
|
||||||
mutable right_total: int, // running size of stream "...right"
|
mut right_total: int, // running size of stream "...right"
|
||||||
// pseudo-stack, really a ring too. Holds the
|
// pseudo-stack, really a ring too. Holds the
|
||||||
// primary-ring-buffers index of the BEGIN that started the
|
// primary-ring-buffers index of the BEGIN that started the
|
||||||
// current block, possibly with the most recent BREAK after that
|
// current block, possibly with the most recent BREAK after that
|
||||||
// BEGIN (if there is any) on top of it. Stuff is flushed off the
|
// BEGIN (if there is any) on top of it. Stuff is flushed off the
|
||||||
// bottom as it becomes irrelevant due to the primary ring-buffer
|
// bottom as it becomes irrelevant due to the primary ring-buffer
|
||||||
// advancing.
|
// advancing.
|
||||||
mutable scan_stack: [mutable uint],
|
mut scan_stack: [mut uint],
|
||||||
mutable scan_stack_empty: bool, // top==bottom disambiguator
|
mut scan_stack_empty: bool, // top==bottom disambiguator
|
||||||
mutable top: uint, // index of top of scan_stack
|
mut top: uint, // index of top of scan_stack
|
||||||
mutable bottom: uint, // index of bottom of scan_stack
|
mut bottom: uint, // index of bottom of scan_stack
|
||||||
// stack of blocks-in-progress being flushed by print
|
// stack of blocks-in-progress being flushed by print
|
||||||
mutable print_stack: [print_stack_elt],
|
mut print_stack: [print_stack_elt],
|
||||||
// buffered indentation to avoid writing trailing whitespace
|
// buffered indentation to avoid writing trailing whitespace
|
||||||
mutable pending_indentation: int
|
mut pending_indentation: int
|
||||||
};
|
};
|
||||||
|
|
||||||
impl printer for printer {
|
impl printer for printer {
|
||||||
|
|
|
@ -24,9 +24,9 @@ type ps =
|
||||||
cm: option<codemap>,
|
cm: option<codemap>,
|
||||||
comments: option<[lexer::cmnt]>,
|
comments: option<[lexer::cmnt]>,
|
||||||
literals: option<[lexer::lit]>,
|
literals: option<[lexer::lit]>,
|
||||||
mutable cur_cmnt: uint,
|
mut cur_cmnt: uint,
|
||||||
mutable cur_lit: uint,
|
mut cur_lit: uint,
|
||||||
mutable boxes: [pp::breaks],
|
mut boxes: [pp::breaks],
|
||||||
ann: pp_ann};
|
ann: pp_ann};
|
||||||
|
|
||||||
fn ibox(s: ps, u: uint) { s.boxes += [pp::inconsistent]; pp::ibox(s.s, u); }
|
fn ibox(s: ps, u: uint) { s.boxes += [pp::inconsistent]; pp::ibox(s.s, u); }
|
||||||
|
@ -39,9 +39,9 @@ fn rust_printer(writer: io::writer) -> ps {
|
||||||
cm: none::<codemap>,
|
cm: none::<codemap>,
|
||||||
comments: none::<[lexer::cmnt]>,
|
comments: none::<[lexer::cmnt]>,
|
||||||
literals: none::<[lexer::lit]>,
|
literals: none::<[lexer::lit]>,
|
||||||
mutable cur_cmnt: 0u,
|
mut cur_cmnt: 0u,
|
||||||
mutable cur_lit: 0u,
|
mut cur_lit: 0u,
|
||||||
mutable boxes: boxes,
|
mut boxes: boxes,
|
||||||
ann: no_ann()};
|
ann: no_ann()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ fn print_crate(cm: codemap, span_diagnostic: diagnostic::span_handler,
|
||||||
cm: some(cm),
|
cm: some(cm),
|
||||||
comments: some(r.cmnts),
|
comments: some(r.cmnts),
|
||||||
literals: some(r.lits),
|
literals: some(r.lits),
|
||||||
mutable cur_cmnt: 0u,
|
mut cur_cmnt: 0u,
|
||||||
mutable cur_lit: 0u,
|
mut cur_lit: 0u,
|
||||||
mutable boxes: boxes,
|
mut boxes: boxes,
|
||||||
ann: ann};
|
ann: ann};
|
||||||
print_crate_(s, crate);
|
print_crate_(s, crate);
|
||||||
}
|
}
|
||||||
|
@ -518,7 +518,7 @@ fn print_item(s: ps, &&item: @ast::item) {
|
||||||
ast::instance_var(nm, t, mt, _) {
|
ast::instance_var(nm, t, mt, _) {
|
||||||
word_nbsp(s, "let");
|
word_nbsp(s, "let");
|
||||||
alt mt {
|
alt mt {
|
||||||
ast::class_mutable { word_nbsp(s, "mutable"); }
|
ast::class_mutable { word_nbsp(s, "mut"); }
|
||||||
_ {}
|
_ {}
|
||||||
}
|
}
|
||||||
word(s.s, nm);
|
word(s.s, nm);
|
||||||
|
@ -818,7 +818,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
word(s.s, "[");
|
word(s.s, "[");
|
||||||
if mutbl == ast::m_mutbl {
|
if mutbl == ast::m_mutbl {
|
||||||
word(s.s, "mutable");
|
word(s.s, "mut");
|
||||||
if vec::len(exprs) > 0u { nbsp(s); }
|
if vec::len(exprs) > 0u { nbsp(s); }
|
||||||
}
|
}
|
||||||
commasep_exprs(s, inconsistent, exprs);
|
commasep_exprs(s, inconsistent, exprs);
|
||||||
|
@ -828,7 +828,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||||
ast::expr_rec(fields, wth) {
|
ast::expr_rec(fields, wth) {
|
||||||
fn print_field(s: ps, field: ast::field) {
|
fn print_field(s: ps, field: ast::field) {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mutable"); }
|
if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mut"); }
|
||||||
word(s.s, field.node.ident);
|
word(s.s, field.node.ident);
|
||||||
word_space(s, ":");
|
word_space(s, ":");
|
||||||
print_expr(s, field.node.expr);
|
print_expr(s, field.node.expr);
|
||||||
|
@ -1135,7 +1135,7 @@ fn print_decl(s: ps, decl: @ast::decl) {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
word_nbsp(s, "let");
|
word_nbsp(s, "let");
|
||||||
|
|
||||||
// if any are mutable, all are mutable
|
// if any are mut, all are mut
|
||||||
if vec::any(locs) {|l| l.node.is_mutbl } {
|
if vec::any(locs) {|l| l.node.is_mutbl } {
|
||||||
assert vec::all(locs) {|l| l.node.is_mutbl };
|
assert vec::all(locs) {|l| l.node.is_mutbl };
|
||||||
word_nbsp(s, "mut");
|
word_nbsp(s, "mut");
|
||||||
|
@ -1493,7 +1493,7 @@ fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: int) {
|
||||||
|
|
||||||
fn print_mutability(s: ps, mutbl: ast::mutability) {
|
fn print_mutability(s: ps, mutbl: ast::mutability) {
|
||||||
alt mutbl {
|
alt mutbl {
|
||||||
ast::m_mutbl { word_nbsp(s, "mutable"); }
|
ast::m_mutbl { word_nbsp(s, "mut"); }
|
||||||
ast::m_const { word_nbsp(s, "const"); }
|
ast::m_const { word_nbsp(s, "const"); }
|
||||||
ast::m_imm {/* nothing */ }
|
ast::m_imm {/* nothing */ }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ import std::map::{hashmap, hashfn, eqfn};
|
||||||
|
|
||||||
type interner<T> =
|
type interner<T> =
|
||||||
{map: hashmap<T, uint>,
|
{map: hashmap<T, uint>,
|
||||||
mutable vect: [T],
|
mut vect: [T],
|
||||||
hasher: hashfn<T>,
|
hasher: hashfn<T>,
|
||||||
eqer: eqfn<T>};
|
eqer: eqfn<T>};
|
||||||
|
|
||||||
fn mk<T: copy>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
|
fn mk<T: copy>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
|
||||||
let m = map::hashmap::<T, uint>(hasher, eqer);
|
let m = map::hashmap::<T, uint>(hasher, eqer);
|
||||||
ret {map: m, mutable vect: [], hasher: hasher, eqer: eqer};
|
ret {map: m, mut vect: [], hasher: hasher, eqer: eqer};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern<T: copy>(itr: interner<T>, val: T) -> uint {
|
fn intern<T: copy>(itr: interner<T>, val: T) -> uint {
|
||||||
|
|
|
@ -68,8 +68,8 @@ fn log_stmt_err(st: ast::stmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_nonlocal_exits(b: ast::blk) -> bool {
|
fn has_nonlocal_exits(b: ast::blk) -> bool {
|
||||||
let has_exits = @mutable false;
|
let has_exits = @mut false;
|
||||||
fn visit_expr(flag: @mutable bool, e: @ast::expr) {
|
fn visit_expr(flag: @mut bool, e: @ast::expr) {
|
||||||
alt e.node {
|
alt e.node {
|
||||||
ast::expr_break { *flag = true; }
|
ast::expr_break { *flag = true; }
|
||||||
ast::expr_cont { *flag = true; }
|
ast::expr_cont { *flag = true; }
|
||||||
|
@ -85,8 +85,8 @@ fn has_nonlocal_exits(b: ast::blk) -> bool {
|
||||||
|
|
||||||
/* FIXME: copy/paste, yuck */
|
/* FIXME: copy/paste, yuck */
|
||||||
fn may_break(b: ast::blk) -> bool {
|
fn may_break(b: ast::blk) -> bool {
|
||||||
let has_exits = @mutable false;
|
let has_exits = @mut false;
|
||||||
fn visit_expr(flag: @mutable bool, e: @ast::expr) {
|
fn visit_expr(flag: @mut bool, e: @ast::expr) {
|
||||||
alt e.node {
|
alt e.node {
|
||||||
ast::expr_break { *flag = true; }
|
ast::expr_break { *flag = true; }
|
||||||
_ { }
|
_ { }
|
||||||
|
|
|
@ -104,7 +104,7 @@ fn exec<T:send>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_ctxt(sess: session::session, ast: @ast::crate,
|
fn build_ctxt(sess: session::session, ast: @ast::crate,
|
||||||
ignore_errors: @mutable bool) -> ctxt {
|
ignore_errors: @mut bool) -> ctxt {
|
||||||
|
|
||||||
import rustc::front::config;
|
import rustc::front::config;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ fn build_ctxt(sess: session::session, ast: @ast::crate,
|
||||||
|
|
||||||
// FIXME: this whole structure should not be duplicated here. makes it
|
// FIXME: this whole structure should not be duplicated here. makes it
|
||||||
// painful to add or remove options.
|
// painful to add or remove options.
|
||||||
fn build_session() -> (session::session, @mutable bool) {
|
fn build_session() -> (session::session, @mut bool) {
|
||||||
let sopts: @session::options = @{
|
let sopts: @session::options = @{
|
||||||
crate_type: session::lib_crate,
|
crate_type: session::lib_crate,
|
||||||
static: false,
|
static: false,
|
||||||
|
@ -163,7 +163,7 @@ fn build_session() -> (session::session, @mutable bool) {
|
||||||
type error_handlers = {
|
type error_handlers = {
|
||||||
emitter: diagnostic::emitter,
|
emitter: diagnostic::emitter,
|
||||||
span_handler: diagnostic::span_handler,
|
span_handler: diagnostic::span_handler,
|
||||||
ignore_errors: @mutable bool
|
ignore_errors: @mut bool
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build a custom error handler that will allow us to ignore non-fatal
|
// Build a custom error handler that will allow us to ignore non-fatal
|
||||||
|
@ -174,7 +174,7 @@ fn build_error_handlers(
|
||||||
|
|
||||||
type diagnostic_handler = {
|
type diagnostic_handler = {
|
||||||
inner: diagnostic::handler,
|
inner: diagnostic::handler,
|
||||||
ignore_errors: @mutable bool
|
ignore_errors: @mut bool
|
||||||
};
|
};
|
||||||
|
|
||||||
impl of diagnostic::handler for diagnostic_handler {
|
impl of diagnostic::handler for diagnostic_handler {
|
||||||
|
@ -197,7 +197,7 @@ fn build_error_handlers(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ignore_errors = @mutable false;
|
let ignore_errors = @mut false;
|
||||||
let emitter = fn@(cmsp: option<(codemap::codemap, codemap::span)>,
|
let emitter = fn@(cmsp: option<(codemap::codemap, codemap::span)>,
|
||||||
msg: str, lvl: diagnostic::level) {
|
msg: str, lvl: diagnostic::level) {
|
||||||
if !(*ignore_errors) {
|
if !(*ignore_errors) {
|
||||||
|
|
|
@ -29,10 +29,10 @@ mod test {
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
let parse_sess = @{
|
let parse_sess = @{
|
||||||
cm: cm,
|
cm: cm,
|
||||||
mutable next_id: 0,
|
mut next_id: 0,
|
||||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
};
|
};
|
||||||
let parser = parser::new_parser_from_source_str(
|
let parser = parser::new_parser_from_source_str(
|
||||||
parse_sess, [], "-", codemap::fss_none, @source);
|
parse_sess, [], "-", codemap::fss_none, @source);
|
||||||
|
|
|
@ -14,10 +14,10 @@ fn new_parse_sess() -> parser::parse_sess {
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
let sess = @{
|
let sess = @{
|
||||||
cm: cm,
|
cm: cm,
|
||||||
mutable next_id: 1,
|
mut next_id: 1,
|
||||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
mutable chpos: 0u,
|
mut chpos: 0u,
|
||||||
mutable byte_pos: 0u
|
mut byte_pos: 0u
|
||||||
};
|
};
|
||||||
ret sess;
|
ret sess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ fn mk_pass() -> pass {
|
||||||
|
|
||||||
type ctxt = {
|
type ctxt = {
|
||||||
srv: astsrv::srv,
|
srv: astsrv::srv,
|
||||||
mutable path: [str]
|
mut path: [str]
|
||||||
};
|
};
|
||||||
|
|
||||||
fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
fn run(srv: astsrv::srv, doc: doc::doc) -> doc::doc {
|
||||||
let ctxt = {
|
let ctxt = {
|
||||||
srv: srv,
|
srv: srv,
|
||||||
mutable path: []
|
mut path: []
|
||||||
};
|
};
|
||||||
let fold = fold::fold({
|
let fold = fold::fold({
|
||||||
fold_item: fold_item,
|
fold_item: fold_item,
|
||||||
|
|
BIN
src/rustdoc/rustdoc
Executable file
BIN
src/rustdoc/rustdoc
Executable file
Binary file not shown.
|
@ -2,7 +2,7 @@ mod kitties {
|
||||||
|
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
let how_hungry : int;
|
let how_hungry : int;
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod kitties {
|
||||||
|
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
let how_hungry : int;
|
let how_hungry : int;
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod kitties {
|
||||||
|
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
let how_hungry : int;
|
let how_hungry : int;
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod kitties {
|
||||||
|
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
fn meow() {
|
fn meow() {
|
||||||
#error("Meow");
|
#error("Meow");
|
||||||
meows += 1u;
|
meows += 1u;
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod kitties {
|
||||||
|
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
fn nap() { uint::range(1u, 10000u) {|_i|}}
|
fn nap() { uint::range(1u, 10000u) {|_i|}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import str;
|
||||||
|
|
||||||
fn LINE_LENGTH() -> uint { ret 60u; }
|
fn LINE_LENGTH() -> uint { ret 60u; }
|
||||||
|
|
||||||
type myrandom = @{mutable last: u32};
|
type myrandom = @{mut last: u32};
|
||||||
|
|
||||||
fn myrandom_next(r: myrandom, mx: u32) -> u32 {
|
fn myrandom_next(r: myrandom, mx: u32) -> u32 {
|
||||||
r.last = (r.last * 3877u32 + 29573u32) % 139968u32;
|
r.last = (r.last * 3877u32 + 29573u32) % 139968u32;
|
||||||
|
@ -44,7 +44,7 @@ fn select_random(r: u32, genelist: [aminoacids]) -> char {
|
||||||
|
|
||||||
fn make_random_fasta(id: str, desc: str, genelist: [aminoacids], n: int) {
|
fn make_random_fasta(id: str, desc: str, genelist: [aminoacids], n: int) {
|
||||||
log(debug, ">" + id + " " + desc);
|
log(debug, ">" + id + " " + desc);
|
||||||
let rng = @{mutable last: std::rand::rng().next()};
|
let rng = @{mut last: std::rand::rng().next()};
|
||||||
let mut op: str = "";
|
let mut op: str = "";
|
||||||
uint::range(0u, n as uint) {|_i|
|
uint::range(0u, n as uint) {|_i|
|
||||||
str::push_char(op, select_random(myrandom_next(rng, 100u32),
|
str::push_char(op, select_random(myrandom_next(rng, 100u32),
|
||||||
|
|
|
@ -136,61 +136,61 @@ mod Body {
|
||||||
const DAYS_PER_YEAR: float = 365.24;
|
const DAYS_PER_YEAR: float = 365.24;
|
||||||
|
|
||||||
type props =
|
type props =
|
||||||
{mutable x: float,
|
{mut x: float,
|
||||||
mutable y: float,
|
mut y: float,
|
||||||
mutable z: float,
|
mut z: float,
|
||||||
mutable vx: float,
|
mut vx: float,
|
||||||
mutable vy: float,
|
mut vy: float,
|
||||||
mutable vz: float,
|
mut vz: float,
|
||||||
mass: float};
|
mass: float};
|
||||||
|
|
||||||
fn jupiter() -> Body::props {
|
fn jupiter() -> Body::props {
|
||||||
ret {mutable x: 4.84143144246472090e+00,
|
ret {mut x: 4.84143144246472090e+00,
|
||||||
mutable y: -1.16032004402742839e+00,
|
mut y: -1.16032004402742839e+00,
|
||||||
mutable z: -1.03622044471123109e-01,
|
mut z: -1.03622044471123109e-01,
|
||||||
mutable vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
|
mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
|
||||||
mutable vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
|
mut vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
|
||||||
mutable vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
|
mut vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
|
||||||
mass: 9.54791938424326609e-04 * SOLAR_MASS};
|
mass: 9.54791938424326609e-04 * SOLAR_MASS};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn saturn() -> Body::props {
|
fn saturn() -> Body::props {
|
||||||
ret {mutable x: 8.34336671824457987e+00,
|
ret {mut x: 8.34336671824457987e+00,
|
||||||
mutable y: 4.12479856412430479e+00,
|
mut y: 4.12479856412430479e+00,
|
||||||
mutable z: -4.03523417114321381e-01,
|
mut z: -4.03523417114321381e-01,
|
||||||
mutable vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
|
mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
|
||||||
mutable vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
|
mut vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
|
||||||
mutable vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
|
mut vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
|
||||||
mass: 2.85885980666130812e-04 * SOLAR_MASS};
|
mass: 2.85885980666130812e-04 * SOLAR_MASS};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uranus() -> Body::props {
|
fn uranus() -> Body::props {
|
||||||
ret {mutable x: 1.28943695621391310e+01,
|
ret {mut x: 1.28943695621391310e+01,
|
||||||
mutable y: -1.51111514016986312e+01,
|
mut y: -1.51111514016986312e+01,
|
||||||
mutable z: -2.23307578892655734e-01,
|
mut z: -2.23307578892655734e-01,
|
||||||
mutable vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
|
mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
|
||||||
mutable vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
|
mut vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
|
||||||
mutable vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
|
mut vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
|
||||||
mass: 4.36624404335156298e-05 * SOLAR_MASS};
|
mass: 4.36624404335156298e-05 * SOLAR_MASS};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn neptune() -> Body::props {
|
fn neptune() -> Body::props {
|
||||||
ret {mutable x: 1.53796971148509165e+01,
|
ret {mut x: 1.53796971148509165e+01,
|
||||||
mutable y: -2.59193146099879641e+01,
|
mut y: -2.59193146099879641e+01,
|
||||||
mutable z: 1.79258772950371181e-01,
|
mut z: 1.79258772950371181e-01,
|
||||||
mutable vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
|
mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
|
||||||
mutable vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
|
mut vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
|
||||||
mutable vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
|
mut vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
|
||||||
mass: 5.15138902046611451e-05 * SOLAR_MASS};
|
mass: 5.15138902046611451e-05 * SOLAR_MASS};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sun() -> Body::props {
|
fn sun() -> Body::props {
|
||||||
ret {mutable x: 0.0,
|
ret {mut x: 0.0,
|
||||||
mutable y: 0.0,
|
mut y: 0.0,
|
||||||
mutable z: 0.0,
|
mut z: 0.0,
|
||||||
mutable vx: 0.0,
|
mut vx: 0.0,
|
||||||
mutable vy: 0.0,
|
mut vy: 0.0,
|
||||||
mutable vz: 0.0,
|
mut vz: 0.0,
|
||||||
mass: SOLAR_MASS};
|
mass: SOLAR_MASS};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn eval_A(i: uint, j: uint) -> float {
|
||||||
1.0/(((i+j)*(i+j+1u)/2u+i+1u) as float)
|
1.0/(((i+j)*(i+j+1u)/2u+i+1u) as float)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_A_times_u(u: [const float], Au: [mutable float]) {
|
fn eval_A_times_u(u: [const float], Au: [mut float]) {
|
||||||
let N = vec::len(u);
|
let N = vec::len(u);
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < N {
|
while i < N {
|
||||||
|
@ -20,7 +20,7 @@ fn eval_A_times_u(u: [const float], Au: [mutable float]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_At_times_u(u: [const float], Au: [mutable float]) {
|
fn eval_At_times_u(u: [const float], Au: [mut float]) {
|
||||||
let N = vec::len(u);
|
let N = vec::len(u);
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
while i < N {
|
while i < N {
|
||||||
|
@ -34,7 +34,7 @@ fn eval_At_times_u(u: [const float], Au: [mutable float]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_AtA_times_u(u: [const float], AtAu: [mutable float]) {
|
fn eval_AtA_times_u(u: [const float], AtAu: [mut float]) {
|
||||||
let v = vec::to_mut(vec::from_elem(vec::len(u), 0.0));
|
let v = vec::to_mut(vec::from_elem(vec::len(u), 0.0));
|
||||||
eval_A_times_u(u, v);
|
eval_A_times_u(u, v);
|
||||||
eval_At_times_u(v, AtAu);
|
eval_At_times_u(v, AtAu);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import io::{writer_util, reader_util};
|
||||||
export grid_t, read_grid, solve_grid, write_grid;
|
export grid_t, read_grid, solve_grid, write_grid;
|
||||||
|
|
||||||
// internal type of sudoku grids
|
// internal type of sudoku grids
|
||||||
type grid = [[mutable u8]];
|
type grid = [[mut u8]];
|
||||||
|
|
||||||
// exported type of sudoku grids
|
// exported type of sudoku grids
|
||||||
enum grid_t { grid_ctor(grid), }
|
enum grid_t { grid_ctor(grid), }
|
||||||
|
|
|
@ -103,10 +103,10 @@ mod map_reduce {
|
||||||
|
|
||||||
send(out, chan(p));
|
send(out, chan(p));
|
||||||
|
|
||||||
let state = @{mutable ref_count: 0, mutable is_done: false};
|
let state = @{mut ref_count: 0, mut is_done: false};
|
||||||
|
|
||||||
fn get(p: port<reduce_proto>, state: @{mutable ref_count: int,
|
fn get(p: port<reduce_proto>, state: @{mut ref_count: int,
|
||||||
mutable is_done: bool})
|
mut is_done: bool})
|
||||||
-> option<int> {
|
-> option<int> {
|
||||||
while !state.is_done || state.ref_count > 0 {
|
while !state.is_done || state.ref_count > 0 {
|
||||||
alt recv(p) {
|
alt recv(p) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// error-pattern:assigning to immutable field
|
// error-pattern:assigning to immutable field
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
let how_hungry : int;
|
let how_hungry : int;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// error-pattern: mismatched types
|
// error-pattern: mismatched types
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let v = @mutable [0];
|
let v = @mut [0];
|
||||||
|
|
||||||
fn f(&&v: @mutable [const int]) {
|
fn f(&&v: @mut [const int]) {
|
||||||
*v = [mutable 3]
|
*v = [mut 3]
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v);
|
f(v);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// error-pattern: mismatched types
|
// error-pattern: mismatched types
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let v = [mutable @mutable ~mutable [0]];
|
let v = [mut @mut ~mut [0]];
|
||||||
|
|
||||||
fn f(&&v: [mutable @mutable ~mutable [const int]]) {
|
fn f(&&v: [mut @mut ~mut [const int]]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v);
|
f(v);
|
||||||
|
|
|
@ -4,11 +4,11 @@ use std;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = [0];
|
let a = [0];
|
||||||
let v: *mutable [int] = ptr::mut_addr_of(a);
|
let v: *mut [int] = ptr::mut_addr_of(a);
|
||||||
|
|
||||||
fn f(&&v: *mutable [const int]) {
|
fn f(&&v: *mut [const int]) {
|
||||||
unsafe {
|
unsafe {
|
||||||
*v = [mutable 3]
|
*v = [mut 3]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// error-pattern: mismatched types
|
// error-pattern: mismatched types
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let v = {mutable g: [0]};
|
let v = {mut g: [0]};
|
||||||
|
|
||||||
fn f(&&v: {mutable g: [const int]}) {
|
fn f(&&v: {mut g: [const int]}) {
|
||||||
v.g = [mutable 3]
|
v.g = [mut 3]
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v);
|
f(v);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// error-pattern: mismatched types
|
// error-pattern: mismatched types
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let v = ~mutable [0];
|
let v = ~mut [0];
|
||||||
|
|
||||||
fn f(&&v: ~mutable [const int]) {
|
fn f(&&v: ~mut [const int]) {
|
||||||
*v = [mutable 3]
|
*v = [mut 3]
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v);
|
f(v);
|
||||||
|
|
|
@ -2,10 +2,10 @@ fn main() {
|
||||||
// Note: explicit type annot is required here
|
// Note: explicit type annot is required here
|
||||||
// because otherwise the inference gets smart
|
// because otherwise the inference gets smart
|
||||||
// and assigns a type of [mut [const int]].
|
// and assigns a type of [mut [const int]].
|
||||||
let v: [mut [int]] = [mutable [0]];
|
let v: [mut [int]] = [mut [0]];
|
||||||
|
|
||||||
fn f(&&v: [mutable [const int]]) {
|
fn f(&&v: [mut [const int]]) {
|
||||||
v[0] = [mutable 3]
|
v[0] = [mut 3]
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v); //! ERROR (values differ in mutability)
|
f(v); //! ERROR (values differ in mutability)
|
||||||
|
|
|
@ -2,9 +2,9 @@ fn main() {
|
||||||
// Note: explicit type annot is required here
|
// Note: explicit type annot is required here
|
||||||
// because otherwise the inference gets smart
|
// because otherwise the inference gets smart
|
||||||
// and assigns a type of [mut [const int]].
|
// and assigns a type of [mut [const int]].
|
||||||
let v: [mut [mut int]] = [mutable [mutable 0]];
|
let v: [mut [mut int]] = [mut [mut 0]];
|
||||||
|
|
||||||
fn f(&&v: [mutable [const int]]) {
|
fn f(&&v: [mut [const int]]) {
|
||||||
v[0] = [3]
|
v[0] = [3]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@ fn main() {
|
||||||
// Note: explicit type annot is required here
|
// Note: explicit type annot is required here
|
||||||
// because otherwise the inference gets smart
|
// because otherwise the inference gets smart
|
||||||
// and assigns a type of [mut [const int]].
|
// and assigns a type of [mut [const int]].
|
||||||
let v: [mut[mut[int]]] = [mutable [mutable [0]]];
|
let v: [mut[mut[int]]] = [mut [mut [0]]];
|
||||||
|
|
||||||
fn f(&&v: [mutable [mutable [const int]]]) {
|
fn f(&&v: [mut [mut [const int]]]) {
|
||||||
v[0][1] = [mutable 3]
|
v[0][1] = [mut 3]
|
||||||
}
|
}
|
||||||
|
|
||||||
f(v); //! ERROR (values differ in mutability)
|
f(v); //! ERROR (values differ in mutability)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// error-pattern: copying a noncopyable value
|
// error-pattern: copying a noncopyable value
|
||||||
|
|
||||||
resource r(i: @mutable int) {
|
resource r(i: @mut int) {
|
||||||
*i = *i + 1;
|
*i = *i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let i = @mutable 0;
|
let i = @mut 0;
|
||||||
{
|
{
|
||||||
// Can't do this copy
|
// Can't do this copy
|
||||||
let x = ~~~{y: r(i)};
|
let x = ~~~{y: r(i)};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// error-pattern:no public field or method with that name
|
// error-pattern:no public field or method with that name
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
let how_hungry : int;
|
let how_hungry : int;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// error-pattern:attempted access of field nap on type
|
// error-pattern:attempted access of field nap on type
|
||||||
class cat {
|
class cat {
|
||||||
priv {
|
priv {
|
||||||
let mutable meows : uint;
|
let mut meows : uint;
|
||||||
fn nap() { uint::range(1u, 10000u) {|_i|}}
|
fn nap() { uint::range(1u, 10000u) {|_i|}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue