File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // error-pattern: cannot copy pinned type r
2
+
3
+ resource r( i: @mutable int) {
4
+ * i = * i + 1 ;
5
+ }
6
+
7
+ fn movearg ( i : r ) {
8
+ // Implicit copy to mutate reference i
9
+ let j <- i;
10
+ }
11
+
12
+ fn main ( ) {
13
+ let i = @mutable 0 ;
14
+ {
15
+ let j <- r ( i ) ;
16
+ movearg ( j ) ;
17
+ }
18
+ log_err * i;
19
+ // nooooooo. destructor ran twice
20
+ assert * i == 2 ;
21
+ }
Original file line number Diff line number Diff line change
1
+ // error-pattern: cannot copy pinned type 'a
2
+
3
+ resource r( i: @mutable int) {
4
+ * i = * i + 1 ;
5
+ }
6
+
7
+ fn movearg < T > ( i : T ) {
8
+ // Implicit copy to mutate reference i
9
+ let j <- i;
10
+ }
11
+
12
+ fn main ( ) {
13
+ let i = @mutable 0 ;
14
+ {
15
+ let j <- r ( i ) ;
16
+ movearg ( j ) ;
17
+ }
18
+ log_err * i;
19
+ // nooooooo. destructor ran twice
20
+ assert * i == 2 ;
21
+ }
You can’t perform that action at this time.
0 commit comments