summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0745.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0745.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0745.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0745.md b/compiler/rustc_error_codes/src/error_codes/E0745.md
new file mode 100644
index 000000000..23ee7af30
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0745.md
@@ -0,0 +1,23 @@
+The address of temporary value was taken.
+
+Erroneous code example:
+
+```compile_fail,E0745
+# #![feature(raw_ref_op)]
+fn temp_address() {
+ let ptr = &raw const 2; // error!
+}
+```
+
+In this example, `2` is destroyed right after the assignment, which means that
+`ptr` now points to an unavailable location.
+
+To avoid this error, first bind the temporary to a named local variable:
+
+```
+# #![feature(raw_ref_op)]
+fn temp_address() {
+ let val = 2;
+ let ptr = &raw const val; // ok!
+}
+```