From a8efd31f2b97a043d73db2131dddfedd65485d50 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sat, 23 Nov 2019 14:15:49 +0000 Subject: Add raw address of expressions to the AST and HIR --- src/librustc_error_codes/error_codes/E0745.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/librustc_error_codes/error_codes/E0745.md (limited to 'src/librustc_error_codes/error_codes') 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; +} +``` -- cgit 1.4.1-3-g733a5