-
Notifications
You must be signed in to change notification settings - Fork 802
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
fix unintentional unsafe_code
trigger
#4574
Conversation
This reverts commit 0e03b39.
Thanks for the review! I'm going to leave this open for now to give the others a chance on some feedback on whether we all agree that this is the correct fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes a lot of sense. Thank you for diving in. I think I will cherry-pick this fix onto a 0.22.4 patch (even if the build break has now already happened).
Making a UI test is a smart way to match downstream user experience. 👍
Just one thought, which might help us re-use stuff... 🤔
@@ -0,0 +1,22 @@ | |||
#![forbid(unsafe_code)] | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, does it make sense to include all the hygiene tests in here?
Something like
use pyo3::*; // to make this `crate` match PyO3's `crate` used in the hygiene tests
#[path = "../../src/tests/hygiene/mod.rs"]
mod hygiene;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very smart! This can't test the cfg
variants in there, but I think that's fine, so I simply allowed unexpected_cfgs
for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Ah, but the abi3 tests have some issues 😭 |
1 similar comment
Ah, but the abi3 tests have some issues 😭 |
Oops, I guess we just gate the test? |
Maybe split the test into two; run the bit I suggested in a separate (gated) test? Seems a shame to have no coverage under abi3... 🤔 (I had a look at |
Ah nvm you already just gated, I think that's good enough 👍 |
Yeah, it's declared out of scope for |
Another attempt at fixing #4394.
This reverts #4396 (can also be done separately first) as it does not play nicely
#[forbid(unsafe_code)]
.The root cause seemed to be that the
unsafe
code generated for theget_all
option inherited aSpan
. This changes that, so that only the part needed for diagnostics inherits theSpan
an the rest gets the defaultcall_site
span.I added a
pass
ui tests, with the repro from #4394, to tests against this. It probably does not cover every emittedunsafe
, but we can probably extend it in the future is other cases pop up. Reusing the hygiene tests for this did not work, probably because they are part of the PyO3 crate and thus the spans/macro hygiene is different than for external crates...