Skip to content

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 26, 2024
1 parent 89e5eaf commit a580d10
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 1 addition & 1 deletion tests/ui/parser/issues/issue-24375.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | tmp[0] => {}
help: check the value in an arm guard
|
LL | val if val == tmp[0] => {}
| ~~~ ++++++++++++++++
| ~~~ ++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = tmp[0];
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
40 changes: 20 additions & 20 deletions tests/ui/parser/recover/recover-pat-exprs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ LL | x._0 => (),
help: check the value in an arm guard
|
LL | val if val == x._0 => (),
| ~~~ ++++++++++++++
| ~~~ ++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x._0;
Expand All @@ -82,7 +82,7 @@ LL | x.0.1 => (),
help: check the value in an arm guard
|
LL | val if val == x.0.1 => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x.0.1;
Expand All @@ -106,7 +106,7 @@ LL | x.4.y.17.__z => (),
help: check the value in an arm guard
|
LL | val if val == x.4.y.17.__z => (),
| ~~~ ++++++++++++++++++++++
| ~~~ ++++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x.4.y.17.__z;
Expand All @@ -130,7 +130,7 @@ LL | x.f() => (),
help: check the value in an arm guard
|
LL | val if val == x.f() => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x.f();
Expand All @@ -151,7 +151,7 @@ LL | x._f() => (),
help: check the value in an arm guard
|
LL | val if val == x._f() => (),
| ~~~ ++++++++++++++++
| ~~~ ++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x._f();
Expand All @@ -173,7 +173,7 @@ LL | x? => (),
help: check the value in an arm guard
|
LL | val if val == x? => (),
| ~~~++++++++++++
| ~~~ ++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x?;
Expand All @@ -196,7 +196,7 @@ LL | ().f() => (),
help: check the value in an arm guard
|
LL | val if val == ().f() => (),
| ~~~ ++++++++++++++++
| ~~~ ++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = ().f();
Expand All @@ -220,7 +220,7 @@ LL | (0, x)?.f() => (),
help: check the value in an arm guard
|
LL | val if val == (0, x)?.f() => (),
| ~~~ +++++++++++++++++++++
| ~~~ +++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = (0, x)?.f();
Expand All @@ -244,7 +244,7 @@ LL | x.f().g() => (),
help: check the value in an arm guard
|
LL | val if val == x.f().g() => (),
| ~~~ +++++++++++++++++++
| ~~~ +++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x.f().g();
Expand All @@ -268,7 +268,7 @@ LL | 0.f()?.g()?? => (),
help: check the value in an arm guard
|
LL | val if val == 0.f()?.g()?? => (),
| ~~~ ++++++++++++++++++++++
| ~~~ ++++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = 0.f()?.g()??;
Expand All @@ -292,7 +292,7 @@ LL | x as usize => (),
help: check the value in an arm guard
|
LL | val if val == x as usize => (),
| ~~~ ++++++++++++++++++++
| ~~~ ++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x as usize;
Expand All @@ -313,7 +313,7 @@ LL | 0 as usize => (),
help: check the value in an arm guard
|
LL | val if val == 0 as usize => (),
| ~~~ ++++++++++++++++++++
| ~~~ ++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = 0 as usize;
Expand All @@ -335,7 +335,7 @@ LL | x.f().0.4 as f32 => (),
help: check the value in an arm guard
|
LL | val if val == x.f().0.4 as f32 => (),
| ~~~ ++++++++++++++++++++++++++
| ~~~ ++++++++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = x.f().0.4 as f32;
Expand All @@ -358,7 +358,7 @@ LL | 1 + 1 => (),
help: check the value in an arm guard
|
LL | val if val == 1 + 1 => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = 1 + 1;
Expand All @@ -379,7 +379,7 @@ LL | (1 + 2) * 3 => (),
help: check the value in an arm guard
|
LL | val if val == (1 + 2) * 3 => (),
| ~~~ +++++++++++++++++++++
| ~~~ +++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = (1 + 2) * 3;
Expand Down Expand Up @@ -418,7 +418,7 @@ LL | u8::MAX.abs() => (),
help: check the value in an arm guard
|
LL | val if val == u8::MAX.abs() => (),
| ~~~ +++++++++++++++++++++++
| ~~~ +++++++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = u8::MAX.abs();
Expand All @@ -439,7 +439,7 @@ LL | z @ w @ v.u() => (),
help: check the value in an arm guard
|
LL | z @ w @ val if val == v.u() => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = v.u();
Expand All @@ -463,7 +463,7 @@ LL | y.ilog(3) => (),
help: check the value in an arm guard
|
LL | val if val == y.ilog(3) => (),
| ~~~ +++++++++++++++++++
| ~~~ +++++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = y.ilog(3);
Expand All @@ -487,7 +487,7 @@ LL | n + 1 => (),
help: check the value in an arm guard
|
LL | val if val == n + 1 => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = n + 1;
Expand Down Expand Up @@ -535,7 +535,7 @@ LL | f?() => (),
help: check the value in an arm guard
|
LL | val if val == f?() => (),
| ~~~ ++++++++++++++
| ~~~ ++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = f?();
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/parser/recover/recover-pat-ranges.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ LL | ..=1 + 2 => (),
help: check the value in an arm guard
|
LL | ..=val if val == 1 + 2 => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = 1 + 2;
Expand Down Expand Up @@ -163,7 +163,7 @@ LL | (1 + 4)...1 * 2 => (),
help: check the value in an arm guard
|
LL | (1 + 4)...val if val == 1 * 2 => (),
| ~~~ +++++++++++++++
| ~~~ +++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = 1 * 2;
Expand Down Expand Up @@ -211,7 +211,7 @@ LL | 0.x()..="y".z() => (),
help: check the value in an arm guard
|
LL | 0.x()..=val if val == "y".z() => (),
| ~~~ +++++++++++++++++
| ~~~ +++++++++++++++++
help: extract the expression into a `const` and refer to it
|
LL + const VAL: _ = "y".z();
Expand Down

0 comments on commit a580d10

Please sign in to comment.