diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2019-11-23 14:15:49 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2019-11-24 18:06:13 +0000 |
| commit | a8efd31f2b97a043d73db2131dddfedd65485d50 (patch) | |
| tree | d5eef5952391f5bf162f3ce4a4470255157843f0 /src/librustc_error_codes | |
| parent | 9420ff4c0ebea44b167d530bb59f9d5721d8ff0b (diff) | |
| download | rust-a8efd31f2b97a043d73db2131dddfedd65485d50.tar.gz rust-a8efd31f2b97a043d73db2131dddfedd65485d50.zip | |
Add raw address of expressions to the AST and HIR
Diffstat (limited to 'src/librustc_error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes.rs | 1 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0745.md | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index b11fe33880c..709ccce517a 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -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 diff --git a/src/librustc_error_codes/error_codes/E0745.md b/src/librustc_error_codes/error_codes/E0745.md new file mode 100644 index 00000000000..7c478a1e0c8 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0745.md @@ -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; +} +``` |
