-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 support to return value in StableMIR interface and not crash due to compilation error #115397
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
This PR changes Stable MIR cc @oli-obk, @celinval, @spastorino |
This comment has been minimized.
This comment has been minimized.
Everything looks good, but maybe returning |
☔ The latest upstream changes (presumably #115346) made this pull request unmergeable. Please resolve the merge conflicts. |
The compiler will still print its regular messages, so the ICE message should still print. I believe the panic hook will also run before we catch the error. If we were to differentiate failure reasons in our APIs, we could use an enum instead of a struct, and have an ICE variant. I can do that now or we can do it later. What do you think? |
Yeah compiler will definitely print out the regular ICE message but as you suggested expecting these with enum variants will feel more right. |
9c33c5c
to
3e90717
Compare
Please add a test for these code paths, they seem easy to regress |
☔ The latest upstream changes (presumably #115469) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors delegate+ r=me after a rebase |
I just realized I forgot to add the new test file to git. |
Invoking StableMir::run() on a crate that has any compilation error was crashing the entire process. Instead, return a `CompilerError` so the user knows compilation did not succeed. I believe ICE will also be converted to `CompilerError`. I'm also adding a return value to the callback, because I think it will be handy for users (at least it was for my current task of implementing a tool to validate stable-mir). However, if people disagree, I can remove that.
Currently we stop compilation, but some users might want to keep going. This is needed for us to test against rustc tests. Other tools, such as Kani, also implements parts of their logic as a backend so it is important for compilation to continue.
9b106fe
to
d10d829
Compare
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#114794 (clarify safety documentation of ptr::swap and ptr::copy) - rust-lang#115397 (Add support to return value in StableMIR interface and not crash due to compilation error) - rust-lang#115559 (implied bounds: do not ICE on unconstrained region vars) Failed merges: - rust-lang#115532 (Implement SMIR generic parameter instantiation) r? `@ghost` `@rustbot` modify labels: rollup
Invoking
StableMir::run()
on a crate that has any compilation error was crashing the entire process. Instead, return aCompilerError
so the user knows compilation did not succeed. I believe ICE will also be converted toCompilerError
.I'm also adding a possibility for the callback to return a value. I think it will be handy for users (at least it was for my current task of implementing a tool to validate stable-mir). However, if people disagree, I can remove that.