Skip to content

Conversation

@relaxcn
Copy link
Contributor

@relaxcn relaxcn commented Oct 16, 2025

While fixing the issue rust-lang/rust-clippy#15883 from rust-clippy, I tracked it down to a problem in rustc where line numbers were incorrect when building trimmed multi-line suggestions.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2025
@rust-log-analyzer

This comment has been minimized.

@Kivooeo
Copy link
Member

Kivooeo commented Oct 16, 2025

You have to update tests with ./x test ui --bless

Also, I'm not sure if this a rustc problem, because issue you reffering is from clippy, which is slightly different project, so would be nice if you could give a small explanation of what exactly you trying to fix, maybe example of current incorrect behavior or something

@relaxcn
Copy link
Contributor Author

relaxcn commented Oct 16, 2025

You have to update tests with ./x test ui --bless

Also, I'm not sure if this a rustc problem, because issue you reffering is from clippy, which is slightly different project, so would be nice if you could give a small explanation of what exactly you trying to fix, maybe example of current incorrect behavior or something

Thank you, I forgot it.

I'm sure the issue is from rustc. But this PR has some problems I will continue to solve it tomorrow.

clippy uses the API from rustc_errors, I researched the issue and found the bug point.

@Muscraft
Copy link
Member

I came across this PR and realized that annotate-snippets also had the same bug, and figured it would be a good idea to share how I fixed it within annotate-snippets, since its internals closely match rustc. Because of those changes, I ended up with with a partial port of that fix for rustc, which might be useful as well.

@relaxcn
Copy link
Contributor Author

relaxcn commented Oct 17, 2025

I came across this PR and realized that annotate-snippets also had the same bug, and figured it would be a good idea to share how I fixed it within annotate-snippets, since its internals closely match rustc. Because of those changes, I ended up with with a partial port of that fix for rustc, which might be useful as well.

Thank you. It sounds a little bit complex for me. I need some times to understand those changes in your PR.

But I think it's very useful, thank you again!

Tracking original span was my initial idea (I thought this was a small bug before😂)

@relaxcn relaxcn marked this pull request as ready for review October 19, 2025 15:38
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 19, 2025

rustc_errors::emitter was changed

cc @Muscraft

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 19, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@relaxcn relaxcn changed the title fix suggestion snippet line number wrong fix incorrect line number when building trimmed multi-line suggestions Oct 19, 2025
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 20, 2025

📌 Commit ad67c9d has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 20, 2025
bors added a commit that referenced this pull request Oct 20, 2025
Rollup of 4 pull requests

Successful merges:

 - #147577 (Improve error message for ambiguous numeric types in closure parameters)
 - #147785 (fix incorrect line number when building trimmed multi-line suggestions)
 - #147814 (btree: some cleanup with less unsafe)
 - #147843 (Change the tidy license checker)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1bb91de into rust-lang:master Oct 20, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 20, 2025
rust-timer added a commit that referenced this pull request Oct 20, 2025
Rollup merge of #147785 - relaxcn:emitter_sugg_line, r=petrochenkov

fix incorrect line number when building trimmed multi-line suggestions

While fixing the issue rust-lang/rust-clippy#15883 from `rust-clippy`, I tracked it down to a problem in `rustc` where line numbers were incorrect when building trimmed multi-line suggestions.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Oct 20, 2025
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#147577 (Improve error message for ambiguous numeric types in closure parameters)
 - rust-lang/rust#147785 (fix incorrect line number when building trimmed multi-line suggestions)
 - rust-lang/rust#147814 (btree: some cleanup with less unsafe)
 - rust-lang/rust#147843 (Change the tidy license checker)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants