about summary refs log tree commit diff
path: root/src/librustc_error_codes/error_codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-25 01:20:38 +0000
committerbors <bors@rust-lang.org>2019-11-25 01:20:38 +0000
commitc9bacb70f0b19d324a548bd7942692ab18d159a4 (patch)
tree66f7ee078e270f46163da47516b38139204476bb /src/librustc_error_codes/error_codes
parent388ffd9df83cfac20b3fbf7128eb44d5b1526f8c (diff)
parentf4efc5de8a91c8322f83fe07ced5ab119a457ade (diff)
downloadrust-c9bacb70f0b19d324a548bd7942692ab18d159a4.tar.gz
rust-c9bacb70f0b19d324a548bd7942692ab18d159a4.zip
Auto merge of #66671 - matthewjasper:ast-address-of, r=Centril
Ast address-of

This is the parts of #64588 that don't affect MIR. If an address-of expression makes it to MIR lowering we error and lower to the best currently expressible approximation to limit further errors.

r? @Centril
Diffstat (limited to 'src/librustc_error_codes/error_codes')
-rw-r--r--src/librustc_error_codes/error_codes/E0745.md20
1 files changed, 20 insertions, 0 deletions
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;
+}
+```