Skip to content

Commit 04d6ae9

Browse files
committed
---
yaml --- r: 54536 b: refs/heads/snap-stage3 c: f678d63 h: refs/heads/master v: v3
1 parent a4ff82c commit 04d6ae9

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 28f0782260ca2e83edd79aeb37888be3e45d23b1
4+
refs/heads/snap-stage3: f678d63507a779d81810c342dd1bdc828fb983ba
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,28 @@ let mut d = @mut 5; // mutable variable, mutable box
10671067
d = @mut 15;
10681068
~~~~
10691069

1070+
A mutable variable and an immutable variable can refer to the same box, given
1071+
that their types are compatible. Mutability of a box is a property of its type,
1072+
however, so for example a mutable handle to an immutable box cannot be
1073+
assigned a reference to a mutable box.
1074+
1075+
~~~~
1076+
let a = @1; // immutable box
1077+
let b = @mut 2; // mutable box
1078+
1079+
let mut c : @int; // declare a variable with type managed immutable int
1080+
let mut d : @mut int; // and one of type managed mutable int
1081+
1082+
c = a; // box type is the same, okay
1083+
d = b; // box type is the same, okay
1084+
~~~~
1085+
1086+
~~~~ {.xfail-test}
1087+
// but b cannot be assigned to c, or a to d
1088+
c = b; // error
1089+
~~~~
1090+
1091+
10701092
# Move semantics
10711093

10721094
Rust uses a shallow copy for parameter passing, assignment and returning values
@@ -1081,6 +1103,16 @@ let y = x.clone(); // y is a newly allocated box
10811103
let z = x; // no new memory allocated, x can no longer be used
10821104
~~~~
10831105

1106+
Since in owned boxes mutability is a property of the owner, not the
1107+
box, mutable boxes may become immutable when they are moved, and vice-versa.
1108+
1109+
~~~~
1110+
let r = ~13;
1111+
let mut s = r; // box becomes mutable
1112+
*s += 1;
1113+
let t = s; // box becomes immutable
1114+
~~~~
1115+
10841116
# Borrowed pointers
10851117

10861118
Rust's borrowed pointers are a general purpose reference type. In contrast with

branches/snap-stage3/src/librust/rust.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static commands: &'static [Command<'static>] = &[
6464
Command{
6565
cmd: "run",
6666
action: Call(cmd_run),
67-
usage_line: "build a executable, and run it",
67+
usage_line: "build an executable, and run it",
6868
usage_full: UsgStr(
6969
"The run command is an shortcut for the command line \n\
7070
\"rustc <filename> -o <filestem>~ && ./<filestem>~\".\

branches/snap-stage3/src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str {
248248
pub fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str {
249249
match vs {
250250
ty::vstore_fixed(_) => {
251-
fmt!("[%s, .. %s]", ty, vstore_to_str(cx, vs))
251+
fmt!("[%s * %s]", ty, vstore_to_str(cx, vs))
252252
}
253253
ty::vstore_slice(_) => {
254254
fmt!("%s %s", vstore_to_str(cx, vs), ty)

branches/snap-stage3/src/test/compile-fail/issue-2149.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ impl<A> vec_monad<A> for ~[A] {
2222
}
2323
fn main() {
2424
["hi"].bind(|x| [x] );
25-
//~^ ERROR type `[&'static str, .. 1]` does not implement any method in scope named `bind`
25+
//~^ ERROR type `[&'static str * 1]` does not implement any method in scope named `bind`
2626
//~^^ ERROR Unconstrained region variable
2727
}

branches/snap-stage3/src/test/compile-fail/issue-4517.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ fn bar(int_param: int) {}
22

33
fn main() {
44
let foo: [u8, ..4] = [1u8, ..4u8];
5-
bar(foo); //~ ERROR mismatched types: expected `int` but found `[u8, .. 4]` (expected int but found vector)
5+
bar(foo); //~ ERROR mismatched types: expected `int` but found `[u8 * 4]` (expected int but found vector)
66
}

0 commit comments

Comments
 (0)