File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change
1
+ ### Example
2
+
3
+ ``` rust
4
+ fn f_mut_bad <'s >(& 's mut self ) -> & 's mut Self {
5
+ let ret = unsafe { transmute :: <& 's Self , & 's mut Self >(self . f ()) };
6
+ ret // β-expansion should have no effect
7
+ }
8
+ ```
9
+
10
+ ### Explanation
11
+
12
+ In this variation on the lovely and delightful ` f_mut ` series, the
13
+ ` self.f() ` point has a lifetime of ` 's ` , and thus the scope of the
14
+ shared borrow extends past the unsafe block.
15
+
16
+ ### Source
17
+
18
+ - https://github.com/rust-lang/rust/issues/30424#issuecomment-168541165
Original file line number Diff line number Diff line change 3
3
``` rust
4
4
fn f_mut_pedantic <'s >(& 's mut self ) -> & 's mut Self {
5
5
let captured_self = self as * mut Self ;
6
- unsafe { & mut * ((* captured_self ). f () as * const Self as * mut Self ) }
6
+ unsafe { & mut * ((& * captured_self ). f () as * const Self as * mut Self ) }
7
7
}
8
8
```
9
9
17
17
18
18
### Source
19
19
20
- https://github.com/rust-lang/rust/issues/30424#issuecomment-167009462
20
+ - https://github.com/rust-lang/rust/issues/30424#issuecomment-167009462
21
+ - https://github.com/rust-lang/rust/issues/30424#issuecomment-168539718
You can’t perform that action at this time.
0 commit comments