mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Add raw address of expressions to the AST and HIR
This commit is contained in:
@@ -409,6 +409,7 @@
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user