File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ impl Foo {
15
15
fn foo ( _: Pin < & mut Foo > ) {
16
16
}
17
17
18
- fn bar ( mut x : Pin < & mut Foo > ) {
18
+ fn bar ( x : Pin < & mut Foo > ) {
19
19
foo ( x) ;
20
20
foo ( x) ; // for this to work we need to automatically reborrow,
21
21
// as if the user had written `foo(x.as_mut())`.
Original file line number Diff line number Diff line change
1
+ #![ feature( pin_ergonomics) ]
2
+ #![ allow( dead_code, incomplete_features) ]
3
+
4
+ // Make sure with pin reborrowing that we can only get one mutable reborrow of a pinned reference.
5
+
6
+ use std:: pin:: { pin, Pin } ;
7
+
8
+ fn twice ( _: Pin < & mut i32 > , _: Pin < & mut i32 > ) { }
9
+
10
+ fn main ( ) {
11
+ let x = pin ! ( 42 ) ;
12
+ twice ( x, x) ; //~ ERROR cannot borrow
13
+ }
Original file line number Diff line number Diff line change
1
+ error[E0499]: cannot borrow `*x.__pointer` as mutable more than once at a time
2
+ --> $DIR/pin-reborrow-once.rs:12:14
3
+ |
4
+ LL | twice(x, x);
5
+ | ----- - ^ second mutable borrow occurs here
6
+ | | |
7
+ | | first mutable borrow occurs here
8
+ | first borrow later used by call
9
+
10
+ error: aborting due to 1 previous error
11
+
12
+ For more information about this error, try `rustc --explain E0499`.
You can’t perform that action at this time.
0 commit comments