Skip to content

Commit df8d472

Browse files
committed
---
yaml --- r: 12107 b: refs/heads/master c: ee5d0f5 h: refs/heads/master i: 12105: 3bd498f 12103: fc2a02a v: v3
1 parent 6919195 commit df8d472

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: bd6e6e349bd97c1f2b552124620f3a7f7332ed68
2+
refs/heads/master: ee5d0f5e3f1681a67452b5301958474343b90c51
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
fn main() {
2+
3+
// Note: here we do not have any type annotations
4+
// but we do express conflicting requirements:
5+
6+
let v = [mut [0]];
7+
let w = [mut [mut 0]];
8+
let x = [mut [mut 0]];
9+
10+
fn f(&&v: [mut [int]]) {
11+
v[0] = [3]
12+
}
13+
14+
fn g(&&v: [const [const int]]) {
15+
}
16+
17+
fn h(&&v: [mut [mut int]]) {
18+
v[0] = [mut 3]
19+
}
20+
21+
fn i(&&v: [mut [const int]]) {
22+
v[0] = [mut 3]
23+
}
24+
25+
fn j(&&v: [[const int]]) {
26+
}
27+
28+
f(v);
29+
g(v);
30+
h(v); //! ERROR (values differ in mutability)
31+
i(v); //! ERROR (values differ in mutability)
32+
j(v); //! ERROR (values differ in mutability)
33+
34+
f(w); //! ERROR (values differ in mutability)
35+
g(w);
36+
h(w);
37+
i(w); //! ERROR (values differ in mutability)
38+
j(w); //! ERROR (values differ in mutability)
39+
40+
// Note that without adding f() or h() to the mix, it is valid for
41+
// x to have the type [mut [const int]], and thus we can safely
42+
// call g() and i() but not j():
43+
g(x);
44+
i(x);
45+
j(x); //! ERROR (values differ in mutability)
46+
}

0 commit comments

Comments
 (0)