Safety-Critical Rust Coding Guidelines

Contents:

  • Introduction
  • Overview
  • Coding Guidelines
    • Types and Traits
    • Patterns
    • Expressions
      • Do not use an integer type as a divisor during integer division
      • The ‘as’ operator should not be used with numeric operands
      • Example guideline with bibliography (gui_Bib7x9KmPq2nL)
      • Example guideline with bibliography (gui_Bob7x9KmPq2nL)
      • Avoid as underscore pointer casts
      • Avoid out-or-range shifts
      • An integer shall not be converted to a pointer
      • Do not shift an expression by a negative number of bits or by greater than or equal to the bitwidth of the operand
      • Ensure that integer operations do not result in arithmetic overflow
      • An integer shall not be converted to an invalid pointer
      • Do not divide by 0
    • Values
    • Statements
    • Functions
    • Associated Items
    • Implementations
    • Generics
    • Attributes
    • Entities And Resolution
    • Ownership And Destruction
    • Exceptions And Errors
    • Concurrency
    • Program Structure And Compilation
    • Unsafety
    • Macros
    • Ffi
    • Inline Assembly
  • Compliance
  • Process
  • Appendices
  • Retired Guidelines
Safety-Critical Rust Coding Guidelines
  • Coding Guidelines
  • Expressions
  • View page source

Expressions

  • Do not use an integer type as a divisor during integer division
  • The ‘as’ operator should not be used with numeric operands
  • Example guideline with bibliography (gui_Bib7x9KmPq2nL)
  • Example guideline with bibliography (gui_Bob7x9KmPq2nL)
  • Avoid as underscore pointer casts
  • Avoid out-or-range shifts
  • An integer shall not be converted to a pointer
  • Do not shift an expression by a negative number of bits or by greater than or equal to the bitwidth of the operand
  • Ensure that integer operations do not result in arithmetic overflow
  • An integer shall not be converted to an invalid pointer
  • Do not divide by 0
Previous Next

© Copyright 2025, Contributors to Coding Guidelines Subcommittee.

Built with Sphinx using a theme provided by Read the Docs. This site is powered through Netlify.