Skip to content

Allow trailing comments on target attribute lines #951

Closed

Description

@LunaStev

Motivation

Target attributes cannot currently carry a comment after their closing delimiter. This makes an ordinary explanatory comment turn a working target condition into an unrelated lexer error on #.

Executed at canonical master d59bdab376bdc04edacdc8029b256cb8d55b5adf, Linux amd64, using the checkout-built compiler with Rust 1.89.0 and LLVM 21.1.8:

#[target(os="linux")] // platform-specific helper
fun helper() {}
fun main() {}
target/debug/wavec check repro.wave --target=x86_64-unknown-linux-gnu --error-format=json

Observed E1001, unexpected character #, at line 1 column 1. A trailing /* explanation */ produces the same failure. Removing the trailing comment succeeds.

Scope

Allow ordinary trailing comments after the existing #[target(...)] form without changing condition syntax. parse_target_attr currently requires the trimmed line to end exactly in )]; the surrounding preprocessor already has comment-aware scanning helpers.

Handle comments lexically so comment markers in quoted attribute values are not mistaken for comments. Preserve comment state, source offsets and newlines, including a block comment continuing onto later lines. Keep attribute-looking text inside comments inert.

Related #645 addressed comments on following lines while finding the controlled declaration; #729 addressed fake attributes inside comments. Neither permits a comment after a real attribute's closing delimiter.

Difficulty: easy to medium; limited to attribute/comment preprocessing and its existing focused tests. No attribute stacking or general syntax redesign is requested.

Completion criteria

  • Active and inactive attributes support trailing line and block comments.
  • Nested/multiline block comments and quoted comment markers do not change target selection.
  • Existing comment-state regressions and LF/CRLF/CR source positions remain covered.
  • Malformed attributes still fail rather than being silently accepted as valid conditions.

Activity

  1. added
    enhancement
    good first issue
    on Oct 18, 2026
  2. added a commit that references this issue on Oct 21, 2026
    42b65e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions