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

Adjust lifetimes on ModelIter to make them more permissive #324

Merged

Conversation

sgpthomas
Copy link
Contributor

Currently, iterating over a Model creates FuncDecls that reference the lifetime of the reference of the model that they come from, rather than the lifetime of context it contains.

This means that it is impossible to use those FuncDecls after the model is dropped, even when the context is still around. From looking at the code, this just seems like a bug, but let me know if this is intentional.

This PR adjusts the lifetimes of ModelIter to also explicitly include the lifetime of the model reference. This way it can return FuncDecl that properly reference the lifetime of the context.

Copy link
Contributor

@waywardmonkeys waywardmonkeys left a comment

Choose a reason for hiding this comment

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

I think this looks good.

It would be good to have a test for this to at least compile in a way that didn't before so that we make sure that this doesn't regress.

@sgpthomas
Copy link
Contributor Author

Added a test that only compiles with this change. Let me know if it looks good to you. Also, is the wasm build something that I broke? Or can I ignore that?

@waywardmonkeys
Copy link
Contributor

Looks great and will merge it shortly.

I don't think you broke the WebAssembly build. I'll try to take a look at it today or tomorrow.

Thanks for the PR!

@waywardmonkeys waywardmonkeys merged commit eb5796f into prove-rs:master Nov 26, 2024
10 of 11 checks passed
@sgpthomas sgpthomas deleted the model_iter_permissive_lifetimes branch November 26, 2024 03:05
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