Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Sep 27, 2025

Fixes #24082

Makes local warning suppression aware of inlined positions.

How does @nowarn know what to suppress? A Suppression is registered with the current Run, and when reporting, a Suppression matches a given diagnostic based on position. The diagnostic position knows its "enclosing" inlined positions, so a suppression should also match those positions.

@som-snytt som-snytt force-pushed the issue/24082-nowarn-inline branch 4 times, most recently from 8cc8b05 to 5f74d71 Compare October 2, 2025 18:14
@som-snytt
Copy link
Contributor Author

It's no longer a one-liner. The motivation to refactor is in the commit to "use adjusted pos": it's hard to keep track of what position is used at any point.

To summarize, there is the pos of the diagnostic (which is arbitrary), the adjusted position to render at (the most specific pos at the user call site, adjusted at EOF), and the positions in the inline stack of the diagnostic pos which are not contained by the user call site (the outermost pos) and which will be displayed in the supplemental stack trace.

Some subtleties include whether the "max line" (for determining the offset of the box, to accommodate the digits) is 10 if the last line is 9 (for error at EOF, as noticed by chance by a test).

There are more intermediate strings to eliminate by using the implicit StringBuilder.

The inlined stack includes the nonInlined pos itself,
which is filtered by rendering.
@som-snytt som-snytt force-pushed the issue/24082-nowarn-inline branch from 5f74d71 to e97e154 Compare October 27, 2025 19:46
@som-snytt
Copy link
Contributor Author

som-snytt commented Oct 27, 2025

Removed the commit that refactors MessageRendering (which can be reintroduced separately).

The third commit here led to that thorough refactoring.

Removed sourcePos.coincidesWith(other), no longer used in this PR.

The previous code was unclear about what pos to adjust.

The diagnostic pos yields an innermost "user pos"
which is adjusted at EOF.

The inline stack is already filtered by position for rendering.
@som-snytt som-snytt force-pushed the issue/24082-nowarn-inline branch from e97e154 to 1bfafe2 Compare October 27, 2025 19:53
@som-snytt som-snytt marked this pull request as ready for review October 27, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nowarn annotation does not work on inlined deprecation warning

1 participant