about summary refs log tree commit diff
path: root/tests/ui/borrowck/borrowck-drop-from-guard.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-drop-from-guard.rs')
-rw-r--r--tests/ui/borrowck/borrowck-drop-from-guard.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-drop-from-guard.rs b/tests/ui/borrowck/borrowck-drop-from-guard.rs
new file mode 100644
index 00000000000..0f320af2657
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-drop-from-guard.rs
@@ -0,0 +1,20 @@
+#![feature(if_let_guard)]
+
+fn foo(_:String) {}
+
+fn main()
+{
+    let my_str = "hello".to_owned();
+    match Some(42) {
+        Some(_) if { drop(my_str); false } => {}
+        Some(_) => {}
+        None => { foo(my_str); } //~ ERROR [E0382]
+    }
+
+    let my_str = "hello".to_owned();
+    match Some(42) {
+        Some(_) if let Some(()) = { drop(my_str); None } => {}
+        Some(_) => {}
+        None => { foo(my_str); } //~ ERROR [E0382]
+    }
+}