Skip to content

Conversation

@ThomasMayerl
Copy link

Upon trying to verify the stdlib definitions, Prusti crashed when encountering an unresolved type alias. Usually, rustc already resolves the aliases. However, when using associated types, rustc cannot do so statically. Therefore, this PR adds support for this.

@ThomasMayerl
Copy link
Author

PCG currently does not support type aliases. In the impl of FunctionDataShapeDataSource of PCG, we check if there are aliases. The temporary fix is to comment out this check, but I don't know if it breaks anything.

Copy link
Owner

@Aurel300 Aurel300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a very good solution. The type-to-type functions that map a generic to an associated type of a trait should not be defined by the GenericParamsEnc. We should have an encoder that handles traits specifically, as well as one for impl blocks; some of the responsibilities of these encoders are outlined in the hack.md document: assoc. type functions, domains/axioms for trait method specifications, function to determine if a given Type implements the trait or not.

@ThomasMayerl
Copy link
Author

I don't think this is a very good solution. The type-to-type functions that map a generic to an associated type of a trait should not be defined by the GenericParamsEnc. We should have an encoder that handles traits specifically, as well as one for impl blocks; some of the responsibilities of these encoders are outlined in the hack.md document: assoc. type functions, domains/axioms for trait method specifications, function to determine if a given Type implements the trait or not.

So you would say we should instead, upon trait encoding, generate the function, and, upon encoding the implementation, the axioms, and that the GenericParamsEnc should only call the assoc function? But does the MIR even still contain the traits/impls or just the result of the resolution? What I mean is, do we even encode traits/impls in Prusti?

@ThomasMayerl ThomasMayerl requested a review from Aurel300 December 8, 2025 14:55
@Aurel300
Copy link
Owner

Thanks, mostly looks good now. We can merge, but you could please check that all the tests from #52 pass with this also?

Apart from that I only wonder (probably not for this PR anymore) about the choice of using trait impls from the current crate vs all visible ones, which may include ones that are coming from dependencies. We should also do something for the latter, avoiding verification (since we won't see the impl bodies) but emitting axioms about which assoc. types map to what, which types implement which traits, etc.

@ThomasMayerl
Copy link
Author

Thanks, mostly looks good now. We can merge, but you could please check that all the tests from #52 pass with this also?

The tests pass. However, two of the files (such as local-testing/generics/fail/trait_post.rs in #52) result in a consistency error because of a variable being s_Param but the bound expression being s_UInt_u32. Verifying the output Viper code works, though. I will still merge the PR because this issue also happens without the changes from this PR.

@Aurel300 Aurel300 merged commit e7c85cd into Aurel300:rewrite-2023 Dec 16, 2025
5 of 7 checks passed
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.

2 participants