File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ ### Example
2
+
3
+ ``` rust
4
+ fn caller (x : & mut i32 ) {
5
+ callee (x , x );
6
+ }
7
+
8
+ fn callee (x : * mut i32 , y : * mut i32 ) {
9
+ }
10
+
11
+ fn main () { }
12
+ ```
13
+
14
+ ### Explanation
15
+
16
+ In the call to ` callee ` , there is an implicit reborrow of ` x ` and
17
+ coercion of the resulting reborrow to a ` *mut ` . These reborrows have a
18
+ very short lifetime, so here we can coerce ` x ` twice into a ` *mut ` .
19
+
20
+ Since this pattern occurs everywhere in FFI libraries, this suggests
21
+ that if we coerce an ` &'a mut ` (resp. ` &'a ` ) to a ` *mut/*const `
22
+ (resp. ` *const ` ), we should not say that the resulting unsafe pointer
23
+ is only usable during ` 'a ` , because ` 'a ` may be something unreasonably
24
+ short.
25
+
26
+ ### Source
27
+
28
+ https://github.com/rust-lang/rust/issues/30424#issuecomment-171344268
You can’t perform that action at this time.
0 commit comments