File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ impl Foo {
1515fn foo ( _: Pin < & mut Foo > ) {
1616}
1717
18- fn bar ( mut x : Pin < & mut Foo > ) {
18+ fn bar ( x : Pin < & mut Foo > ) {
1919 foo ( x) ;
2020 foo ( x) ; // for this to work we need to automatically reborrow,
2121 // 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