Skip to content

[Rust Goals 2027] Macro safety #583

Description

@pellico

This is tracking issue regarding potential topic to be discussed with Rust project. (Rust Safety Coding Guidelines meeting 4/3/2026)

Rust macro can generate a lot of code and it is straightforward to guarantee the correctness in safety critical application:

There are two main line of reasoning:

  1. Expand macro and apply the same guidelines and process for generated code (e.g. test coverage, delta review ...).
    This is a accepted method for C macro and other code generator but it requires that expanded code can be compiled with same semantic.
  2. Apply strict macro guidelines and usage limitation.
    This doesn't require any technical change in Rust tooling but there is not yet a wide agreement that by just coding guidelines is possible to guarantee code correctness.

Personally I prefer the first solution because it is the most convincing and easy to justify but it looks like that this requires a significant change in the Rust compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions