We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7b39f75 + 0275cd7 commit 008228aCopy full SHA for 008228a
src/librustc_error_codes/error_codes/E0745.md
@@ -1,20 +1,23 @@
1
-Cannot take address of temporary value.
+The address of temporary value was taken.
2
3
Erroneous code example:
4
5
```compile_fail,E0745
6
# #![feature(raw_ref_op)]
7
fn temp_address() {
8
- let ptr = &raw const 2; // ERROR
+ let ptr = &raw const 2; // error!
9
}
10
```
11
12
-To avoid the error, first bind the temporary to a named local variable.
+In this example, `2` is destroyed right after the assignment, which means that
13
+`ptr` now points to an unavailable location.
14
+
15
+To avoid this error, first bind the temporary to a named local variable:
16
17
18
19
20
let val = 2;
- let ptr = &raw const val;
21
+ let ptr = &raw const val; // ok!
22
23
0 commit comments