Skip to content

Commit 9320aa3

Browse files
committed
---
yaml --- r: 6295 b: refs/heads/master c: b655fb9 h: refs/heads/master i: 6293: 440ce81 6291: f55ad72 6287: f3f88a8 v: v3
1 parent 9641130 commit 9320aa3

24 files changed

+54
-55
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 1d361f680610bb0f75f80b8fc8ca03d04b13577b
2+
refs/heads/master: b655fb9ea7d81d03cf049ae32babda19003631e5

trunk/src/comp/syntax/parse/parser.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,7 @@ fn parse_path_and_ty_param_substs(p: parser) -> ast::path {
746746

747747
fn parse_mutability(p: parser) -> ast::mutability {
748748
if eat_word(p, "mutable") {
749-
if p.peek() == token::QUES { p.bump(); ast::maybe_mut }
750-
else { ast::mut }
749+
ast::mut
751750
} else if eat_word(p, "const") {
752751
ast::maybe_mut
753752
} else {

trunk/src/comp/syntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: int) {
13071307
fn print_mutability(s: ps, mut: ast::mutability) {
13081308
alt mut {
13091309
ast::mut. { word_nbsp(s, "mutable"); }
1310-
ast::maybe_mut. { word_nbsp(s, "mutable?"); }
1310+
ast::maybe_mut. { word_nbsp(s, "const"); }
13111311
ast::imm. {/* nothing */ }
13121312
}
13131313
}

trunk/src/comp/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
8484
alt m.mut {
8585
ast::mut. { mstr = "mutable "; }
8686
ast::imm. { mstr = ""; }
87-
ast::maybe_mut. { mstr = "mutable? "; }
87+
ast::maybe_mut. { mstr = "const "; }
8888
}
8989
ret mstr + ty_to_str(cx, m.ty);
9090
}

trunk/src/lib/io.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn file_reader(path: str) -> result::t<reader, str> {
188188

189189
// Byte buffer readers
190190

191-
// TODO: mutable? u8, but this fails with rustboot.
191+
// TODO: const u8, but this fails with rustboot.
192192
type byte_buf = @{buf: [u8], mutable pos: uint};
193193

194194
obj byte_buf_reader(bbuf: byte_buf) {

trunk/src/lib/list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Function: from_vec
2525
2626
Create a list from a vector
2727
*/
28-
fn from_vec<T>(v: [mutable? T]) -> list<T> {
28+
fn from_vec<T>(v: [const T]) -> list<T> {
2929
*vec::foldr({ |h, t| @cons(h, t) }, @nil::<T>, v)
3030
}
3131

trunk/src/lib/sort.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Merge sort. Returns a new vector containing the sorted list.
2020
Has worst case O(n log n) performance, best case O(n), but
2121
is not space efficient. This is a stable sort.
2222
*/
23-
fn merge_sort<T>(le: lteq<T>, v: [mutable? T]) -> [T] {
23+
fn merge_sort<T>(le: lteq<T>, v: [const T]) -> [T] {
2424
fn merge<T>(le: lteq<T>, a: [T], b: [T]) -> [T] {
2525
let rs: [T] = [];
2626
let a_len: uint = len::<T>(a);

trunk/src/lib/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Function: unsafe_from_bytes
189189
Converts a vector of bytes to a string. Does not verify that the
190190
vector contains valid UTF-8.
191191
*/
192-
fn unsafe_from_bytes(v: [mutable? u8]) -> str unsafe {
192+
fn unsafe_from_bytes(v: [const u8]) -> str unsafe {
193193
let vcopy: [u8] = v + [0u8];
194194
let scopy: str = unsafe::reinterpret_cast(vcopy);
195195
unsafe::leak(vcopy);

trunk/src/lib/ufind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn set_count(ufnd: ufind) -> uint { ret vec::len::<node>(ufnd.nodes); }
4444

4545
// Removes all sets with IDs greater than or equal to the given value.
4646
fn prune(ufnd: ufind, n: uint) {
47-
// TODO: Use "slice" once we get rid of "mutable?"
47+
// TODO: Use "slice" once we get rid of "const"
4848

4949
let len = vec::len::<node>(ufnd.nodes);
5050
while len != n { vec::pop::<node>(ufnd.nodes); len -= 1u; }

trunk/src/lib/vec.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import ptr::addr_of;
88

99
#[abi = "rust-intrinsic"]
1010
native mod rusti {
11-
fn vec_len<T>(&&v: [mutable? T]) -> uint;
11+
fn vec_len<T>(&&v: [const T]) -> uint;
1212
}
1313

1414
#[abi = "cdecl"]
1515
native mod rustrt {
1616
fn vec_reserve_shared<T>(t: *sys::type_desc,
17-
&v: [mutable? T],
17+
&v: [const T],
1818
n: uint);
1919
fn vec_from_buf_shared<T>(t: *sys::type_desc,
2020
ptr: *T,
@@ -34,7 +34,7 @@ Predicate: is_empty
3434
3535
Returns true if a vector contains no elements.
3636
*/
37-
pure fn is_empty<T>(v: [mutable? T]) -> bool {
37+
pure fn is_empty<T>(v: [const T]) -> bool {
3838
// FIXME: This would be easier if we could just call len
3939
for t: T in v { ret false; }
4040
ret true;
@@ -45,7 +45,7 @@ Predicate: is_not_empty
4545
4646
Returns true if a vector contains some elements.
4747
*/
48-
pure fn is_not_empty<T>(v: [mutable? T]) -> bool { ret !is_empty(v); }
48+
pure fn is_not_empty<T>(v: [const T]) -> bool { ret !is_empty(v); }
4949

5050
/*
5151
Predicate: same_length
@@ -69,7 +69,7 @@ Parameters:
6969
v - A vector
7070
n - The number of elements to reserve space for
7171
*/
72-
fn reserve<T>(&v: [mutable? T], n: uint) {
72+
fn reserve<T>(&v: [const T], n: uint) {
7373
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(), v, n);
7474
}
7575

@@ -78,7 +78,7 @@ Function: len
7878
7979
Returns the length of a vector
8080
*/
81-
pure fn len<T>(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } }
81+
pure fn len<T>(v: [const T]) -> uint { unchecked { rusti::vec_len(v) } }
8282

8383
/*
8484
Function: init_fn
@@ -181,7 +181,7 @@ Returns the first element of a vector
181181
Predicates:
182182
<is_not_empty> (v)
183183
*/
184-
fn head<T>(v: [mutable? T]) : is_not_empty(v) -> T { ret v[0]; }
184+
fn head<T>(v: [const T]) : is_not_empty(v) -> T { ret v[0]; }
185185

186186
/*
187187
Function: tail
@@ -191,7 +191,7 @@ Returns all but the first element of a vector
191191
Predicates:
192192
<is_not_empty> (v)
193193
*/
194-
fn tail<T>(v: [mutable? T]) : is_not_empty(v) -> [T] {
194+
fn tail<T>(v: [const T]) : is_not_empty(v) -> [T] {
195195
ret slice(v, 1u, len(v));
196196
}
197197

@@ -206,7 +206,7 @@ Returns all but the last elemnt of a vector
206206
Preconditions:
207207
`v` is not empty
208208
*/
209-
fn init<T>(v: [mutable? T]) -> [T] {
209+
fn init<T>(v: [const T]) -> [T] {
210210
assert len(v) != 0u;
211211
slice(v, 0u, len(v) - 1u)
212212
}
@@ -221,7 +221,7 @@ Returns:
221221
An option containing the last element of `v` if `v` is not empty, or
222222
none if `v` is empty.
223223
*/
224-
fn last<T>(v: [mutable? T]) -> option::t<T> {
224+
fn last<T>(v: [const T]) -> option::t<T> {
225225
if len(v) == 0u { ret none; }
226226
ret some(v[len(v) - 1u]);
227227
}
@@ -234,7 +234,7 @@ Returns the last element of a non-empty vector `v`
234234
Predicates:
235235
<is_not_empty> (v)
236236
*/
237-
fn last_total<T>(v: [mutable? T]) : is_not_empty(v) -> T {
237+
fn last_total<T>(v: [const T]) : is_not_empty(v) -> T {
238238
ret v[len(v) - 1u];
239239
}
240240

@@ -243,7 +243,7 @@ Function: slice
243243
244244
Returns a copy of the elements from [`start`..`end`) from `v`.
245245
*/
246-
fn slice<T>(v: [mutable? T], start: uint, end: uint) -> [T] {
246+
fn slice<T>(v: [const T], start: uint, end: uint) -> [T] {
247247
assert (start <= end);
248248
assert (end <= len(v));
249249
let result = [];
@@ -259,7 +259,7 @@ Function: slice_mut
259259
260260
Returns a copy of the elements from [`start`..`end`) from `v`.
261261
*/
262-
fn slice_mut<T>(v: [mutable? T], start: uint, end: uint) -> [mutable T] {
262+
fn slice_mut<T>(v: [const T], start: uint, end: uint) -> [mutable T] {
263263
assert (start <= end);
264264
assert (end <= len(v));
265265
let result = [mutable];
@@ -277,7 +277,7 @@ Function: shift
277277
278278
Removes the first element from a vector and return it
279279
*/
280-
fn shift<T>(&v: [mutable? T]) -> T {
280+
fn shift<T>(&v: [const T]) -> T {
281281
let ln = len::<T>(v);
282282
assert (ln > 0u);
283283
let e = v[0];
@@ -291,7 +291,7 @@ Function: pop
291291
292292
Remove the last element from a vector and return it
293293
*/
294-
fn pop<T>(&v: [mutable? T]) -> T {
294+
fn pop<T>(&v: [const T]) -> T {
295295
let ln = len(v);
296296
assert (ln > 0u);
297297
ln -= 1u;
@@ -323,7 +323,7 @@ fn grow<T>(&v: [T], n: uint, initval: T) {
323323
}
324324

325325
// TODO: Remove me once we have slots.
326-
// FIXME: Can't grow take a [mutable? T]
326+
// FIXME: Can't grow take a [const T]
327327
/*
328328
Function: grow_mut
329329
@@ -384,7 +384,7 @@ Function: map
384384
385385
Apply a function to each element of a vector and return the results
386386
*/
387-
fn map<T, U>(f: block(T) -> U, v: [mutable? T]) -> [U] {
387+
fn map<T, U>(f: block(T) -> U, v: [const T]) -> [U] {
388388
let result = [];
389389
reserve(result, len(v));
390390
for elem: T in v {
@@ -416,7 +416,7 @@ Apply a function to each element of a vector and return the results
416416
If function `f` returns `none` then that element is excluded from
417417
the resulting vector.
418418
*/
419-
fn filter_map<T, U>(f: block(T) -> option::t<U>, v: [mutable? T]) -> [U] {
419+
fn filter_map<T, U>(f: block(T) -> option::t<U>, v: [const T]) -> [U] {
420420
let result = [];
421421
for elem: T in v {
422422
let elem2 = elem; // satisfies alias checker
@@ -437,7 +437,7 @@ holds.
437437
Apply function `f` to each element of `v` and return a vector containing
438438
only those elements for which `f` returned true.
439439
*/
440-
fn filter<T>(f: block(T) -> bool, v: [mutable? T]) -> [T] {
440+
fn filter<T>(f: block(T) -> bool, v: [const T]) -> [T] {
441441
let result = [];
442442
for elem: T in v {
443443
let elem2 = elem; // satisfies alias checker
@@ -454,7 +454,7 @@ Function: concat
454454
Concatenate a vector of vectors. Flattens a vector of vectors of T into
455455
a single vector of T.
456456
*/
457-
fn concat<T>(v: [mutable? [mutable? T]]) -> [T] {
457+
fn concat<T>(v: [const [const T]]) -> [T] {
458458
// FIXME: So much copying
459459
let new: [T] = [];
460460
for inner: [T] in v { new += inner; }
@@ -466,7 +466,7 @@ Function: foldl
466466
467467
Reduce a vector from left to right
468468
*/
469-
fn foldl<T, U>(p: block(T, U) -> T, z: T, v: [mutable? U]) -> T {
469+
fn foldl<T, U>(p: block(T, U) -> T, z: T, v: [const U]) -> T {
470470
let accum = z;
471471
iter(v) { |elt|
472472
accum = p(accum, elt);
@@ -479,7 +479,7 @@ Function: foldr
479479
480480
Reduce a vector from right to left
481481
*/
482-
fn foldr<T, U>(p: block(T, U) -> U, z: U, v: [mutable? T]) -> U {
482+
fn foldr<T, U>(p: block(T, U) -> U, z: U, v: [const T]) -> U {
483483
let accum = z;
484484
riter(v) { |elt|
485485
accum = p(elt, accum);
@@ -526,7 +526,7 @@ Function: count
526526
527527
Returns the number of elements that are equal to a given value
528528
*/
529-
fn count<T>(x: T, v: [mutable? T]) -> uint {
529+
fn count<T>(x: T, v: [const T]) -> uint {
530530
let cnt = 0u;
531531
for elt: T in v { if x == elt { cnt += 1u; } }
532532
ret cnt;
@@ -646,7 +646,7 @@ Function: reversed
646646
647647
Returns a vector with the order of elements reversed
648648
*/
649-
fn reversed<T>(v: [mutable? T]) -> [T] {
649+
fn reversed<T>(v: [const T]) -> [T] {
650650
let rs: [T] = [];
651651
let i = len::<T>(v);
652652
if i == 0u { ret rs; } else { i -= 1u; }
@@ -690,7 +690,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the
690690
element's value.
691691
692692
*/
693-
fn iter<T>(v: [mutable? T], f: block(T)) {
693+
fn iter<T>(v: [const T], f: block(T)) {
694694
iter2(v) { |_i, v| f(v) }
695695
}
696696

@@ -702,7 +702,7 @@ Iterates over a vector's elements and indexes
702702
Iterates over vector `v` and, for each element, calls function `f` with the
703703
element's value and index.
704704
*/
705-
fn iter2<T>(v: [mutable? T], f: block(uint, T)) {
705+
fn iter2<T>(v: [const T], f: block(uint, T)) {
706706
let i = 0u;
707707
for x in v { f(i, x); i += 1u; }
708708
}
@@ -716,7 +716,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the
716716
element's value.
717717
718718
*/
719-
fn riter<T>(v: [mutable? T], f: block(T)) {
719+
fn riter<T>(v: [const T], f: block(T)) {
720720
riter2(v) { |_i, v| f(v) }
721721
}
722722

@@ -728,7 +728,7 @@ Iterates over a vector's elements and indexes in reverse
728728
Iterates over vector `v` and, for each element, calls function `f` with the
729729
element's value and index.
730730
*/
731-
fn riter2<T>(v: [mutable? T], f: block(uint, T)) {
731+
fn riter2<T>(v: [const T], f: block(uint, T)) {
732732
let i = len(v);
733733
while 0u < i {
734734
i -= 1u;
@@ -746,7 +746,7 @@ is sorted then the permutations are lexicographically sorted).
746746
The total number of permutations produced is `len(v)!`. If `v` contains
747747
repeated elements, then some permutations are repeated.
748748
*/
749-
fn permute<T>(v: [mutable? T], put: block([T])) {
749+
fn permute<T>(v: [const T], put: block([T])) {
750750
let ln = len(v);
751751
if ln == 0u {
752752
put([]);
@@ -798,7 +798,7 @@ mod unsafe {
798798
modifing its buffers, so it is up to the caller to ensure that
799799
the vector is actually the specified size.
800800
*/
801-
unsafe fn set_len<T>(&v: [mutable? T], new_len: uint) {
801+
unsafe fn set_len<T>(&v: [const T], new_len: uint) {
802802
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
803803
(**repr).fill = new_len * sys::size_of::<T>();
804804
}
@@ -814,7 +814,7 @@ mod unsafe {
814814
Modifying the vector may cause its buffer to be reallocated, which
815815
would also make any pointers to it invalid.
816816
*/
817-
unsafe fn to_ptr<T>(v: [mutable? T]) -> *T {
817+
unsafe fn to_ptr<T>(v: [const T]) -> *T {
818818
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
819819
ret ::unsafe::reinterpret_cast(addr_of((**repr).data));
820820
}

trunk/src/test/compile-fail/mutable-huh-box-assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// error-pattern: assigning to immutable box
22

33
fn main() {
4-
fn f(&&v: @mutable? int) {
4+
fn f(&&v: @const int) {
55
// This shouldn't be possible
66
*v = 1
77
}

trunk/src/test/compile-fail/mutable-huh-field-assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// error-pattern: assigning to immutable field
22

33
fn main() {
4-
fn f(&&v: {mutable? field: int}) {
4+
fn f(&&v: {const field: int}) {
55
// This shouldn't be possible
66
v.field = 1
77
}

trunk/src/test/compile-fail/mutable-huh-ptr-assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std;
44

55
fn main() {
6-
unsafe fn f(&&v: *mutable? int) {
6+
unsafe fn f(&&v: *const int) {
77
// This shouldn't be possible
88
*v = 1
99
}

trunk/src/test/compile-fail/mutable-huh-unique-assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// error-pattern: assigning to immutable box
22

33
fn main() {
4-
fn f(&&v: ~mutable? int) {
4+
fn f(&&v: ~const int) {
55
// This shouldn't be possible
66
*v = 1
77
}

trunk/src/test/compile-fail/mutable-huh-variance-box.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
fn main() {
44
let v = @mutable [0];
55

6-
fn f(&&v: @mutable [mutable? int]) {
6+
fn f(&&v: @mutable [const int]) {
77
*v = [mutable 3]
88
}
99

0 commit comments

Comments
 (0)