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

Add try_use_var method to cranelift-frontend. #4588

Merged
merged 4 commits into from
Aug 4, 2022

Conversation

teymour-aldridge
Copy link
Contributor

@teymour-aldridge teymour-aldridge commented Aug 3, 2022

Please ensure that the following steps are all taken care of before submitting
the PR.

  • This is a very small PR, so I have not created an issue
  • A frontend might want to provide its own error reporting to end users if the variable does not exist.
  • @cfallin (maybe?)

- Unlike `use_var`, this method does not panic if the variable has not been defined
before use
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Aug 3, 2022
@afonso360
Copy link
Contributor

afonso360 commented Aug 3, 2022

Should we do something similar to declare_var and def_var both can fail in similar conditions to this one (recoverable user errors)?

@teymour-aldridge
Copy link
Contributor Author

Should we do something similar to declare_var and def_var both can fail in similar conditions to this one (recoverable user errors)?

That makes sense to me.

- Also implement Error for error enums.
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good overall and this is a nice API improvement.

My main comment below is in the Display impls -- we should be able to use the write! convenience macro so we don't have to unroll what the format string would have done by hand. With that cleaned up, I'd be happy to merge this.

cranelift/frontend/src/frontend.rs Outdated Show resolved Hide resolved
cranelift/frontend/src/frontend.rs Outdated Show resolved Hide resolved
cranelift/frontend/src/frontend.rs Outdated Show resolved Hide resolved
@cfallin cfallin enabled auto-merge (squash) August 4, 2022 15:44
@cfallin cfallin merged commit ad223c5 into bytecodealliance:main Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants