Skip to content

Commit a580d10

Browse files
committed
Fix substitution parts having a shifted underline in some cases
1 parent 89e5eaf commit a580d10

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

compiler/rustc_errors/src/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ impl HumanEmitter {
20192019
let offset: isize = offsets
20202020
.iter()
20212021
.filter_map(
2022-
|(start, v)| if span_start_pos <= *start { None } else { Some(v) },
2022+
|(start, v)| if span_start_pos < *start { None } else { Some(v) },
20232023
)
20242024
.sum();
20252025
let underline_start = (span_start_pos + start) as isize + offset;

tests/ui/parser/issues/issue-24375.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | tmp[0] => {}
77
help: check the value in an arm guard
88
|
99
LL | val if val == tmp[0] => {}
10-
| ~~~ ++++++++++++++++
10+
| ~~~ ++++++++++++++++
1111
help: extract the expression into a `const` and refer to it
1212
|
1313
LL + const VAL: _ = tmp[0];

tests/ui/parser/issues/issue-32505.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | foo(|_|)
99
help: you might have meant to open the body of the closure
1010
|
1111
LL | foo(|_| {})
12-
| ++
12+
| ++
1313

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

tests/ui/parser/recover/recover-pat-exprs.stderr

+20-20
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ LL | x._0 => (),
5858
help: check the value in an arm guard
5959
|
6060
LL | val if val == x._0 => (),
61-
| ~~~ ++++++++++++++
61+
| ~~~ ++++++++++++++
6262
help: extract the expression into a `const` and refer to it
6363
|
6464
LL + const VAL: _ = x._0;
@@ -82,7 +82,7 @@ LL | x.0.1 => (),
8282
help: check the value in an arm guard
8383
|
8484
LL | val if val == x.0.1 => (),
85-
| ~~~ +++++++++++++++
85+
| ~~~ +++++++++++++++
8686
help: extract the expression into a `const` and refer to it
8787
|
8888
LL + const VAL: _ = x.0.1;
@@ -106,7 +106,7 @@ LL | x.4.y.17.__z => (),
106106
help: check the value in an arm guard
107107
|
108108
LL | val if val == x.4.y.17.__z => (),
109-
| ~~~ ++++++++++++++++++++++
109+
| ~~~ ++++++++++++++++++++++
110110
help: extract the expression into a `const` and refer to it
111111
|
112112
LL + const VAL: _ = x.4.y.17.__z;
@@ -130,7 +130,7 @@ LL | x.f() => (),
130130
help: check the value in an arm guard
131131
|
132132
LL | val if val == x.f() => (),
133-
| ~~~ +++++++++++++++
133+
| ~~~ +++++++++++++++
134134
help: extract the expression into a `const` and refer to it
135135
|
136136
LL + const VAL: _ = x.f();
@@ -151,7 +151,7 @@ LL | x._f() => (),
151151
help: check the value in an arm guard
152152
|
153153
LL | val if val == x._f() => (),
154-
| ~~~ ++++++++++++++++
154+
| ~~~ ++++++++++++++++
155155
help: extract the expression into a `const` and refer to it
156156
|
157157
LL + const VAL: _ = x._f();
@@ -173,7 +173,7 @@ LL | x? => (),
173173
help: check the value in an arm guard
174174
|
175175
LL | val if val == x? => (),
176-
| ~~~++++++++++++
176+
| ~~~ ++++++++++++
177177
help: extract the expression into a `const` and refer to it
178178
|
179179
LL + const VAL: _ = x?;
@@ -196,7 +196,7 @@ LL | ().f() => (),
196196
help: check the value in an arm guard
197197
|
198198
LL | val if val == ().f() => (),
199-
| ~~~ ++++++++++++++++
199+
| ~~~ ++++++++++++++++
200200
help: extract the expression into a `const` and refer to it
201201
|
202202
LL + const VAL: _ = ().f();
@@ -220,7 +220,7 @@ LL | (0, x)?.f() => (),
220220
help: check the value in an arm guard
221221
|
222222
LL | val if val == (0, x)?.f() => (),
223-
| ~~~ +++++++++++++++++++++
223+
| ~~~ +++++++++++++++++++++
224224
help: extract the expression into a `const` and refer to it
225225
|
226226
LL + const VAL: _ = (0, x)?.f();
@@ -244,7 +244,7 @@ LL | x.f().g() => (),
244244
help: check the value in an arm guard
245245
|
246246
LL | val if val == x.f().g() => (),
247-
| ~~~ +++++++++++++++++++
247+
| ~~~ +++++++++++++++++++
248248
help: extract the expression into a `const` and refer to it
249249
|
250250
LL + const VAL: _ = x.f().g();
@@ -268,7 +268,7 @@ LL | 0.f()?.g()?? => (),
268268
help: check the value in an arm guard
269269
|
270270
LL | val if val == 0.f()?.g()?? => (),
271-
| ~~~ ++++++++++++++++++++++
271+
| ~~~ ++++++++++++++++++++++
272272
help: extract the expression into a `const` and refer to it
273273
|
274274
LL + const VAL: _ = 0.f()?.g()??;
@@ -292,7 +292,7 @@ LL | x as usize => (),
292292
help: check the value in an arm guard
293293
|
294294
LL | val if val == x as usize => (),
295-
| ~~~ ++++++++++++++++++++
295+
| ~~~ ++++++++++++++++++++
296296
help: extract the expression into a `const` and refer to it
297297
|
298298
LL + const VAL: _ = x as usize;
@@ -313,7 +313,7 @@ LL | 0 as usize => (),
313313
help: check the value in an arm guard
314314
|
315315
LL | val if val == 0 as usize => (),
316-
| ~~~ ++++++++++++++++++++
316+
| ~~~ ++++++++++++++++++++
317317
help: extract the expression into a `const` and refer to it
318318
|
319319
LL + const VAL: _ = 0 as usize;
@@ -335,7 +335,7 @@ LL | x.f().0.4 as f32 => (),
335335
help: check the value in an arm guard
336336
|
337337
LL | val if val == x.f().0.4 as f32 => (),
338-
| ~~~ ++++++++++++++++++++++++++
338+
| ~~~ ++++++++++++++++++++++++++
339339
help: extract the expression into a `const` and refer to it
340340
|
341341
LL + const VAL: _ = x.f().0.4 as f32;
@@ -358,7 +358,7 @@ LL | 1 + 1 => (),
358358
help: check the value in an arm guard
359359
|
360360
LL | val if val == 1 + 1 => (),
361-
| ~~~ +++++++++++++++
361+
| ~~~ +++++++++++++++
362362
help: extract the expression into a `const` and refer to it
363363
|
364364
LL + const VAL: _ = 1 + 1;
@@ -379,7 +379,7 @@ LL | (1 + 2) * 3 => (),
379379
help: check the value in an arm guard
380380
|
381381
LL | val if val == (1 + 2) * 3 => (),
382-
| ~~~ +++++++++++++++++++++
382+
| ~~~ +++++++++++++++++++++
383383
help: extract the expression into a `const` and refer to it
384384
|
385385
LL + const VAL: _ = (1 + 2) * 3;
@@ -418,7 +418,7 @@ LL | u8::MAX.abs() => (),
418418
help: check the value in an arm guard
419419
|
420420
LL | val if val == u8::MAX.abs() => (),
421-
| ~~~ +++++++++++++++++++++++
421+
| ~~~ +++++++++++++++++++++++
422422
help: extract the expression into a `const` and refer to it
423423
|
424424
LL + const VAL: _ = u8::MAX.abs();
@@ -439,7 +439,7 @@ LL | z @ w @ v.u() => (),
439439
help: check the value in an arm guard
440440
|
441441
LL | z @ w @ val if val == v.u() => (),
442-
| ~~~ +++++++++++++++
442+
| ~~~ +++++++++++++++
443443
help: extract the expression into a `const` and refer to it
444444
|
445445
LL + const VAL: _ = v.u();
@@ -463,7 +463,7 @@ LL | y.ilog(3) => (),
463463
help: check the value in an arm guard
464464
|
465465
LL | val if val == y.ilog(3) => (),
466-
| ~~~ +++++++++++++++++++
466+
| ~~~ +++++++++++++++++++
467467
help: extract the expression into a `const` and refer to it
468468
|
469469
LL + const VAL: _ = y.ilog(3);
@@ -487,7 +487,7 @@ LL | n + 1 => (),
487487
help: check the value in an arm guard
488488
|
489489
LL | val if val == n + 1 => (),
490-
| ~~~ +++++++++++++++
490+
| ~~~ +++++++++++++++
491491
help: extract the expression into a `const` and refer to it
492492
|
493493
LL + const VAL: _ = n + 1;
@@ -535,7 +535,7 @@ LL | f?() => (),
535535
help: check the value in an arm guard
536536
|
537537
LL | val if val == f?() => (),
538-
| ~~~ ++++++++++++++
538+
| ~~~ ++++++++++++++
539539
help: extract the expression into a `const` and refer to it
540540
|
541541
LL + const VAL: _ = f?();

tests/ui/parser/recover/recover-pat-ranges.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ LL | ..=1 + 2 => (),
9191
help: check the value in an arm guard
9292
|
9393
LL | ..=val if val == 1 + 2 => (),
94-
| ~~~ +++++++++++++++
94+
| ~~~ +++++++++++++++
9595
help: extract the expression into a `const` and refer to it
9696
|
9797
LL + const VAL: _ = 1 + 2;
@@ -163,7 +163,7 @@ LL | (1 + 4)...1 * 2 => (),
163163
help: check the value in an arm guard
164164
|
165165
LL | (1 + 4)...val if val == 1 * 2 => (),
166-
| ~~~ +++++++++++++++
166+
| ~~~ +++++++++++++++
167167
help: extract the expression into a `const` and refer to it
168168
|
169169
LL + const VAL: _ = 1 * 2;
@@ -211,7 +211,7 @@ LL | 0.x()..="y".z() => (),
211211
help: check the value in an arm guard
212212
|
213213
LL | 0.x()..=val if val == "y".z() => (),
214-
| ~~~ +++++++++++++++++
214+
| ~~~ +++++++++++++++++
215215
help: extract the expression into a `const` and refer to it
216216
|
217217
LL + const VAL: _ = "y".z();

0 commit comments

Comments
 (0)