-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown #97798
Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown #97798
Conversation
This comment has been minimized.
This comment has been minimized.
I'm ok with the results, need to look at the impl, particularly to check that it'll be graceful when handling more than 2 suggested changes in a single suggestion. |
compiler/rustc_errors/src/emitter.rs
Outdated
let print_line = |line_pos: usize, | ||
line: &str, | ||
highlight_parts: &Vec<SubstitutionHighlight>, | ||
buffer: &mut StyledBuffer, | ||
row_num: &mut usize| { |
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.
Maybe moving this to its own method might help with readability.
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 tried, but I'm not sure if it's better, there are a lot of variables / state that needs to be passed around.
e991594
to
1961d9e
Compare
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1); | ||
let mut unhighlighted_lines = Vec::new(); | ||
for (line_pos, (line, highlight_parts)) in lines.by_ref().zip(highlights).enumerate() { | ||
debug!(%line_pos, %line, ?highlight_parts); |
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.
First time I see this, what does %
do? 🤯
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.
It uses Display
instead of Debug
:D
@bors r+ |
📌 Commit 1961d9e has been approved by |
We can modify clippy directly from this repo as well. |
Oh, nice! Didn't know about that. |
…that_are_quite_far_away_from_each_other, r=estebank Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown This is an attempt to fix suggestions one part of which is 6 lines or more far from the first. I've noticed "the problem" (of not showing some parts of the suggestion) here: rust-lang#97759 (comment). I'm not sure about the implementation (this big closure is just bad and makes already complicated code even more so), but I want to at least discuss the result. Here is an example of how this changes the output: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ``` r? `@estebank` `@rustbot` label +A-diagnostics +A-suggestion-diagnostics
Failed in rollup: https://github.com/rust-lang/rust/runs/6897040285?check_suite_focus=true |
!(a & b) = !a | !b
Previously we only show at most 6 lines of suggestions and, if the suggestions are more than 6 lines apart, we've just showed ... at the end. This is probably fine, but quite confusing in my opinion. This commit is an attempt to show ... in places where there is nothing to suggest instead, for example: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ```
I'm not sure if I succeeded
1961d9e
to
e502b9a
Compare
I think it should be fine now |
@bors r=estebank |
📌 Commit e502b9a has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#95392 (std: Stabilize feature try_reserve_2 ) - rust-lang#97798 (Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown) - rust-lang#97844 (Windows: No panic if function not (yet) available) - rust-lang#98013 (Subtype FRU fields first in `type_changing_struct_update`) - rust-lang#98191 (Remove the rest of unnecessary `to_string`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…suggestion_highlight_lines, r=flip1995 Remove `MAX_SUGGESTION_HIGHLIGHT_LINES` After rust-lang#97798 the `MAX_SUGGESTION_HIGHLIGHT_LINES` constant doesn't really make sense since we always show full suggestions. This PR removes last usages of the constant and the constant itself. r? `@flip1995` (this mostly does changes in clippy)
…suggestion_highlight_lines, r=flip1995 Remove `MAX_SUGGESTION_HIGHLIGHT_LINES` After rust-lang#97798 the `MAX_SUGGESTION_HIGHLIGHT_LINES` constant doesn't really make sense since we always show full suggestions. This PR removes last usages of the constant and the constant itself. r? ``@flip1995`` (this mostly does changes in clippy)
…that_are_quite_far_away_from_each_other, r=estebank Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown This is an attempt to fix suggestions one part of which is 6 lines or more far from the first. I've noticed "the problem" (of not showing some parts of the suggestion) here: rust-lang#97759 (comment). I'm not sure about the implementation (this big closure is just bad and makes already complicated code even more so), but I want to at least discuss the result. Here is an example of how this changes the output: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ``` r? `@estebank` `@rustbot` label +A-diagnostics +A-suggestion-diagnostics
This is an attempt to fix suggestions one part of which is 6 lines or more far from the first. I've noticed "the problem" (of not showing some parts of the suggestion) here: #97759 (comment).
I'm not sure about the implementation (this big closure is just bad and makes already complicated code even more so), but I want to at least discuss the result.
Here is an example of how this changes the output:
Before:
After:
r? @estebank
@rustbot label +A-diagnostics +A-suggestion-diagnostics