summaryrefslogtreecommitdiffstats
path: root/src/test/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs')
-rw-r--r--src/test/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs
new file mode 100644
index 000000000..d2375aa69
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs
@@ -0,0 +1,30 @@
+// edition:2021
+//check-pass
+#![warn(unused)]
+#![feature(rustc_attrs)]
+#![feature(btree_drain_filter)]
+
+use std::collections::BTreeMap;
+use std::panic::{catch_unwind, AssertUnwindSafe};
+
+fn main() {
+ let mut map = BTreeMap::new();
+ map.insert("a", ());
+ map.insert("b", ());
+ map.insert("c", ());
+
+ {
+ let mut it = map.drain_filter(|_, _| true);
+ catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err();
+ let result = catch_unwind(AssertUnwindSafe(|| it.next()));
+ assert!(matches!(result, Ok(None)));
+ }
+
+ {
+ let mut it = map.drain_filter(|_, _| true);
+ catch_unwind(AssertUnwindSafe(|| while let Some(_) = it.next() {})).unwrap_err();
+ let result = catch_unwind(AssertUnwindSafe(|| it.next()));
+ assert!(matches!(result, Ok(None)));
+ }
+
+}