fix(mir): resolve user type aliases to their base type for movability - #540
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
AkiraTamai
marked this pull request as ready for review
September 2, 2026 11:39
Comment on lines
+452
to
+461
| fn resolve_alias_base(env: &crate::verification::ModuleEnv, name: &str) -> String { | ||
| let mut current = name.to_string(); | ||
| let mut seen = std::collections::HashSet::new(); | ||
| while let Some(refined) = env.get_type(¤t) { | ||
| if !seen.insert(current.clone()) || refined._base_type == current { | ||
| break; | ||
| } | ||
| current = refined._base_type.clone(); | ||
| } | ||
| current |
Contributor
Comment on lines
+271
to
+276
| let alias_bases = module_env | ||
| .map(|env| { | ||
| env.types | ||
| .keys() | ||
| .map(|name| (name.clone(), resolve_alias_base(env, name))) | ||
| .collect() |
Contributor
Comment on lines
466
to
+467
| pub fn lower_hir_to_mir(hir_atom: &HirAtom) -> MirBody { | ||
| let mut ctx = LowerCtx::new(); | ||
| lower_hir_to_mir_with_env(hir_atom, None) |
Contributor
There was a problem hiding this comment.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
Follow-up to #539.
mir::movability_from_typeonly recognizes primitives and a hard-coded list of aliases (Nat,Pos,HumanAge, ...), so any other user alias (type Usd = i64 unit USD;,type Count = Nat;) was treated asMove. Branching on such a parameter and returning it on one path then failed move analysis withconflicting ownership ... alive on one control-flow path but consumed on another.Fix: MIR lowering and the structured-concurrency ownership check resolve aliases through
ModuleEnvbefore deciding movability.executor.rspassesSome(module_env);LocalDecl::tystill records the alias name (only themovabilitydecision changes). Without an env (unit tests,infer_atom_return_type) behavior is unchanged.Tests:
tests/test_alias_movability.{mm,rs}(branch onUsd/Countparams; fails ondevelop) andtask_ownership::tests::copy_alias_consumed_by_siblings_is_allowed.Link to Devin session: https://app.devin.ai/sessions/2eef5afcd69d4e0ab19ada3b22d5cf7e
Open in Devin Desktop: https://app.devin.ai/desktop/session/2eef5afcd69d4e0ab19ada3b22d5cf7e?variant=devin
Requested by: @AkiraTamai