aft icon indicating copy to clipboard operation
aft copied to clipboard

Rust diagnostics still provisional on 0.65.0 when an include macro has an ident parameter (follow-up to #1425)

Open elmagow opened this issue 2 weeks ago • 2 comments

What happened?

Follow-up to #1425 (closed; I can't reopen it). On v0.65.0, aft_inspect Rust diagnostics in our workspace are still permanently PARTIAL ... diagnostics are provisional. The fingerprint walk still stops at the same file:

INFO rust check fingerprint walk root=<workspace> examined=642 complete=false last=<workspace>/crates/<crate>/src/<module>/<file>.rs elapsed_ms=298

The 0.65.0 fix resolves include macros whose parameters are all literal or expr. Ours also takes an ident parameter for the generated test name:

macro_rules! fixture_test {
    ($name:ident, $fixture:expr, $expr:expr) => {
        #[test]
        fn $name() {
            let expected = include_str!(concat!("../../tests/fixtures/<dir>/", $fixture));
            // ...
        }
    };
}

fixture_test!(case_a, "a.json", make_a());

Cause (from crates/aft/src/lsp/completed_rust_check/inputs.rs at v0.65.0)

parameters() accepts only $x:literal and $x:expr fragments and returns None for any other kind:

[Token::Text(name), colon, kind]
    if name.starts_with('$')
        && colon.text(":")
        && (kind.text("literal") || kind.text("expr")) => { ... }
_ => return None,

So definition.parameters is None, and every invocation of the macro then hits the refusal in the invocation loop (definition.parameters.is_none() || invocation.nested → refuse), even though $name never appears inside the include_str! arguments. One such test macro keeps the whole workspace provisional, the same outcome as before 0.65.0.

Possible fix

Record each parameter's fragment kind instead of rejecting other kinds outright. Refuse only when a parameter that is not literal or expr is used inside an include's arguments. Parameters only used elsewhere in the body (ident for a test name, ty, tt, block, ...) cannot change the include path. The binding step would then skip those positions in the invocation's arguments, as it already does for the positions it maps.

Regression test idea: reporter_fixture_macro_tracks_all_literal_invocations_across_files with the matcher changed to ($name:ident, $fixture:literal) => { const $name: &str = include_str!(concat!("../../tests/fixtures/", $fixture)); }. It should still track exactly a.txt and b.txt.

This follows from reading the v0.65.0 source and our log; I have not built a separate demo crate.

Versions

  • AFT plugin: @cortexkit/aft-opencode 0.65.0
  • AFT binary: 0.65.0
  • OpenCode: 2.3.0
  • Platform: darwin arm64
  • rust-analyzer 1.100.0

elmagow avatar Nov 14 '26 16:11 elmagow

Thanks for checking, and for pinning down the cause. You're right: parameters() accepts only literal and expr fragments, so a macro with an ident parameter can't be resolved at all, even when that parameter never reaches the include path.

The fix records each parameter's kind and refuses only when a parameter that could change the path (anything other than literal or expr) is used inside the include's arguments. Parameters used elsewhere in the body, such as a test name, a type or a block, are skipped when the invocation's arguments are matched. Your shape ($name:ident, $fixture:expr, $expr:expr) is covered by a regression test.

We'll track it here and close this issue once the fix is released.

aft-alfonso[bot] avatar Nov 14 '26 16:11 aft-alfonso[bot]

Fixed in v0.66.0: an include macro's parameters that don't appear in the include path no longer keep Rust diagnostics provisional. Thanks for the precise report, @elmagow. If a workspace still reports PARTIAL on 0.66.0, please reopen with the macro.

aft-alfonso[bot] avatar Nov 17 '26 09:11 aft-alfonso[bot]