Skip to content

Commit 6c7e8fe

Browse files
committed
Add some notes and test some more pattern variants
1 parent 8175bf3 commit 6c7e8fe

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Diff for: tests/ui/closures/2229_closure_analysis/unresolvable-upvar-issue-87987.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//! When a closure syntactically captures a place, but doesn't actually capture
2+
//! it, make sure MIR building doesn't ICE when handling that place.
3+
//!
4+
//! Under the Rust 2021 disjoint capture rules, this sort of non-capture can
5+
//! occur when a place is only inspected by infallible non-binding patterns.
6+
7+
// FIXME(#135985): On its own, this test should probably just be check-pass.
8+
// But there are few/no other tests that use non-binding array patterns and
9+
// invoke the later parts of the compiler, so building/running has some value.
10+
111
//@ run-pass
212
//@ edition:2021
313

@@ -20,8 +30,16 @@ fn main() {
2030

2131
let mref = &mut arr;
2232

33+
// These array patterns don't need to inspect the array, so the array
34+
// isn't captured.
2335
let _c = || match arr {
24-
[_, _, _, _] => println!("A"),
36+
[_, _, _, _] => println!("C"),
37+
};
38+
let _d = || match arr {
39+
[_, .., _] => println!("D"),
40+
};
41+
let _e = || match arr {
42+
[_, ..] => println!("E"),
2543
};
2644

2745
println!("{:#?}", mref);

0 commit comments

Comments
 (0)