Skip to content
/ rust Public
forked from rust-lang/rust

Commit

Permalink
Fix substitution parts having a shifted underline in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ShE3py committed Apr 25, 2024
1 parent 865808b commit b52e4bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ impl HumanEmitter {
let offset: isize = offsets
.iter()
.filter_map(
|(start, v)| if span_start_pos <= *start { None } else { Some(v) },
|(start, v)| if span_start_pos < *start { None } else { Some(v) },
)
.sum();
let underline_start = (span_start_pos + start) as isize + offset;
Expand All @@ -2028,7 +2028,7 @@ impl HumanEmitter {
let padding: usize = max_line_num_len + 3;
for p in underline_start..underline_end {
if let DisplaySuggestion::Underline = show_code_change {
// If this is a replacement, underline with `^`, if this is an addition
// If this is a replacement, underline with `~`, if this is an addition
// underline with `+`.
buffer.putc(
row_num,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/parser/issues/issue-32505.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | foo(|_|)
help: you might have meant to open the body of the closure
|
LL | foo(|_| {})
| ++
| ++

error[E0425]: cannot find function `foo` in this scope
--> $DIR/issue-32505.rs:2:5
Expand Down

0 comments on commit b52e4bd

Please sign in to comment.