Skip to content

Commit eb3e1c9

Browse files
authored
Rollup merge of rust-lang#135985 - Zalathar:whats-upvar, r=lqd
Rename test to `unresolvable-upvar-issue-87987.rs` and add some notes Extracted from rust-lang#135756. I had to figure out what this test was trying to test, so I might as well write it down for future reference.
2 parents 5c821ae + 6c7e8fe commit eb3e1c9

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

Diff for: src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ ui/closure_context/issue-26046-fn-once.rs
409409
ui/closure_context/issue-42065.rs
410410
ui/closures/2229_closure_analysis/issue-118144.rs
411411
ui/closures/2229_closure_analysis/issue-87378.rs
412-
ui/closures/2229_closure_analysis/issue-87987.rs
413412
ui/closures/2229_closure_analysis/issue-88118-2.rs
414413
ui/closures/2229_closure_analysis/issue-88476.rs
415414
ui/closures/2229_closure_analysis/issue-89606.rs

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

-27
This file was deleted.

Diff for: tests/ui/closures/2229_closure_analysis/issue-87987.stderr

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
11+
//@ run-pass
12+
//@ edition:2021
13+
14+
#[expect(dead_code)]
15+
struct Props {
16+
field_1: u32,
17+
field_2: u32,
18+
}
19+
20+
fn main() {
21+
// Test 1
22+
let props_2 = Props { field_1: 1, field_2: 1 };
23+
24+
let _ = || {
25+
let _: Props = props_2;
26+
};
27+
28+
// Test 2
29+
let mut arr = [1, 3, 4, 5];
30+
31+
let mref = &mut arr;
32+
33+
// These array patterns don't need to inspect the array, so the array
34+
// isn't captured.
35+
let _c = || match arr {
36+
[_, _, _, _] => println!("C"),
37+
};
38+
let _d = || match arr {
39+
[_, .., _] => println!("D"),
40+
};
41+
let _e = || match arr {
42+
[_, ..] => println!("E"),
43+
};
44+
45+
println!("{:#?}", mref);
46+
}

0 commit comments

Comments
 (0)