Skip to content

Commit

Permalink
Rollup merge of #135985 - Zalathar:whats-upvar, r=lqd
Browse files Browse the repository at this point in the history
Rename test to `unresolvable-upvar-issue-87987.rs` and add some notes

Extracted from #135756. I had to figure out what this test was trying to test, so I might as well write it down for future reference.
  • Loading branch information
joboet authored Jan 24, 2025
2 parents 1621af0 + 6c7e8fe commit aa83880
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 42 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ ui/closure_context/issue-26046-fn-once.rs
ui/closure_context/issue-42065.rs
ui/closures/2229_closure_analysis/issue-118144.rs
ui/closures/2229_closure_analysis/issue-87378.rs
ui/closures/2229_closure_analysis/issue-87987.rs
ui/closures/2229_closure_analysis/issue-88118-2.rs
ui/closures/2229_closure_analysis/issue-88476.rs
ui/closures/2229_closure_analysis/issue-89606.rs
Expand Down
27 changes: 0 additions & 27 deletions tests/ui/closures/2229_closure_analysis/issue-87987.rs

This file was deleted.

14 changes: 0 additions & 14 deletions tests/ui/closures/2229_closure_analysis/issue-87987.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! 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

#[expect(dead_code)]
struct Props {
field_1: u32,
field_2: u32,
}

fn main() {
// Test 1
let props_2 = Props { field_1: 1, field_2: 1 };

let _ = || {
let _: Props = props_2;
};

// Test 2
let mut arr = [1, 3, 4, 5];

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!("C"),
};
let _d = || match arr {
[_, .., _] => println!("D"),
};
let _e = || match arr {
[_, ..] => println!("E"),
};

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

0 comments on commit aa83880

Please sign in to comment.