File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
- Cannot take address of temporary value.
1
+ The address of temporary value was taken .
2
2
3
3
Erroneous code example:
4
4
5
5
``` compile_fail,E0745
6
6
# #![feature(raw_ref_op)]
7
7
fn temp_address() {
8
- let ptr = &raw const 2; // ERROR
8
+ let ptr = &raw const 2; // error!
9
9
}
10
10
```
11
11
12
- To avoid the error, first bind the temporary to a named local variable.
12
+ 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:
13
16
14
17
```
15
18
# #![feature(raw_ref_op)]
16
19
fn temp_address() {
17
20
let val = 2;
18
- let ptr = &raw const val;
21
+ let ptr = &raw const val; // ok!
19
22
}
20
23
```
You can’t perform that action at this time.
0 commit comments