summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs')
-rw-r--r--tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs
new file mode 100644
index 000000000..e384aacb7
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs
@@ -0,0 +1,22 @@
+struct Defer<'a> {
+ x: &'a [&'a str],
+}
+
+impl<'a> Drop for Defer<'a> {
+ fn drop(&mut self) {
+ unsafe {
+ println!("{:?}", self.x);
+ }
+ }
+}
+
+fn defer<'r>(x: &'r [&'r str]) -> Defer<'r> {
+ Defer {
+ x: x
+ }
+}
+
+fn main() {
+ let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed
+ x.x[0];
+}