Skip to content

Rust grammar: Doc comments in Rust are actually not comments, therefore shouldn't be marked as such  #20

@alexr00

Description

@alexr00

From @KSXGitHub

Comments are pieces of code that is usually ignored and can be placed anywhere. Doc comments in most languages are usually ignored by the compiler/interpreter. But Rust's so-called "doc comments" are different from normal comments:

  • Under every outer doc (/// ..., /** ... */, or #[doc = "..."]) must be a language item. Otherwise, it is a syntax error.
  • Every inner doc (//! ..., /*! ... */, or #![doc = "..."]) must be placed within a language item. Otherwise, it is a syntax error.
  • Doc comment is just syntactic sugar for the #[doc] attribute.

Suggestion

Doc comment in Rust is a flavor of Markdown, therefore it should be highlighted as a Markdown code snippet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions