Skip to content

fix(analyser): move the spans of diagnostic details into the file - #1049

Merged
psteinroe merged 2 commits into
mainfrom
fix/detail-spans-in-file
Nov 1, 2026
Merged

psteinroe merged 2 commits into
mainfrom
fix/detail-spans-in-file

Conversation

@psteinroe

Copy link
Copy Markdown
Collaborator

Follow-up to #952's "Not covered". A lint rule reports spans relative to its statement, and Analyser::analyse moves the diagnostic's span into the file. The spans of its details (LinterDiagnostic::detail(Some(span), ..) and label) stayed relative to the statement, while the printer and the LSP read them as file offsets. No rule passes a detail span today, but the first one that does would show its related information at the wrong place.

What changed

LinterDiagnostic::move_into_file(statement_range) moves the span of the diagnostic and the spans of its details into the file; analyse calls it where it moved the span before. The docs of label/detail say that the span is relative to the statement, like the diagnostic's span.

#952 is open and conflicting with main; it doesn't cover this item, so this PR is based on main. Its debug_assert_in_statement could check the detail spans too once both are in.

Tests

diagnostics_move_into_the_file: a diagnostic with a span, a detail with a span and one without, and a diagnostic without a span (it points at the statement). cargo test -p pgls_analyser, cargo clippy --workspace --all-targets -- -D warnings.

…il-spans-in-file

# Conflicts:
#	crates/pgls_analyser/src/lib.rs
@psteinroe
psteinroe merged commit a8c6cad into main Nov 1, 2026
12 checks passed
@psteinroe
psteinroe deleted the fix/detail-spans-in-file branch November 1, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant