about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2019-10-23 09:55:20 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2019-11-03 12:24:35 -0800
commitd6431f69ad2d05e9aa2d5a316c1b4fcaf85f24aa (patch)
tree81c460bfb94de944025dfbeeacd21b1126e266c1
parentfab0caf1723b243e6446ddca669b30b241daf313 (diff)
downloadrust-d6431f69ad2d05e9aa2d5a316c1b4fcaf85f24aa.tar.gz
rust-d6431f69ad2d05e9aa2d5a316c1b4fcaf85f24aa.zip
Test that borrows of projections are promoted everywhere
Previously, this worked in `fn`s but not `const`s or `static`s.
-rw-r--r--src/test/ui/consts/promote_borrowed_field.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/ui/consts/promote_borrowed_field.rs b/src/test/ui/consts/promote_borrowed_field.rs
new file mode 100644
index 00000000000..c4841b46f60
--- /dev/null
+++ b/src/test/ui/consts/promote_borrowed_field.rs
@@ -0,0 +1,12 @@
+// run-pass
+
+// From https://github.com/rust-lang/rust/issues/65727
+
+const _: &i32 = {
+    let x = &(5, false).0;
+    x
+};
+
+fn main() {
+    let _: &'static i32 = &(5, false).0;
+}