Skip to content

macro-error: "unexpected token" for test_case attribute with semicolon syntax #21216

@nazmulidris

Description

@nazmulidris

rust-analyzer version

0.3.2702-standalone (VS Code extension, both release and pre-release)

rustc version

rustc 1.93.0-nightly (3ff30e7 2025-11-29)

Relevant settings

Default settings, proc-macros enabled.

Problem

rust-analyzer reports macro-error: unexpected token on #[test_case] attributes that use the semicolon syntax for naming test cases.

The code compiles and runs correctly with cargo test.

Minimal reproduction

// Cargo.toml: test-case = "3"

use test_case::test_case;

#[test_case(80, 1  ; "80 cols = 1 row boundary")]
#[test_case(160, 2 ; "160 cols = 2 row boundary")]
fn my_test(input: u16, expected: u16) {
    assert_eq!(input / 80, expected);
}

Expected behavior

No diagnostic errors — the test_case proc-macro should expand successfully.

Actual behavior

rust-analyzer shows macro-error: unexpected token on the first #[test_case] attribute in each stacked group. Subsequent attributes in the same group don't show errors.

Additionally, because the macro fails to expand, all symbols inside the test function show as "unknown type" (no type inference).

Notes

  • The semicolon syntax (args ; "name") is documented test_case syntax for naming test cases
  • Only the first #[test_case] in a stacked group shows the error
  • cargo check reports no errors
  • The issue appears in VS Code, VS Code Insiders, and VSCodium with both release and pre-release extensions

Workaround

"rust-analyzer.diagnostics.disabled": ["macro-error"]

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