-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
New lints: Safe items inside unsafe extern
#975
Comments
rustdoc-json doesn't model functions declared in |
Relatedly, you probably want a lint for changing |
Neat, TIL -- thank you! We might still want a separate lint for the two cases so we can offer a more specific diagnostic message in each case. I'll make a test crate and see what happens currently, and go from there.
Nice catch! I think it might already be on a to-do list somewhere, but I'll make sure of it :) |
I decided the current lint for safe -> unsafe fn is fine here, and just added test cases here and in the adapter: Leaving this issue open until we can lint for safe -> unsafe transitions in Thanks again @aDotInTheVoid! |
For the Also worth noting: |
Awesome, thanks for putting the PR together! I'll hold the next cargo-semver-checks release until that's merged and available in
Oh good call! We definitely want to lint for that. |
…umeGomez rustdoc-json: Include safety of `static`s `static`s in an `extern` block can have an associated safety annotation ["because there is nothing guaranteeing that the bit pattern at the static’s memory is valid for the type it is declared with"](https://doc.rust-lang.org/reference/items/external-blocks.html#statics). Rustdoc already knows this and displays in for HTML. This PR also includes it in JSON. Inspired by obi1kenobi/cargo-semver-checks#975 which needs this, but it's probably useful in other places. r? `@GuillaumeGomez.` Possibly easier to review commit-by-commit.
Rollup merge of rust-lang#133715 - aDotInTheVoid:rdj-static, r=GuillaumeGomez rustdoc-json: Include safety of `static`s `static`s in an `extern` block can have an associated safety annotation ["because there is nothing guaranteeing that the bit pattern at the static’s memory is valid for the type it is declared with"](https://doc.rust-lang.org/reference/items/external-blocks.html#statics). Rustdoc already knows this and displays in for HTML. This PR also includes it in JSON. Inspired by obi1kenobi/cargo-semver-checks#975 which needs this, but it's probably useful in other places. r? `@GuillaumeGomez.` Possibly easier to review commit-by-commit.
A new feature in Rust 1.82+ is the ability to define safe items inside an
unsafe extern
block:https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#safe-items-with-unsafe-extern
Making a previously-safe item become unsafe is a major breaking change, since it now requires
unsafe
at the point of use.At least two lints, and possibly more:
I believe we'll also need additional schema in the adapter to model extern items and show which items are safe vs unsafe. This shouldn't be too difficult to add, though it's an extra step compared to "just writing a lint." For folks new to contributing to Trustfall, I'd recommend first writing another lint that doesn't need this extra step before moving to this issue.
The text was updated successfully, but these errors were encountered: