Skip to content

rust: add safe keyword #4292

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

fw-immunant
Copy link

@fw-immunant fw-immunant commented Jul 3, 2025

This is a "weak" keyword, only applicable in Rust 2024+ unsafe extern blocks: https://doc.rust-lang.org/reference/keywords.html#r-lex.keywords.weak.safe

Changes

Adds the safe keyword within a mode for unsafe extern blocks.

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

@joshgoebel
Copy link
Member

We'd also need a markup test to show what this syntax looks like in real life and guarantee that your rule is working as intended and that there are no edge cases, etc we need to concern ourselves with.

fw-immunant and others added 2 commits July 3, 2025 14:45
Co-authored-by: Josh Goebel <me@joshgoebel.com>
This is a "weak" keyword, only applicable in Rust 2024+ `unsafe extern` blocks,
immediately prior to the "extern" keyword:

https://doc.rust-lang.org/reference/keywords.html#r-lex.keywords.weak.safe
@fw-immunant
Copy link
Author

I added a test, resulting in an alternative approach that should be more foolproof. Let me know what else is needed, if anything.

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.

3 participants