summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs')
-rw-r--r--tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs
new file mode 100644
index 000000000..792225e65
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs
@@ -0,0 +1,15 @@
+// References to by-move bindings in an if-let guard *cannot* be used after the guard.
+
+#![feature(if_let_guard)]
+
+fn main() {
+ let x: Option<Option<String>> = Some(Some(String::new()));
+ match x {
+ Some(mut y) if let Some(ref z) = y => {
+ //~^ ERROR: cannot move out of `x.0` because it is borrowed
+ let _z: &String = z;
+ let _y: Option<String> = y;
+ }
+ _ => {}
+ }
+}