Uh oh!
There was an error while loading. Please reload this page.
Fake capture closures if typeck results are empty - #100452
Conversation
rust-highfive
commented
Aug 12, 2022
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
nagisa
commented
Aug 15, 2022
r? rust-lang/compiler |
ouz-a
commented
Aug 30, 2022
r? rust-lang/compiler |
ouz-a
commented
Sep 7, 2022
r? rust-lang/compiler |
jackh726
commented
Sep 7, 2022
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?
jackh726
commented
Sep 7, 2022
r=me with updated comment |
ouz-a
commented
Sep 23, 2022
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? |
bors
commented
Sep 27, 2022
☔ The latest upstream changes (presumably #102306) made this pull request unmergeable. Please resolve the merge conflicts. |
bors
commented
Oct 21, 2022
☔ The latest upstream changes (presumably #103310) made this pull request unmergeable. Please resolve the merge conflicts. |
jackh726
commented
Oct 21, 2022
@bors delegate+ r=me after rebase |
bors
commented
Oct 21, 2022
✌️ @ouz-a can now approve this pull request |
ouz-a
commented
Oct 23, 2022
@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. Fixesrust-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. Fixesrust-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. Fixesrust-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. Fixesrust-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 => {} ```
Dylan-DPC
commented
Oct 28, 2022
rustbot
commented
Oct 31, 2022
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
ouz-a
commented
Oct 31, 2022
I am not sure about the results of these tests would love to get some approval from @rust-lang/clippy |
bors
commented
Dec 29, 2022
☔ The latest upstream changes (presumably #106266) made this pull request unmergeable. Please resolve the merge conflicts. |
jackh726
commented
Dec 30, 2022
Well, thank goodness for clippy. This PR regresses the following code with edition 2021 (it fails for previous editions): #[derive(Clone)]structAlpha;fnclone_then_move_cloned(){fnfoo<F:Fn()>(_:&Alpha, _:F){}let x = Alpha;// ok, data is moved while the clone is in use.foo(&x,move || {let _ = x;});}fnmain(){clone_then_move_cloned()}Can you please add the above as a test? Looks like we need to come up with a different solution. |
flip1995
commented
Dec 30, 2022
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. |
ouz-a
commented
Dec 30, 2022
Yeah, will look into another solution. |
jackh726
commented
Feb 18, 2023
@ouz-a any updates here? |
ouz-a
commented
Feb 19, 2023
Sorry completely forget about this, going to try to solve this, this week if can't solve it will post what I found. |
bors
commented
Mar 1, 2023
☔ The latest upstream changes (presumably #108586) made this pull request unmergeable. Please resolve the merge conflicts. |
ouz-a
commented
Mar 9, 2023
I spent some time trying to uncover what's happening but I couldn't find a solution: pubasyncfnsomething(path:&[usize]) -> usize{// Without this async block it doesn't ICEasync{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