Skip to content

Commit 008228a

Browse files
authored
Rollup merge of #75140 - GuillaumeGomez:cleanup-e0745, r=pickfire
Clean up E0745 r? @Dylan-DPC
2 parents 7b39f75 + 0275cd7 commit 008228a

File tree

1 file changed

+7
-4
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+7
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
Cannot take address of temporary value.
1+
The address of temporary value was taken.
22

33
Erroneous code example:
44

55
```compile_fail,E0745
66
# #![feature(raw_ref_op)]
77
fn temp_address() {
8-
let ptr = &raw const 2; // ERROR
8+
let ptr = &raw const 2; // error!
99
}
1010
```
1111

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:
1316

1417
```
1518
# #![feature(raw_ref_op)]
1619
fn temp_address() {
1720
let val = 2;
18-
let ptr = &raw const val;
21+
let ptr = &raw const val; // ok!
1922
}
2023
```

0 commit comments

Comments
 (0)