Fix panics involving mutable references to ZSTs - #45
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes panics when the analyzer/refinement pipeline encounters mutable references to zero-sized types (ZSTs), specifically around closure types with no captures and the unit type ().
Changes:
- Update
Env::dependencies()to stop dropping singleton-sorted temp vars, preventing “unbound var” panics during clause building. - Update
local_def::Analyzer::reassign_local_mutabilities()to treat ZST locals as mutable when needed, avoiding incorrect optimization assumptions. - Add new UI tests covering
&mut ()and&mutto a no-capture closure in both pass/fail suites.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/refine/env.rs | Keeps singleton temp vars in dependency mapping to avoid missing mapped variables during clause construction. |
src/analyze/local_def.rs | Marks ZST locals as mutable in mutability reassignment to avoid panics/incorrect handling of mut-borrows. |
tests/ui/pass/mut_empty_tuple.rs | New passing regression test for &mut (). |
tests/ui/pass/closure_mut_param.rs | New passing regression test for &mut to a ZST closure type. |
tests/ui/fail/mut_empty_tuple.rs | New failing (Unsat) test variant for &mut (). |
tests/ui/fail/closure_mut_param.rs | New failing (Unsat) test variant for &mut to a closure parameter that is invoked. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
2c20328 to
3bd747cCompareUh oh!
There was an error while loading. Please reload this page.
fix#39
fix#40
let _1: (); bb0: { _1 = (); }should not mark_1as mut, so this fix is imprecise, but it's a rare case anyway and shouldn't have a performance impact...)