File tree Expand file tree Collapse file tree 9 files changed +39
-23
lines changed
trunk/src/test/compile-fail Expand file tree Collapse file tree 9 files changed +39
-23
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 14e3fdea9c0a4e9669d4c918af84b6306aca0123
2
+ refs/heads/master: 6e2aa3b9986e1534ccdd2e12303b89507c579b00
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
1
// test that autoderef of a type like this does not
2
2
// cause compiler to loop. Note that no instances
3
3
// of such a type could ever be constructed.
4
- resource t( x: x) { } //! ERROR this type cannot be instantiated
5
- enum x = @t; //! ERROR this type cannot be instantiated
6
-
7
- fn new_t ( x : t ) {
8
- x. to_str ; //! ERROR attempted access of field to_str
4
+ class t { //! ERROR this type cannot be instantiated
5
+ let x: x;
6
+ let to_str: ( ) ;
7
+ new ( x: x) { self . x = x; self . to_str = ( ) ; }
9
8
}
9
+ enum x = @t; //! ERROR this type cannot be instantiated
10
10
11
11
fn main ( ) {
12
12
}
Original file line number Diff line number Diff line change 2
2
3
3
fn foo < T : const > ( _x : T ) { }
4
4
5
- resource r( _x: int) { }
6
- resource r2( _x: @mut int) { }
5
+ class r {
6
+ let x: int;
7
+ new ( x: int) { self . x = x; }
8
+ drop { }
9
+ }
10
+
11
+ class r2 {
12
+ let x: @mut int;
13
+ new ( x: @mut int) { self . x = x; }
14
+ drop { }
15
+ }
7
16
8
17
fn main ( ) {
9
18
foo ( { f: 3 } ) ;
Original file line number Diff line number Diff line change 1
1
// error-pattern: copying a noncopyable value
2
2
3
- resource r( i: @mut int) {
4
- * i = * i + 1 ;
3
+ class r {
4
+ let i: @mut int;
5
+ new ( i: @mut int) { self . i = i; }
6
+ drop { * ( self . i ) = * ( self . i ) + 1 ; }
5
7
}
6
8
7
9
fn main ( ) {
Original file line number Diff line number Diff line change 1
1
// error-pattern: copying a noncopyable value
2
2
3
- resource my_resource ( x: int) {
4
- log ( error, x) ;
3
+ class my_resource {
4
+ let x: int;
5
+ new ( x: int) { self . x = x; }
6
+ drop { log( error, self . x ) ; }
5
7
}
6
8
7
9
fn main ( ) {
Original file line number Diff line number Diff line change 5
5
enum an_enum /& { }
6
6
iface an_iface/& { }
7
7
class a_class/& { new ( ) { } }
8
- resource a_rsrc/& ( _x : ( ) ) { }
9
8
10
9
fn a_fn1( e: an_enum/& a) -> an_enum/& b {
11
10
ret e; //! ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
@@ -19,11 +18,7 @@ fn a_fn3(e: a_class/&a) -> a_class/&b {
19
18
ret e; //! ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
20
19
}
21
20
22
- fn a_fn4 ( e : a_rsrc/& a ) -> a_rsrc/& b {
23
- ret e; //! ERROR mismatched types: expected `a_rsrc/&b` but found `a_rsrc/&a`
24
- }
25
-
26
- fn a_fn5 ( e : int/& a ) -> int/& b {
21
+ fn a_fn4( e: int/& a) -> int/& b {
27
22
//!^ ERROR Region parameters are not allowed on this type.
28
23
//!^^ ERROR Region parameters are not allowed on this type.
29
24
ret e;
Original file line number Diff line number Diff line change 1
1
// error-pattern: copying a noncopyable value
2
2
3
- resource r( b: bool) {
3
+ class r {
4
+ let b: bool;
5
+ new ( b: bool) { self . b = b; }
6
+ drop { }
4
7
}
5
8
6
9
fn main ( ) {
Original file line number Diff line number Diff line change 1
1
// error-pattern: copying a noncopyable value
2
2
3
- resource r( i: @mut int) {
4
- * i = * i + 1 ;
3
+ class r {
4
+ let i: @mut int;
5
+ new ( i: @mut int) { self . i = i; }
6
+ drop { * ( self . i ) = * ( self . i ) + 1 ; }
5
7
}
6
8
7
9
fn f < T > ( +i : [ T ] , +j : [ T ] ) {
Original file line number Diff line number Diff line change 1
1
// error-pattern: copying a noncopyable value
2
2
3
- resource r( _i: int) { }
3
+ class r {
4
+ new( _i : int) { }
5
+ drop { }
6
+ }
4
7
5
8
fn main ( ) {
6
- // This can't make sense as it would copy the resources
9
+ // This can't make sense as it would copy the classes
7
10
let i <- [ r ( 0 ) ] ;
8
11
let j <- [ r ( 1 ) ] ;
9
12
let k = i + j;
You can’t perform that action at this time.
0 commit comments