-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace tabs earlier in diagnostics #79757
Replace tabs earlier in diagnostics #79757
Conversation
It was not enough to just edit places where we check Unicode width, as many other margin calculations are also impacted. This approach seems like the simplest thing I could think of given the problem we're trying to solve. I did also experiment with wrapper types to clearly delineate the different kinds of lengths / offsets, but it's much more verbose and a much larger change, which I am not sure is worth the trouble. I believe it would avoid the string copy though. |
04aa312
to
485efb1
Compare
485efb1
to
507cabd
Compare
Ah, hmm, I guess there are a few remaining failures because some tabs were making it through to Anyway, I'm curious what you think about the approach generally. If it seems broadly okay, I'll adjust things further to fix up the remaining tests. |
let s = self.styles[line_pos].remove(*pos); | ||
for _ in 0..4 { | ||
line.insert(*pos, ' '); | ||
self.styles[line_pos].insert(*pos, s); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly concerned by this removal. Have you tried to see the output in your local CLI? I need to double check the code, but can you confirm that the underlines are all colored correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chances look reasonable, I need to read it again to make sure that everything is correct, but provisionally r=me. Could you address @pickfire's comment about |
507cabd
to
ad0a30e
Compare
@estebank Thanks for the initial look! 😄 This should now be ready for a full review. Changes since last time:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This replaces tabs earlier in the diagnostics emitting process, which allows various margin calculations to ignore the existence of tabs. It does add a string copy for the source lines that are emitted.
ad0a30e
to
3537bd8
Compare
I made a small cleanup change after @pickfire's latest review:
|
@estebank Just a friendly reminder that this is ready for another review. 😄 I’m hoping to work my way up to eventually helping with the review load as well. |
// Tabs are assumed to have been replaced by spaces in calling code. | ||
assert!(!source_string.contains('\t')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit heavy handed but ok with me (I will assume we'll see reports on nightly if this causes issues before it hits stable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, mostly I just wanted it to be ultra clear to future code readers which paths should not have tabs, but it could be relaxed to a comment of course. I'll check json
output now.
No worries! Apologies, I was offline for all of December, which is why my personal queue has grown dramatically 😅 The changes look all great. I'm approving, but could you also check that the Super happy to see this fixed! |
@bors r+ |
📌 Commit 3537bd8 has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#79757 (Replace tabs earlier in diagnostics) - rust-lang#80600 (Add `MaybeUninit` method `array_assume_init`) - rust-lang#80880 (Move some tests to more reasonable directories) - rust-lang#80897 (driver: Use `atty` instead of rolling our own) - rust-lang#80898 (Add another test case for rust-lang#79808) - rust-lang#80917 (core/slice: remove doc comment about scoped borrow) - rust-lang#80927 (Replace a simple `if let` with the `matches` macro) - rust-lang#80930 (fix typo in trait method mutability mismatch help) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
@estebank I couldn't find any
|
The tab replacement for diagnostics added in rust-lang#79757 included a few assertions to ensure all tab characters are handled appropriately. We've started getting reports of these assertions firing (rust-lang#81614). Since it's only a cosmetic issue, this downgrades the assertions to debug only, so we at least continue compiling even if the diagnostics might be a tad wonky. Fixes rust-lang#81614
…tebank Reduce tab formatting assertions to debug only The tab replacement for diagnostics added in rust-lang#79757 included a few assertions to ensure all tab characters are handled appropriately. We've started getting reports of these assertions firing (rust-lang#81614). Since it's only a cosmetic issue, this downgrades the assertions to debug only, so we at least continue compiling even if the diagnostics might be a tad wonky. Minimizes the impact of rust-lang#81614
This replaces tabs earlier in the diagnostics emitting process, which allows various margin calculations to ignore the existence of tabs. It does add a string copy for the source lines that are emitted.
Fixes #78438
r? @estebank