about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2025-01-20 17:05:54 +1100
committerZalathar <Zalathar@users.noreply.github.com>2025-01-24 23:49:04 +1100
commit6c7e8fefa30688f2a750f738bb78da517c4ffc00 (patch)
tree84b6f7872da277ea4fb032565c50c84ad899022a
parent8175bf3ed3b4c5f8d4f59f8c83fdd284a24e4dac (diff)
downloadrust-6c7e8fefa30688f2a750f738bb78da517c4ffc00.tar.gz
rust-6c7e8fefa30688f2a750f738bb78da517c4ffc00.zip
Add some notes and test some more pattern variants
-rw-r--r--tests/ui/closures/2229_closure_analysis/unresolvable-upvar-issue-87987.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/ui/closures/2229_closure_analysis/unresolvable-upvar-issue-87987.rs b/tests/ui/closures/2229_closure_analysis/unresolvable-upvar-issue-87987.rs
index 03cbe53cbec..c501e034c97 100644
--- a/tests/ui/closures/2229_closure_analysis/unresolvable-upvar-issue-87987.rs
+++ b/tests/ui/closures/2229_closure_analysis/unresolvable-upvar-issue-87987.rs
@@ -1,3 +1,13 @@
+//! When a closure syntactically captures a place, but doesn't actually capture
+//! it, make sure MIR building doesn't ICE when handling that place.
+//!
+//! Under the Rust 2021 disjoint capture rules, this sort of non-capture can
+//! occur when a place is only inspected by infallible non-binding patterns.
+
+// FIXME(#135985): On its own, this test should probably just be check-pass.
+// But there are few/no other tests that use non-binding array patterns and
+// invoke the later parts of the compiler, so building/running has some value.
+
 //@ run-pass
 //@ edition:2021
 
@@ -20,8 +30,16 @@ fn main() {
 
     let mref = &mut arr;
 
+    // These array patterns don't need to inspect the array, so the array
+    // isn't captured.
     let _c = || match arr {
-        [_, _, _, _] => println!("A"),
+        [_, _, _, _] => println!("C"),
+    };
+    let _d = || match arr {
+        [_, .., _] => println!("D"),
+    };
+    let _e = || match arr {
+        [_, ..] => println!("E"),
     };
 
     println!("{:#?}", mref);