Fix panics involving mutable references to ZSTs#45
Merged
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.
2c20328 to
3bd747c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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...)