Skip to content
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

Improve inference of Ghost when erased #905

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

xldenis
Copy link
Collaborator

@xldenis xldenis commented Nov 1, 2023

See: verus-lang/verus#875

This improves the type inference of gh! when dealing with erased code.
Previously, it was required to always annotate gh bindings if you wanted the erased code to work. This was because when the gh code is erased, type inference is missing information to determine a concrete type and rustc will reject the code as ambiguous.

For example, the following failed to compile with rustc previously:

let x = gh! { 5 };

This PR fixes it by exploiting the coercion from ! to any type in Rust, so that when erased, we will 'default' to Ghost<!> while remaining capable to unify with any possible type annotation that was provided in a binding.

this was found in collaboration with @utaal

Developped in collaboration with @utaal
@xldenis xldenis force-pushed the better-ghost-inference branch from 6312c6c to af5ef6e Compare November 1, 2023 14:16
@xldenis xldenis merged commit f0ee73d into master Nov 2, 2023
4 checks passed
@xldenis xldenis deleted the better-ghost-inference branch November 2, 2023 10:31
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.

1 participant