Skip to content

[Coding Rule]: assure visibility of unsafe keyword in unsafe code#358

Merged
plaindocs merged 9 commits into
Safety-Critical-Rust-Consortium:mainfrom
rcseacord:guideline/unsafetoken
Feb 18, 2026
Merged

[Coding Rule]: assure visibility of unsafe keyword in unsafe code#358
plaindocs merged 9 commits into
Safety-Critical-Rust-Consortium:mainfrom
rcseacord:guideline/unsafetoken

Conversation

@rcseacord

Copy link
Copy Markdown
Collaborator

Created PR for #252 by @workingjubilee

@netlify

netlify Bot commented Jan 2, 2026

Copy link
Copy Markdown

Deploy Preview for scrc-coding-guidelines ready!

Name Link
🔨 Latest commit fe6c44f
🔍 Latest deploy log https://app.netlify.com/projects/scrc-coding-guidelines/deploys/697fe58b63e6dc0008c5b684
😎 Deploy Preview https://deploy-preview-358--scrc-coding-guidelines.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rcseacord rcseacord changed the title [Coding Rule]: assure visibility of unsafe tokens in unsafe code [Coding Rule]: assure visibility of unsafe keyword in unsafe code Jan 4, 2026
rcseacord and others added 8 commits February 2, 2026 07:04
Updated guideline to ensure visibility of unsafe tokens in unsafe code, reflecting changes in Rust Edition 2024. Added rationale and examples to clarify requirements.
Update guideline to ensure visibility of 'unsafe' keyword in unsafe code, reflecting changes in Rust Edition 2024.
Clarify issues with using #[export_name] and #[link_section] attributes without unsafe wrappers in Rust 2024.
Removed visibility section and updated examples for compliance with Rust Edition 2024. Clarified unsafe usage in function declarations and attributes.
Removed exceptions section and added safety notes for unsafe attributes.
@PLeVasseur
PLeVasseur force-pushed the guideline/unsafetoken branch from d8d653b to e1044d5 Compare February 1, 2026 22:31
@felix91gr felix91gr added the coding guideline An issue related to a suggestion for a coding guideline label Feb 10, 2026
@felix91gr felix91gr added coding guideline An issue related to a suggestion for a coding guideline and removed coding guideline An issue related to a suggestion for a coding guideline labels Feb 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @darkwisebear! You've been assigned to review this coding guideline PR.

Your Role as Reviewer

As outlined in our contribution guide, please:

  1. Begin your review within 14 days
  2. Provide constructive feedback on the guideline content, examples, and formatting
  3. Iterate with @rcseacord - they may update the PR based on your feedback
  4. When the guideline is ready, approve and add to the merge queue

Review Checklist

  • Guideline title is clear and follows conventions
  • Amplification section expands on the title appropriately
  • Rationale explains the "why" effectively
  • Non-compliant example(s) clearly show the problem
  • Compliant example(s) clearly show the solution
  • Code examples compile (check the CI results)
  • FLS paragraph ID is correct

Bot Commands

If you need to pass this review:

  • @guidelines-bot /pass [reason] - Pass just this PR to the next reviewer
  • @guidelines-bot /away YYYY-MM-DD [reason] - Step away from the queue until a date
  • @guidelines-bot /release [@username] [reason] - Release assignment (yours or someone else's with triage+ permission)

To assign someone else:

  • @guidelines-bot /r? @username - Assign a specific reviewer
  • @guidelines-bot /r? producers - Request the next reviewer from the queue

Other commands:

  • @guidelines-bot /claim - Claim this review for yourself
  • @guidelines-bot /label +label-name - Add a label
  • @guidelines-bot /label -label-name - Remove a label
  • @guidelines-bot /queue - Show reviewer queue
  • @guidelines-bot /commands - Show all available commands

@darkwisebear darkwisebear left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, I'd be in favor of merging, the comments are merely nits and minor things. I can't click the stuff in the checklist, consider them clicked.


unsafe extern "C" {
// Here the assumption is that malloc is the one defined by C's stdlib.h
// and that size_of::<usize>() == size_of::<size_t>()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May be a bit picky, but this should probably be asserted on, as in const { assert!(std::mem::size_of::<usize>() == std::mem::size_of::<libc::size_t>()); } or just replace usize with libc::size_t to not contradict to #225.

:id: gui_ZDLZzjeOwLSU
:category: required
:status: draft
:release: 1.85-latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Afaiu this rule is only meaningful for edition <2024. If this is correct, should we add this to the metadata in this section? Would we need a new metdata field for this?

Comment on lines +252 to +256
* **Static Analysis Tools**:

* ``cargo-geiger`` - Counts and reports unsafe code usage
* ``cargo-audit`` - Checks for known vulnerabilities in dependencies
* Custom Clippy lints for project-specific requirements

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While this part is informative, it's not helping enforcing the rule. I think this should be moved from this section.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Rectified PR #358: latest review by @darkwisebear is COMMENTED; refreshed reviewer activity.

@plaindocs plaindocs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving on behalf of @darkwisebear to get this merged.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Rectified PR #358: latest review by @darkwisebear is COMMENTED; refreshed reviewer activity.

@plaindocs
plaindocs added this pull request to the merge queue Feb 18, 2026
@plaindocs

Copy link
Copy Markdown
Collaborator

@darkwisebear please open an issue with the remaining nits 🙇‍♂️

Merged via the queue into Safety-Critical-Rust-Consortium:main with commit 1c7d6bb Feb 18, 2026
17 checks passed
@PLeVasseur
PLeVasseur deleted the guideline/unsafetoken branch February 18, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chapter: unsafety coding guideline An issue related to a suggestion for a coding guideline

Development

Successfully merging this pull request may close these issues.

6 participants