-
Couldn't load subscription status.
- Fork 33
Initial commit adding coding guidelines using sphinx-needs #226
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
Initial commit adding coding guidelines using sphinx-needs #226
Conversation
8839f4d to
4830618
Compare
|
Thanks, @PLeVasseur... I've been meaning to dive into |
| Types and Traits | ||
| ================ | ||
|
|
||
| .. guideline:: Avoid Implicit Integer Wrapping |
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.
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
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.
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. |
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.
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:: |
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'm not sure what bad_example expands to. Usually we would call this a "noncompliant example"
3a2040f to
0b256af
Compare
0b256af to
ba215f0
Compare
…uild calls normal build correctly
7d015b1 to
7019df4
Compare
|
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. |
|
Closing this one as we have spun off the safety-critical-rust-coding-guidelines repo. |
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
ToDo (@PLeVasseur) before merge
closes rustfoundation/safety-critical-rust-coding-guidelines#5