]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0745.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0745.md
1 Cannot take address of temporary value.
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
9 }
10 ```
11
12 To avoid the error, first bind the temporary to a named local variable.
13
14 ```ignore (not yet implemented)
15 # #![feature(raw_ref_op)]
16 fn temp_address() {
17     let val = 2;
18     let ptr = &raw const val;
19 }
20 ```