File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -480,7 +480,27 @@ pub fn main() {
480
480
# }
481
481
```
482
482
483
- The type system prevents us from moving the data.
483
+ The type system prevents us from moving the data, as follows:
484
+
485
+ ```
486
+ error[E0277]: `PhantomPinned` cannot be unpinned
487
+ --> src\test.rs:56:30
488
+ |
489
+ 56 | std::mem::swap(test1.get_mut(), test2.get_mut());
490
+ | ^^^^^^^ within `test1::Test`, the trait `Unpin` is not implemented for `PhantomPinned`
491
+ |
492
+ = note: consider using `Box::pin`
493
+ note: required because it appears within the type `test1::Test`
494
+ --> src\test.rs:7:8
495
+ |
496
+ 7 | struct Test {
497
+ | ^^^^
498
+ note: required by a bound in `std::pin::Pin::<&'a mut T>::get_mut`
499
+ --> <...>rustlib/src/rust\library\core\src\pin.rs:748:12
500
+ |
501
+ 748 | T: Unpin,
502
+ | ^^^^^ required by this bound in `std::pin::Pin::<&'a mut T>::get_mut`
503
+ ```
484
504
485
505
> It's important to note that stack pinning will always rely on guarantees
486
506
> you give when writing ` unsafe ` . While we know that the _ pointee_ of ` &'a mut T `
You can’t perform that action at this time.
0 commit comments