Skip to content

Conversation

@PLeVasseur
Copy link
Collaborator

Hey folks 👋

Sorry for the massive PR. I plan to demo this and walk through it a bit in our next meeting to aid in getting proper context to review it.

Content

  • Initial mechanisms for creating both human-readable HTML and machine-parseable JSON files.
  • One real-ish guideline.
  • Reading the README.md and README.rst will also help frame the content.

ToDo (@PLeVasseur) before merge

  • Add CI to allow the build to break should something change upstream in the Ferrocene Language Specification.

closes rustfoundation/safety-critical-rust-coding-guidelines#5

@PLeVasseur PLeVasseur requested a review from JoelMarcey March 11, 2025 03:00
@PLeVasseur PLeVasseur force-pushed the feature/prototype-coding-guidelines-sphinx-needs branch from 8839f4d to 4830618 Compare March 11, 2025 03:01
@adfernandes
Copy link
Contributor

adfernandes commented Mar 12, 2025

Thanks, @PLeVasseur... I've been meaning to dive into sphinx-needs for quite a while, so maybe this is the push (ha ha, pardon the pun) I need...

Types and Traits
================

.. guideline:: Avoid Implicit Integer Wrapping
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid doesn't sound like a requirement but the MUST below does. Follow something like https://datatracker.ietf.org/doc/html/rfc2119 to define the meaning of terms you use in the coding standard. Also follow the update from https://datatracker.ietf.org/doc/html/rfc8174

Copy link
Contributor

Choose a reason for hiding this comment

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

There may also be some cases where you want modulo behavior so you need an exception to this rule and someway for the developer to indicate that they want modulo behavior to suppress a tool diagnostic.


Code must not rely on Rust's implicit integer wrapping behavior that occurs in release builds.
Instead, explicitly handle potential overflows using the standard library's checked,
saturating, or wrapping operations.
Copy link
Contributor

Choose a reason for hiding this comment

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

or ensure integer operations don't overflow. I don't know rust very well, but if you have (int i = 0, i < 10; i++) there is not need to explicitly handle overflows because none are possible.

configurations. Explicit handling of potential overflow conditions improves code clarity,
maintainability, and reduces the risk of numerical errors in production.

.. bad_example::
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what bad_example expands to. Usually we would call this a "noncompliant example"

@PLeVasseur PLeVasseur force-pushed the feature/prototype-coding-guidelines-sphinx-needs branch 2 times, most recently from 3a2040f to 0b256af Compare March 14, 2025 17:59
@PLeVasseur PLeVasseur force-pushed the feature/prototype-coding-guidelines-sphinx-needs branch from 0b256af to ba215f0 Compare March 14, 2025 18:10
@PLeVasseur PLeVasseur force-pushed the feature/prototype-coding-guidelines-sphinx-needs branch from 7d015b1 to 7019df4 Compare March 14, 2025 18:34
@PLeVasseur
Copy link
Collaborator Author

Looks like I have some initial CI working for PRs and nightly. Soliciting any other feedback!

By the way, thanks for the feedback @rcseacord. I am considering processing this in a follow-up PR and opening some issues to track your thoughts.

@PLeVasseur
Copy link
Collaborator Author

Closing this one as we have spun off the safety-critical-rust-coding-guidelines repo.

@PLeVasseur PLeVasseur closed this Mar 19, 2025
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.

Initial coding guidelines proposal stood up

4 participants