Fake capture closures if typeck results are empty#100452
Fake capture closures if typeck results are empty#100452ouz-a wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
|
r? rust-lang/compiler |
|
r? rust-lang/compiler |
|
r? rust-lang/compiler |
|
Should ping @nikomatsakis about this. He probably has the most background on this. |
There was a problem hiding this comment.
Can you update this comment to include an explanation for the added logic? And also add a reference to the issue number?
|
r=me with updated comment |
|
r? @jackh726 |
|
cc @nikomatsakis I feel like there is a bigger issue I am missing here and this fix feels a bit like hack, is there anything you would like to add? |
|
☔ The latest upstream changes (presumably #102306) made this pull request unmergeable. Please resolve the merge conflicts. |
|
☔ The latest upstream changes (presumably #103310) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@bors delegate+ r=me after rebase |
|
✌️ @ouz-a can now approve this pull request |
|
@bors r=jackh726 |
Fake capture closures if typeck results are empty This ICE happens because `closure_min_captures` is empty, the reason it's empty is with the 2021 edition `enable_precise_capture` is set to true, which makes it so that we can't fake capture any information because that result of the `unwrap` is none hence the ICE. Other solution is editing [maybe_read_scrutinee](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/expr_use_visitor.rs.html#453-463) to this since empty slice contains no sub patterns. Fixes rust-lang#93242 ```rust PatKind::Slice(_, ref slice, _) => { if slice.is_none(){ need_to_be_read = true; } } // instead of PatKind::Or(_) | PatKind::Box(_) | PatKind::Slice(..) | PatKind::Ref(..) | PatKind::Wild => {} ```
Fake capture closures if typeck results are empty This ICE happens because `closure_min_captures` is empty, the reason it's empty is with the 2021 edition `enable_precise_capture` is set to true, which makes it so that we can't fake capture any information because that result of the `unwrap` is none hence the ICE. Other solution is editing [maybe_read_scrutinee](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/expr_use_visitor.rs.html#453-463) to this since empty slice contains no sub patterns. Fixes rust-lang#93242 ```rust PatKind::Slice(_, ref slice, _) => { if slice.is_none(){ need_to_be_read = true; } } // instead of PatKind::Or(_) | PatKind::Box(_) | PatKind::Slice(..) | PatKind::Ref(..) | PatKind::Wild => {} ```
Fake capture closures if typeck results are empty This ICE happens because `closure_min_captures` is empty, the reason it's empty is with the 2021 edition `enable_precise_capture` is set to true, which makes it so that we can't fake capture any information because that result of the `unwrap` is none hence the ICE. Other solution is editing [maybe_read_scrutinee](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/expr_use_visitor.rs.html#453-463) to this since empty slice contains no sub patterns. Fixes rust-lang#93242 ```rust PatKind::Slice(_, ref slice, _) => { if slice.is_none(){ need_to_be_read = true; } } // instead of PatKind::Or(_) | PatKind::Box(_) | PatKind::Slice(..) | PatKind::Ref(..) | PatKind::Wild => {} ```
Fake capture closures if typeck results are empty This ICE happens because `closure_min_captures` is empty, the reason it's empty is with the 2021 edition `enable_precise_capture` is set to true, which makes it so that we can't fake capture any information because that result of the `unwrap` is none hence the ICE. Other solution is editing [maybe_read_scrutinee](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/expr_use_visitor.rs.html#453-463) to this since empty slice contains no sub patterns. Fixes rust-lang#93242 ```rust PatKind::Slice(_, ref slice, _) => { if slice.is_none(){ need_to_be_read = true; } } // instead of PatKind::Or(_) | PatKind::Box(_) | PatKind::Slice(..) | PatKind::Ref(..) | PatKind::Wild => {} ```
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
|
I am not sure about the results of these tests would love to get some approval from @rust-lang/clippy |
|
☔ The latest upstream changes (presumably #106266) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Well, thank goodness for clippy. This PR regresses the following code with edition 2021 (it fails for previous editions): #[derive(Clone)]
struct Alpha;
fn clone_then_move_cloned() {
fn foo<F: Fn()>(_: &Alpha, _: F) {}
let x = Alpha;
// ok, data is moved while the clone is in use.
foo(&x, move || {
let _ = x;
});
}
fn main() { clone_then_move_cloned() }Can you please add the above as a test? Looks like we need to come up with a different solution. |
|
Yeah this Clippy test change looks fishy. Usually when a Clippy test changes without any Clippy changes it means some assertions Clippy made about compiler internals changed. |
Yeah, will look into another solution. |
|
@ouz-a any updates here? |
Sorry completely forget about this, going to try to solve this, this week if can't solve it will post what I found. |
|
☔ The latest upstream changes (presumably #108586) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I spent some time trying to uncover what's happening but I couldn't find a solution: pub async fn something(path: &[usize]) -> usize {
// Without this async block it doesn't ICE
async {
match path {
[] => 1,
//[1] => 2,
_ => 1,
}
}
.await
} |
This ICE happens because
closure_min_capturesis empty, the reason it's empty is with the 2021 editionenable_precise_captureis set to true, which makes it so that we can't fake capture any information because that result of theunwrapis none hence the ICE.Other solution is editing maybe_read_scrutinee to this since empty slice contains no sub patterns.
Fixes #93242