Skip to content

Commit

Permalink
Add some notes and test some more pattern variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Jan 24, 2025
1 parent 8175bf3 commit 6c7e8fe
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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);
Expand Down

0 comments on commit 6c7e8fe

Please sign in to comment.