Skip to content

Fix issue #1627 #1652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pratapsingh1729
Copy link
Contributor

Fixes #1627 (Verus crashing on an external impl Trait when that trait has an associated type).

@Chris-Hawblitzel or whoever wrote the trait logic should definitely confirm this, but below is why I think this fix is sound.

In rust_to_vir_impl.rs:608, we look up trait_map[&trait_path]. Here, trait_map contains all the traits in the current crate, while trait_path is iterating through auto_import_impls, which contains all impls that are either for "new" traits (traits from the current crate), or external impls from the current crate. Then, the for loop starting on line 576 iterates through all of the auto_import_impls (the impls that might be visible to Verus), looking up their traits in the trait_map.

The error case in #1627 comes from an external impl for an external trait, so the external trait doesn't appear in trait_map. But since it is an external impl for an external trait, Verus shouldn't be able to see it, so I think it shouldn't need to check whether there is an associated type match for it in the list of local traits.

If my reasoning is incorrect, please let me know---I'd be happy to implement a different fix!

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@parno parno requested a review from Chris-Hawblitzel May 30, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verus crashes on impl IntoIterator for Foo outside verus! macro
1 participant