Add raw address of expressions to the AST and HIR

This commit is contained in:
Matthew Jasper 2019-11-23 14:15:49 +00:00
parent 9420ff4c0e
commit a8efd31f2b
22 changed files with 308 additions and 139 deletions

View file

@ -409,6 +409,7 @@ E0741: include_str!("./error_codes/E0741.md"),
E0742: include_str!("./error_codes/E0742.md"),
E0743: include_str!("./error_codes/E0743.md"),
E0744: include_str!("./error_codes/E0744.md"),
E0745: include_str!("./error_codes/E0745.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard

View 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;
}
```