File tree Expand file tree Collapse file tree 8 files changed +38
-22
lines changed
Expand file tree Collapse file tree 8 files changed +38
-22
lines changed Original file line number Diff line number Diff line change 11// test that autoderef of a type like this does not
22// cause compiler to loop. Note that no instances
33// 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 = ( ) ; }
98}
9+ enum x = @t; //! ERROR this type cannot be instantiated
1010
1111fn main ( ) {
1212}
Original file line number Diff line number Diff line change 22
33fn foo < T : const > ( _x : T ) { }
44
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+ }
716
817fn main ( ) {
918 foo ( { f: 3 } ) ;
Original file line number Diff line number Diff line change 11// error-pattern: copying a noncopyable value
22
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 ; }
57}
68
79fn main ( ) {
Original file line number Diff line number Diff line change 11// error-pattern: copying a noncopyable value
22
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 ) ; }
57}
68
79fn main ( ) {
Original file line number Diff line number Diff line change 55enum an_enum /& { }
66iface an_iface/& { }
77class a_class/& { new ( ) { } }
8- resource a_rsrc/& ( _x : ( ) ) { }
98
109fn a_fn1( e: an_enum/& a) -> an_enum/& b {
1110 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 {
1918 ret e; //! ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
2019}
2120
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 {
2722 //!^ ERROR Region parameters are not allowed on this type.
2823 //!^^ ERROR Region parameters are not allowed on this type.
2924 ret e;
Original file line number Diff line number Diff line change 11// error-pattern: copying a noncopyable value
22
3- resource r( b: bool) {
3+ class r {
4+ let b: bool;
5+ new ( b: bool) { self . b = b; }
6+ drop { }
47}
58
69fn main ( ) {
Original file line number Diff line number Diff line change 11// error-pattern: copying a noncopyable value
22
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 ; }
57}
68
79fn f < T > ( +i : [ T ] , +j : [ T ] ) {
Original file line number Diff line number Diff line change 11// error-pattern: copying a noncopyable value
22
3- resource r( _i: int) { }
3+ class r {
4+ new( _i : int) { }
5+ drop { }
6+ }
47
58fn 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
710 let i <- [ r ( 0 ) ] ;
811 let j <- [ r ( 1 ) ] ;
912 let k = i + j;
You can’t perform that action at this time.
0 commit comments