File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
trunk/src/test/compile-fail Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: bd6e6e349bd97c1f2b552124620f3a7f7332ed68
2
+ refs/heads/master: ee5d0f5e3f1681a67452b5301958474343b90c51
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments