Add raw address of expressions to the AST and HIR
This commit is contained in:
parent
9420ff4c0e
commit
a8efd31f2b
22 changed files with 308 additions and 139 deletions
20
src/librustc_error_codes/error_codes/E0745.md
Normal file
20
src/librustc_error_codes/error_codes/E0745.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
Cannot take address of temporary value.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0745
|
||||
# #![feature(raw_ref_op)]
|
||||
fn temp_address() {
|
||||
let ptr = &raw const 2; // ERROR
|
||||
}
|
||||
```
|
||||
|
||||
To avoid the error, first bind the temporary to a named local variable.
|
||||
|
||||
```ignore
|
||||
# #![feature(raw_ref_op)]
|
||||
fn temp_address() {
|
||||
let val = 2;
|
||||
let ptr = &raw const val;
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue