Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cc07c35

Browse files
committedApr 21, 2017
Reduce visual clutter of multiline start when possible
When a span starts on a line with nothing but whitespace to the left, and there are no other annotations in that line, simplify the visual representation of the span. Go from: ```rust error[E0072]: recursive type `A` has infinite size --> file2.rs:1:1 | 1 | struct A { | _^ starting here... 2 | | a: A, 3 | | } | |_^ ...ending here: recursive type has infinite size | ``` To: ```rust error[E0072]: recursive type `A` has infinite size --> file2.rs:1:1 | 1 | / struct A { 2 | | a: A, 3 | | } | |_^ recursive type has infinite size ``` Remove `starting here...`/`...ending here` labels from all multiline diagnostics.
1 parent 968ae7b commit cc07c35

26 files changed

+200
-179
lines changed
 

‎src/librustc_errors/emitter.rs

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,41 @@ impl EmitterWriter {
263263

264264
draw_col_separator(buffer, line_offset, width_offset - 2);
265265

266+
// Special case when there's only one annotation involved, it is the start of a multiline
267+
// span and there's no text at the beginning of the code line. Instead of doing the whole
268+
// graph:
269+
//
270+
// 2 | fn foo() {
271+
// | _^
272+
// 3 | |
273+
// 4 | | }
274+
// | |_^ test
275+
//
276+
// we simplify the output to:
277+
//
278+
// 2 | / fn foo() {
279+
// 3 | |
280+
// 4 | | }
281+
// | |_^ test
282+
if line.annotations.len() == 1 {
283+
if let Some(ref ann) = line.annotations.get(0) {
284+
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
285+
if source_string[0..ann.start_col].trim() == "" {
286+
let style = if ann.is_primary {
287+
Style::UnderlinePrimary
288+
} else {
289+
Style::UnderlineSecondary
290+
};
291+
buffer.putc(line_offset,
292+
width_offset + depth - 1,
293+
'/',
294+
style);
295+
return vec![(depth, style)];
296+
}
297+
}
298+
}
299+
}
300+
266301
// We want to display like this:
267302
//
268303
// vec.push(vec.pop().unwrap());
@@ -355,10 +390,8 @@ impl EmitterWriter {
355390
for (i, annotation) in annotations.iter().enumerate() {
356391
for (j, next) in annotations.iter().enumerate() {
357392
if overlaps(next, annotation, 0) // This label overlaps with another one and both
358-
&& !annotation.is_line() // take space (they have text and are not
359-
&& !next.is_line() // multiline lines).
360-
&& annotation.has_label()
361-
&& j > i
393+
&& annotation.has_label() // take space (they have text and are not
394+
&& j > i // multiline lines).
362395
&& p == 0 // We're currently on the first line, move the label one line down
363396
{
364397
// This annotation needs a new line in the output.
@@ -374,7 +407,7 @@ impl EmitterWriter {
374407
} else {
375408
0
376409
};
377-
if overlaps(next, annotation, l) // Do not allow two labels to be in the same
410+
if (overlaps(next, annotation, l) // Do not allow two labels to be in the same
378411
// line if they overlap including padding, to
379412
// avoid situations like:
380413
//
@@ -383,11 +416,18 @@ impl EmitterWriter {
383416
// | |
384417
// fn_spanx_span
385418
//
386-
&& !annotation.is_line() // Do not add a new line if this annotation
387-
&& !next.is_line() // or the next are vertical line placeholders.
388419
&& annotation.has_label() // Both labels must have some text, otherwise
389-
&& next.has_label() // they are not overlapping.
420+
&& next.has_label()) // they are not overlapping.
421+
// Do not add a new line if this annotation
422+
// or the next are vertical line placeholders.
423+
|| (annotation.takes_space() // If either this or the next annotation is
424+
&& next.has_label()) // multiline start/end, move it to a new line
425+
|| (annotation.has_label() // so as not to overlap the orizontal lines.
426+
&& next.takes_space())
427+
|| (annotation.takes_space()
428+
&& next.takes_space())
390429
{
430+
// This annotation needs a new line in the output.
391431
p += 1;
392432
break;
393433
}
@@ -397,6 +437,7 @@ impl EmitterWriter {
397437
line_len = p;
398438
}
399439
}
440+
400441
if line_len != 0 {
401442
line_len += 1;
402443
}
@@ -480,7 +521,7 @@ impl EmitterWriter {
480521
};
481522
let pos = pos + 1;
482523

483-
if pos > 1 && annotation.has_label() {
524+
if pos > 1 && (annotation.has_label() || annotation.takes_space()) {
484525
for p in line_offset + 1..line_offset + pos + 1 {
485526
buffer.putc(p,
486527
code_offset + annotation.start_col,
@@ -514,12 +555,12 @@ impl EmitterWriter {
514555
// After this we will have:
515556
//
516557
// 2 | fn foo() {
517-
// | __________ starting here...
558+
// | __________
518559
// | |
519560
// | something about `foo`
520561
// 3 |
521562
// 4 | }
522-
// | _ ...ending here: test
563+
// | _ test
523564
for &(pos, annotation) in &annotations_position {
524565
let style = if annotation.is_primary {
525566
Style::LabelPrimary
@@ -557,12 +598,12 @@ impl EmitterWriter {
557598
// After this we will have:
558599
//
559600
// 2 | fn foo() {
560-
// | ____-_____^ starting here...
601+
// | ____-_____^
561602
// | |
562603
// | something about `foo`
563604
// 3 |
564605
// 4 | }
565-
// | _^ ...ending here: test
606+
// | _^ test
566607
for &(_, annotation) in &annotations_position {
567608
let (underline, style) = if annotation.is_primary {
568609
('^', Style::UnderlinePrimary)

‎src/librustc_errors/snippet.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl MultilineAnnotation {
6363
start_col: self.start_col,
6464
end_col: self.start_col + 1,
6565
is_primary: self.is_primary,
66-
label: Some("starting here...".to_owned()),
66+
label: None,
6767
annotation_type: AnnotationType::MultilineStart(self.depth)
6868
}
6969
}
@@ -73,10 +73,7 @@ impl MultilineAnnotation {
7373
start_col: self.end_col - 1,
7474
end_col: self.end_col,
7575
is_primary: self.is_primary,
76-
label: match self.label {
77-
Some(ref label) => Some(format!("...ending here: {}", label)),
78-
None => Some("...ending here".to_owned()),
79-
},
76+
label: self.label.clone(),
8077
annotation_type: AnnotationType::MultilineEnd(self.depth)
8178
}
8279
}
@@ -106,9 +103,9 @@ pub enum AnnotationType {
106103
// Each of these corresponds to one part of the following diagram:
107104
//
108105
// x | foo(1 + bar(x,
109-
// | _________^ starting here... < MultilineStart
110-
// x | | y), < MultilineLine
111-
// | |______________^ ...ending here: label < MultilineEnd
106+
// | _________^ < MultilineStart
107+
// x | | y), < MultilineLine
108+
// | |______________^ label < MultilineEnd
112109
// x | z);
113110
/// Annotation marking the first character of a fully shown multiline span
114111
MultilineStart(usize),
@@ -189,6 +186,15 @@ impl Annotation {
189186
false
190187
}
191188
}
189+
190+
pub fn takes_space(&self) -> bool {
191+
// Multiline annotations always have to keep vertical space.
192+
match self.annotation_type {
193+
AnnotationType::MultilineStart(_) |
194+
AnnotationType::MultilineEnd(_) => true,
195+
_ => false,
196+
}
197+
}
192198
}
193199

194200
#[derive(Debug)]

‎src/libsyntax/test_snippet.rs

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ error: foo
128128
--> test.rs:2:10
129129
|
130130
2 | fn foo() {
131-
| __________^ starting here...
131+
| __________^
132132
3 | | }
133-
| |_^ ...ending here: test
133+
| |_^ test
134134
135135
"#);
136136
}
@@ -161,11 +161,11 @@ error: foo
161161
--> test.rs:2:10
162162
|
163163
2 | fn foo() {
164-
| __________^ starting here...
164+
| __________^
165165
3 | |
166166
4 | |
167167
5 | | }
168-
| |___^ ...ending here: test
168+
| |___^ test
169169
170170
"#);
171171
}
@@ -207,14 +207,14 @@ error: foo
207207
--> test.rs:3:3
208208
|
209209
3 | X0 Y0
210-
| ____^__- starting here...
210+
| ____^__-
211211
| | ___|
212-
| || starting here...
212+
| ||
213213
4 | || X1 Y1
214214
5 | || X2 Y2
215-
| ||____^__- ...ending here: `Y` is a good letter too
215+
| ||____^__- `Y` is a good letter too
216216
| |____|
217-
| ...ending here: `X` is a good letter
217+
| `X` is a good letter
218218
219219
"#);
220220
}
@@ -256,13 +256,13 @@ error: foo
256256
--> test.rs:3:3
257257
|
258258
3 | X0 Y0
259-
| ____^__- starting here...
259+
| ____^__-
260260
| | ___|
261-
| || starting here...
261+
| ||
262262
4 | || Y1 X1
263-
| ||____-__^ ...ending here: `X` is a good letter
263+
| ||____-__^ `X` is a good letter
264264
| |_____|
265-
| ...ending here: `Y` is a good letter too
265+
| `Y` is a good letter too
266266
267267
"#);
268268
}
@@ -306,13 +306,13 @@ error: foo
306306
--> test.rs:3:6
307307
|
308308
3 | X0 Y0 Z0
309-
| ______^ starting here...
309+
| ______^
310310
4 | | X1 Y1 Z1
311-
| |_________- starting here...
311+
| |_________-
312312
5 | || X2 Y2 Z2
313-
| ||____^ ...ending here: `X` is a good letter
313+
| ||____^ `X` is a good letter
314314
6 | | X3 Y3 Z3
315-
| |_____- ...ending here: `Y` is a good letter too
315+
| |_____- `Y` is a good letter too
316316
317317
"#);
318318
}
@@ -366,16 +366,16 @@ error: foo
366366
--> test.rs:3:3
367367
|
368368
3 | X0 Y0 Z0
369-
| _____^__-__- starting here...
369+
| _____^__-__-
370370
| | ____|__|
371-
| || ___| starting here...
372-
| ||| starting here...
371+
| || ___|
372+
| |||
373373
4 | ||| X1 Y1 Z1
374374
5 | ||| X2 Y2 Z2
375-
| |||____^__-__- ...ending here: `Z` label
375+
| |||____^__-__- `Z` label
376376
| ||____|__|
377-
| |____| ...ending here: `Y` is a good letter too
378-
| ...ending here: `X` is a good letter
377+
| |____| `Y` is a good letter too
378+
| `X` is a good letter
379379
380380
"#);
381381
}
@@ -430,17 +430,17 @@ error: foo
430430
--> test.rs:3:6
431431
|
432432
3 | X0 Y0 Z0
433-
| ______^ starting here...
433+
| ______^
434434
4 | | X1 Y1 Z1
435-
| |____^_- starting here...
435+
| |____^_-
436436
| ||____|
437-
| | ...ending here: `X` is a good letter
437+
| | `X` is a good letter
438438
5 | | X2 Y2 Z2
439-
| |____-______- ...ending here: `Y` is a good letter too
439+
| |____-______- `Y` is a good letter too
440440
| ____|
441-
| | starting here...
441+
| |
442442
6 | | X3 Y3 Z3
443-
| |________- ...ending here: `Z`
443+
| |________- `Z`
444444
445445
"#);
446446
}
@@ -458,7 +458,7 @@ fn foo() {
458458
vec![
459459
SpanLabel {
460460
start: Position {
461-
string: "Y0",
461+
string: "X0",
462462
count: 1,
463463
},
464464
end: Position {
@@ -481,16 +481,15 @@ fn foo() {
481481
],
482482
r#"
483483
error: foo
484-
--> test.rs:3:6
484+
--> test.rs:3:3
485485
|
486-
3 | X0 Y0 Z0
487-
| ______^ starting here...
486+
3 | / X0 Y0 Z0
488487
4 | | X1 Y1 Z1
489-
| |____^ ...ending here: `X` is a good letter
488+
| |____^ `X` is a good letter
490489
5 | X2 Y2 Z2
491-
| ______- starting here...
490+
| ______-
492491
6 | | X3 Y3 Z3
493-
| |__________- ...ending here: `Y` is a good letter too
492+
| |__________- `Y` is a good letter too
494493
495494
"#);
496495
}
@@ -534,14 +533,14 @@ error: foo
534533
--> test.rs:3:6
535534
|
536535
3 | X0 Y0 Z0
537-
| ______^ starting here...
536+
| ______^
538537
4 | | X1 Y1 Z1
539-
| |____^____- starting here...
538+
| |____^____-
540539
| ||____|
541-
| | ...ending here: `X` is a good letter
540+
| | `X` is a good letter
542541
5 | | X2 Y2 Z2
543542
6 | | X3 Y3 Z3
544-
| |___________- ...ending here: `Y` is a good letter too
543+
| |___________- `Y` is a good letter too
545544
546545
"#);
547546
}
@@ -982,18 +981,18 @@ error: foo
982981
--> test.rs:3:6
983982
|
984983
3 | X0 Y0 Z0
985-
| ______^ starting here...
984+
| ______^
986985
4 | | X1 Y1 Z1
987-
| |____^____- starting here...
986+
| |____^____-
988987
| ||____|
989-
| | ...ending here: `X` is a good letter
988+
| | `X` is a good letter
990989
5 | | 1
991990
6 | | 2
992991
7 | | 3
993992
... |
994993
15 | | X2 Y2 Z2
995994
16 | | X3 Y3 Z3
996-
| |___________- ...ending here: `Y` is a good letter too
995+
| |___________- `Y` is a good letter too
997996
998997
"#);
999998
}
@@ -1047,21 +1046,21 @@ error: foo
10471046
--> test.rs:3:6
10481047
|
10491048
3 | X0 Y0 Z0
1050-
| ______^ starting here...
1049+
| ______^
10511050
4 | | 1
10521051
5 | | 2
10531052
6 | | 3
10541053
7 | | X1 Y1 Z1
1055-
| |_________- starting here...
1054+
| |_________-
10561055
8 | || 4
10571056
9 | || 5
10581057
10 | || 6
10591058
11 | || X2 Y2 Z2
1060-
| ||__________- ...ending here: `Z` is a good letter too
1059+
| ||__________- `Z` is a good letter too
10611060
... |
10621061
15 | | 10
10631062
16 | | X3 Y3 Z3
1064-
| |_______^ ...ending here: `Y` is a good letter
1063+
| |_______^ `Y` is a good letter
10651064
10661065
"#);
10671066
}

‎src/test/ui/compare-method/region-extra-2.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ error[E0276]: impl has stricter requirements than trait
44
15 | fn renew<'b: 'a>(self) -> &'b mut [T];
55
| -------------------------------------- definition of `renew` from trait
66
...
7-
19 | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
8-
| _____^ starting here...
7+
19 | / fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
98
20 | | //~^ ERROR E0276
109
21 | | &mut self[..]
1110
22 | | }
12-
| |_____^ ...ending here: impl has extra requirement `'a: 'b`
11+
| |_____^ impl has extra requirement `'a: 'b`
1312

1413
error: aborting due to previous error
1514

‎src/test/ui/compare-method/traits-misc-mismatch-2.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ error[E0276]: impl has stricter requirements than trait
44
19 | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
55
| ------------------------------------------------------------------ definition of `zip` from trait
66
...
7-
23 | fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
8-
| _____^ starting here...
7+
23 | / fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
98
24 | | //~^ ERROR E0276
109
25 | | ZipIterator{a: self, b: other}
1110
26 | | }
12-
| |_____^ ...ending here: impl has extra requirement `U: Iterator<B>`
11+
| |_____^ impl has extra requirement `U: Iterator<B>`
1312

1413
error: aborting due to previous error
1514

‎src/test/ui/did_you_mean/issue-40006.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ error: missing `fn`, `type`, or `const` for impl-item declaration
22
--> $DIR/issue-40006.rs:11:9
33
|
44
11 | impl X {
5-
| _________^ starting here...
5+
| _________^
66
12 | | Y
7-
| |____^ ...ending here: missing `fn`, `type`, or `const`
7+
| |____^ missing `fn`, `type`, or `const`
88

99
error: missing `fn`, `type`, or `const` for trait-item declaration
1010
--> $DIR/issue-40006.rs:17:10
1111
|
1212
17 | trait X {
13-
| __________^ starting here...
13+
| __________^
1414
18 | | X() {}
15-
| |____^ ...ending here: missing `fn`, `type`, or `const`
15+
| |____^ missing `fn`, `type`, or `const`
1616

1717
error: expected `[`, found `#`
1818
--> $DIR/issue-40006.rs:19:17
@@ -24,17 +24,17 @@ error: missing `fn`, `type`, or `const` for trait-item declaration
2424
--> $DIR/issue-40006.rs:19:21
2525
|
2626
19 | fn xxx() { ### }
27-
| _____________________^ starting here...
27+
| _____________________^
2828
20 | | L = M;
29-
| |____^ ...ending here: missing `fn`, `type`, or `const`
29+
| |____^ missing `fn`, `type`, or `const`
3030

3131
error: missing `fn`, `type`, or `const` for trait-item declaration
3232
--> $DIR/issue-40006.rs:20:11
3333
|
3434
20 | L = M;
35-
| ___________^ starting here...
35+
| ___________^
3636
21 | | Z = { 2 + 3 };
37-
| |____^ ...ending here: missing `fn`, `type`, or `const`
37+
| |____^ missing `fn`, `type`, or `const`
3838

3939
error: expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `;`
4040
--> $DIR/issue-40006.rs:21:18
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
22
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:32:1
33
|
4-
32 | impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
5-
| _^ starting here...
4+
32 | / impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
65
33 | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
76
34 | |
87
35 | | // (unsafe to access self.1 due to #[may_dangle] on A)
98
36 | | fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
109
37 | | }
11-
| |_^ ...ending here
10+
| |_^
1211

1312
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
1413
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:38:1
1514
|
16-
38 | impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
17-
| _^ starting here...
15+
38 | / impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
1816
39 | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
1917
40 | |
2018
41 | | // (unsafe to access self.1 due to #[may_dangle] on 'a)
2119
42 | | fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
2220
43 | | }
23-
| |_^ ...ending here
21+
| |_^
2422

2523
error: aborting due to 2 previous errors
2624

‎src/test/ui/issue-37311-type-length-limit/issue-37311.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
error: reached the type-length limit while instantiating `<T as Foo><(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(), &()), &(&()...`
22
--> $DIR/issue-37311.rs:23:5
33
|
4-
23 | fn recurse(&self) {
5-
| _____^ starting here...
4+
23 | / fn recurse(&self) {
65
24 | | (self, self).recurse();
76
25 | | }
8-
| |_____^ ...ending here
7+
| |_____^
98
|
109
= note: consider adding a `#![type_length_limit="2097152"]` attribute to your crate
1110

‎src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ note: ...the reference is valid for the lifetime 'a as defined on the body at 11
88
--> $DIR/ex1-return-one-existing-name-if-else.rs:11:44
99
|
1010
11 | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
11-
| ____________________________________________^ starting here...
11+
| ____________________________________________^
1212
12 | | if x > y { x } else { y }
1313
13 | | }
14-
| |_^ ...ending here
14+
| |_^
1515
note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the body at 11:43
1616
--> $DIR/ex1-return-one-existing-name-if-else.rs:11:44
1717
|
1818
11 | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
19-
| ____________________________________________^ starting here...
19+
| ____________________________________________^
2020
12 | | if x > y { x } else { y }
2121
13 | | }
22-
| |_^ ...ending here
22+
| |_^
2323

2424
error: aborting due to previous error
2525

‎src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ note: the anonymous lifetime #2 defined on the body at 15:51...
1010
--> $DIR/ex2a-push-one-existing-name.rs:15:52
1111
|
1212
15 | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
13-
| ____________________________________________________^ starting here...
13+
| ____________________________________________________^
1414
16 | | x.push(y);
1515
17 | | }
16-
| |_^ ...ending here
16+
| |_^
1717
note: ...does not necessarily outlive the lifetime 'a as defined on the body at 15:51
1818
--> $DIR/ex2a-push-one-existing-name.rs:15:52
1919
|
2020
15 | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
21-
| ____________________________________________________^ starting here...
21+
| ____________________________________________________^
2222
16 | | x.push(y);
2323
17 | | }
24-
| |_^ ...ending here
24+
| |_^
2525

2626
error: aborting due to previous error
2727

‎src/test/ui/lifetime-errors/ex2b-push-no-existing-names.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ note: the anonymous lifetime #3 defined on the body at 15:43...
1010
--> $DIR/ex2b-push-no-existing-names.rs:15:44
1111
|
1212
15 | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
13-
| ____________________________________________^ starting here...
13+
| ____________________________________________^
1414
16 | | x.push(y);
1515
17 | | }
16-
| |_^ ...ending here
16+
| |_^
1717
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 15:43
1818
--> $DIR/ex2b-push-no-existing-names.rs:15:44
1919
|
2020
15 | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
21-
| ____________________________________________^ starting here...
21+
| ____________________________________________^
2222
16 | | x.push(y);
2323
17 | | }
24-
| |_^ ...ending here
24+
| |_^
2525

2626
error: aborting due to previous error
2727

‎src/test/ui/lifetime-errors/ex2c-push-inference-variable.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ note: first, the lifetime cannot outlive the lifetime 'c as defined on the body
88
--> $DIR/ex2c-push-inference-variable.rs:15:67
99
|
1010
15 | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
11-
| ___________________________________________________________________^ starting here...
11+
| ___________________________________________________________________^
1212
16 | | let z = Ref { data: y.data };
1313
17 | | x.push(z);
1414
18 | | }
15-
| |_^ ...ending here
15+
| |_^
1616
note: ...so that reference does not outlive borrowed content
1717
--> $DIR/ex2c-push-inference-variable.rs:16:25
1818
|
@@ -22,11 +22,11 @@ note: but, the lifetime must be valid for the lifetime 'b as defined on the body
2222
--> $DIR/ex2c-push-inference-variable.rs:15:67
2323
|
2424
15 | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
25-
| ___________________________________________________________________^ starting here...
25+
| ___________________________________________________________________^
2626
16 | | let z = Ref { data: y.data };
2727
17 | | x.push(z);
2828
18 | | }
29-
| |_^ ...ending here
29+
| |_^
3030
note: ...so that expression is assignable (expected Ref<'b, _>, found Ref<'_, _>)
3131
--> $DIR/ex2c-push-inference-variable.rs:17:12
3232
|

‎src/test/ui/lifetime-errors/ex2d-push-inference-variable-2.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ note: first, the lifetime cannot outlive the lifetime 'c as defined on the body
88
--> $DIR/ex2d-push-inference-variable-2.rs:15:67
99
|
1010
15 | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
11-
| ___________________________________________________________________^ starting here...
11+
| ___________________________________________________________________^
1212
16 | | let a: &mut Vec<Ref<i32>> = x;
1313
17 | | let b = Ref { data: y.data };
1414
18 | | a.push(b);
1515
19 | | }
16-
| |_^ ...ending here
16+
| |_^
1717
note: ...so that reference does not outlive borrowed content
1818
--> $DIR/ex2d-push-inference-variable-2.rs:17:25
1919
|
@@ -23,12 +23,12 @@ note: but, the lifetime must be valid for the lifetime 'b as defined on the body
2323
--> $DIR/ex2d-push-inference-variable-2.rs:15:67
2424
|
2525
15 | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
26-
| ___________________________________________________________________^ starting here...
26+
| ___________________________________________________________________^
2727
16 | | let a: &mut Vec<Ref<i32>> = x;
2828
17 | | let b = Ref { data: y.data };
2929
18 | | a.push(b);
3030
19 | | }
31-
| |_^ ...ending here
31+
| |_^
3232
note: ...so that expression is assignable (expected &mut std::vec::Vec<Ref<'_, i32>>, found &mut std::vec::Vec<Ref<'b, i32>>)
3333
--> $DIR/ex2d-push-inference-variable-2.rs:16:33
3434
|

‎src/test/ui/lifetime-errors/ex2e-push-inference-variable-3.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ note: first, the lifetime cannot outlive the lifetime 'c as defined on the body
88
--> $DIR/ex2e-push-inference-variable-3.rs:15:67
99
|
1010
15 | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
11-
| ___________________________________________________________________^ starting here...
11+
| ___________________________________________________________________^
1212
16 | | let a: &mut Vec<Ref<i32>> = x;
1313
17 | | let b = Ref { data: y.data };
1414
18 | | Vec::push(a, b);
1515
19 | | }
16-
| |_^ ...ending here
16+
| |_^
1717
note: ...so that reference does not outlive borrowed content
1818
--> $DIR/ex2e-push-inference-variable-3.rs:17:25
1919
|
@@ -23,12 +23,12 @@ note: but, the lifetime must be valid for the lifetime 'b as defined on the body
2323
--> $DIR/ex2e-push-inference-variable-3.rs:15:67
2424
|
2525
15 | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
26-
| ___________________________________________________________________^ starting here...
26+
| ___________________________________________________________________^
2727
16 | | let a: &mut Vec<Ref<i32>> = x;
2828
17 | | let b = Ref { data: y.data };
2929
18 | | Vec::push(a, b);
3030
19 | | }
31-
| |_^ ...ending here
31+
| |_^
3232
note: ...so that expression is assignable (expected &mut std::vec::Vec<Ref<'_, i32>>, found &mut std::vec::Vec<Ref<'b, i32>>)
3333
--> $DIR/ex2e-push-inference-variable-3.rs:16:33
3434
|

‎src/test/ui/mismatched_types/abridged.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,29 @@ error[E0308]: mismatched types
3737
error[E0308]: mismatched types
3838
--> $DIR/abridged.rs:42:5
3939
|
40-
42 | X {
41-
| _____^ starting here...
40+
42 | / X {
4241
43 | | x: X {
4342
44 | | x: "".to_string(),
4443
45 | | y: 2,
4544
46 | | },
4645
47 | | y: 3,
4746
48 | | }
48-
| |_____^ ...ending here: expected struct `std::string::String`, found integral variable
47+
| |_____^ expected struct `std::string::String`, found integral variable
4948
|
5049
= note: expected type `X<X<_, std::string::String>, std::string::String>`
5150
found type `X<X<_, {integer}>, {integer}>`
5251

5352
error[E0308]: mismatched types
5453
--> $DIR/abridged.rs:52:5
5554
|
56-
52 | X {
57-
| _____^ starting here...
55+
52 | / X {
5856
53 | | x: X {
5957
54 | | x: "".to_string(),
6058
55 | | y: 2,
6159
56 | | },
6260
57 | | y: "".to_string(),
6361
58 | | }
64-
| |_____^ ...ending here: expected struct `std::string::String`, found integral variable
62+
| |_____^ expected struct `std::string::String`, found integral variable
6563
|
6664
= note: expected type `X<X<_, std::string::String>, _>`
6765
found type `X<X<_, {integer}>, _>`

‎src/test/ui/mismatched_types/main.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ error[E0308]: mismatched types
22
--> $DIR/main.rs:12:18
33
|
44
12 | let x: u32 = (
5-
| __________________^ starting here...
5+
| __________________^
66
13 | | );
7-
| |_____^ ...ending here: expected u32, found ()
7+
| |_____^ expected u32, found ()
88
|
99
= note: expected type `u32`
1010
found type `()`

‎src/test/ui/missing-items/m2.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ error: main function not found
33
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
44
--> $DIR/m2.rs:20:1
55
|
6-
20 | impl m1::X for X {
7-
| _^ starting here...
6+
20 | / impl m1::X for X {
87
21 | | }
9-
| |_^ ...ending here: missing `CONSTANT`, `Type`, `method` in implementation
8+
| |_^ missing `CONSTANT`, `Type`, `method` in implementation
109
|
1110
= note: `CONSTANT` from trait: `const CONSTANT: u32;`
1211
= note: `Type` from trait: `type Type;`

‎src/test/ui/span/impl-wrong-item-for-trait.stderr

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ error[E0046]: not all trait items implemented, missing: `bar`
1919
16 | fn bar(&self);
2020
| -------------- `bar` from trait
2121
...
22-
22 | impl Foo for FooConstForMethod {
23-
| _^ starting here...
22+
22 | / impl Foo for FooConstForMethod {
2423
23 | | //~^ ERROR E0046
2524
24 | | //~| NOTE missing `bar` in implementation
2625
25 | | const bar: u64 = 1;
2726
... |
2827
28 | | const MY_CONST: u32 = 1;
2928
29 | | }
30-
| |_^ ...ending here: missing `bar` in implementation
29+
| |_^ missing `bar` in implementation
3130

3231
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
3332
--> $DIR/impl-wrong-item-for-trait.rs:37:5
@@ -44,15 +43,14 @@ error[E0046]: not all trait items implemented, missing: `MY_CONST`
4443
17 | const MY_CONST: u32;
4544
| -------------------- `MY_CONST` from trait
4645
...
47-
33 | impl Foo for FooMethodForConst {
48-
| _^ starting here...
46+
33 | / impl Foo for FooMethodForConst {
4947
34 | | //~^ ERROR E0046
5048
35 | | //~| NOTE missing `MY_CONST` in implementation
5149
36 | | fn bar(&self) {}
5250
... |
5351
39 | | //~| NOTE does not match trait
5452
40 | | }
55-
| |_^ ...ending here: missing `MY_CONST` in implementation
53+
| |_^ missing `MY_CONST` in implementation
5654

5755
error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo`
5856
--> $DIR/impl-wrong-item-for-trait.rs:47:5
@@ -69,23 +67,21 @@ error[E0046]: not all trait items implemented, missing: `bar`
6967
16 | fn bar(&self);
7068
| -------------- `bar` from trait
7169
...
72-
44 | impl Foo for FooTypeForMethod {
73-
| _^ starting here...
70+
44 | / impl Foo for FooTypeForMethod {
7471
45 | | //~^ ERROR E0046
7572
46 | | //~| NOTE missing `bar` in implementation
7673
47 | | type bar = u64;
7774
... |
7875
50 | | const MY_CONST: u32 = 1;
7976
51 | | }
80-
| |_^ ...ending here: missing `bar` in implementation
77+
| |_^ missing `bar` in implementation
8178

8279
error[E0046]: not all trait items implemented, missing: `fmt`
8380
--> $DIR/impl-wrong-item-for-trait.rs:53:1
8481
|
85-
53 | impl Debug for FooTypeForMethod {
86-
| _^ starting here...
82+
53 | / impl Debug for FooTypeForMethod {
8783
54 | | }
88-
| |_^ ...ending here: missing `fmt` in implementation
84+
| |_^ missing `fmt` in implementation
8985
|
9086
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
9187

‎src/test/ui/span/issue-23729.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
error[E0046]: not all trait items implemented, missing: `Item`
22
--> $DIR/issue-23729.rs:20:9
33
|
4-
20 | impl Iterator for Recurrence {
5-
| _________^ starting here...
4+
20 | / impl Iterator for Recurrence {
65
21 | | //~^ ERROR E0046
76
22 | | //~| NOTE missing `Item` in implementation
87
23 | | //~| NOTE `Item` from trait: `type Item;`
98
... |
109
36 | | }
1110
37 | | }
12-
| |_________^ ...ending here: missing `Item` in implementation
11+
| |_________^ missing `Item` in implementation
1312
|
1413
= note: `Item` from trait: `type Item;`
1514

‎src/test/ui/span/issue-23827.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
error[E0046]: not all trait items implemented, missing: `Output`
22
--> $DIR/issue-23827.rs:36:1
33
|
4-
36 | impl<C: Component> FnOnce<(C,)> for Prototype {
5-
| _^ starting here...
4+
36 | / impl<C: Component> FnOnce<(C,)> for Prototype {
65
37 | | //~^ ERROR E0046
76
38 | | //~| NOTE missing `Output` in implementation
87
39 | | //~| NOTE `Output` from trait: `type Output;`
98
... |
109
42 | | }
1110
43 | | }
12-
| |_^ ...ending here: missing `Output` in implementation
11+
| |_^ missing `Output` in implementation
1312
|
1413
= note: `Output` from trait: `type Output;`
1514

‎src/test/ui/span/issue-24356.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
error[E0046]: not all trait items implemented, missing: `Target`
22
--> $DIR/issue-24356.rs:30:9
33
|
4-
30 | impl Deref for Thing {
5-
| _________^ starting here...
4+
30 | / impl Deref for Thing {
65
31 | | //~^ ERROR E0046
76
32 | | //~| NOTE missing `Target` in implementation
87
33 | | //~| NOTE `Target` from trait: `type Target;`
98
34 | | fn deref(&self) -> i8 { self.0 }
109
35 | | }
11-
| |_________^ ...ending here: missing `Target` in implementation
10+
| |_________^ missing `Target` in implementation
1211
|
1312
= note: `Target` from trait: `type Target;`
1413

‎src/test/ui/span/issue-7575.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ error: no method named `fff` found for type `Myisize` in the current scope
3838
note: candidate #1 is defined in an impl for the type `Myisize`
3939
--> $DIR/issue-7575.rs:51:5
4040
|
41-
51 | fn fff(i: isize) -> isize { //~ NOTE candidate
42-
| _____^ starting here...
41+
51 | / fn fff(i: isize) -> isize { //~ NOTE candidate
4342
52 | | i
4443
53 | | }
45-
| |_____^ ...ending here
44+
| |_____^
4645

4746
error: no method named `is_str` found for type `T` in the current scope
4847
--> $DIR/issue-7575.rs:85:7
@@ -54,11 +53,10 @@ error: no method named `is_str` found for type `T` in the current scope
5453
note: candidate #1 is defined in the trait `ManyImplTrait`
5554
--> $DIR/issue-7575.rs:57:5
5655
|
57-
57 | fn is_str() -> bool { //~ NOTE candidate
58-
| _____^ starting here...
56+
57 | / fn is_str() -> bool { //~ NOTE candidate
5957
58 | | false
6058
59 | | }
61-
| |_____^ ...ending here
59+
| |_____^
6260
= help: to disambiguate the method call, write `ManyImplTrait::is_str(t)` instead
6361
= help: items from traits can only be used if the trait is implemented and in scope; the following trait defines an item `is_str`, perhaps you need to implement it:
6462
= help: candidate #1: `ManyImplTrait`

‎src/test/ui/span/lint-unused-unsafe.stderr

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,68 +49,62 @@ note: because it's nested under this `unsafe` fn
4949
error: unnecessary `unsafe` block
5050
--> $DIR/lint-unused-unsafe.rs:33:9
5151
|
52-
33 | unsafe { //~ ERROR: unnecessary `unsafe` block
53-
| _________^ starting here...
52+
33 | / unsafe { //~ ERROR: unnecessary `unsafe` block
5453
34 | | unsf()
5554
35 | | }
56-
| |_________^ ...ending here: unnecessary `unsafe` block
55+
| |_________^ unnecessary `unsafe` block
5756
|
5857
note: because it's nested under this `unsafe` block
5958
--> $DIR/lint-unused-unsafe.rs:32:5
6059
|
61-
32 | unsafe { // don't put the warning here
62-
| _____^ starting here...
60+
32 | / unsafe { // don't put the warning here
6361
33 | | unsafe { //~ ERROR: unnecessary `unsafe` block
6462
34 | | unsf()
6563
35 | | }
6664
36 | | }
67-
| |_____^ ...ending here
65+
| |_____^
6866

6967
error: unnecessary `unsafe` block
7068
--> $DIR/lint-unused-unsafe.rs:39:5
7169
|
72-
39 | unsafe { //~ ERROR: unnecessary `unsafe` block
73-
| _____^ starting here...
70+
39 | / unsafe { //~ ERROR: unnecessary `unsafe` block
7471
40 | | unsafe { //~ ERROR: unnecessary `unsafe` block
7572
41 | | unsf()
7673
42 | | }
7774
43 | | }
78-
| |_____^ ...ending here: unnecessary `unsafe` block
75+
| |_____^ unnecessary `unsafe` block
7976
|
8077
note: because it's nested under this `unsafe` fn
8178
--> $DIR/lint-unused-unsafe.rs:38:1
8279
|
83-
38 | unsafe fn bad7() {
84-
| _^ starting here...
80+
38 | / unsafe fn bad7() {
8581
39 | | unsafe { //~ ERROR: unnecessary `unsafe` block
8682
40 | | unsafe { //~ ERROR: unnecessary `unsafe` block
8783
41 | | unsf()
8884
42 | | }
8985
43 | | }
9086
44 | | }
91-
| |_^ ...ending here
87+
| |_^
9288

9389
error: unnecessary `unsafe` block
9490
--> $DIR/lint-unused-unsafe.rs:40:9
9591
|
96-
40 | unsafe { //~ ERROR: unnecessary `unsafe` block
97-
| _________^ starting here...
92+
40 | / unsafe { //~ ERROR: unnecessary `unsafe` block
9893
41 | | unsf()
9994
42 | | }
100-
| |_________^ ...ending here: unnecessary `unsafe` block
95+
| |_________^ unnecessary `unsafe` block
10196
|
10297
note: because it's nested under this `unsafe` fn
10398
--> $DIR/lint-unused-unsafe.rs:38:1
10499
|
105-
38 | unsafe fn bad7() {
106-
| _^ starting here...
100+
38 | / unsafe fn bad7() {
107101
39 | | unsafe { //~ ERROR: unnecessary `unsafe` block
108102
40 | | unsafe { //~ ERROR: unnecessary `unsafe` block
109103
41 | | unsf()
110104
42 | | }
111105
43 | | }
112106
44 | | }
113-
| |_^ ...ending here
107+
| |_^
114108

115109
error: aborting due to 8 previous errors
116110

‎src/test/ui/span/multiline-span-E0072.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
error[E0072]: recursive type `ListNode` has infinite size
22
--> $DIR/multiline-span-E0072.rs:12:1
33
|
4-
12 | struct
5-
| _^ starting here...
4+
12 | / struct
65
13 | | ListNode
76
14 | | {
87
15 | | head: u8,
98
16 | | tail: Option<ListNode>,
109
17 | | }
11-
| |_^ ...ending here: recursive type has infinite size
10+
| |_^ recursive type has infinite size
1211
|
1312
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ListNode` representable
1413

‎src/test/ui/span/multiline-span-simple.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied
22
--> $DIR/multiline-span-simple.rs:23:9
33
|
44
23 | foo(1 as u32 +
5-
| _________^ starting here...
5+
| _________^
66
24 | |
77
25 | | bar(x,
88
26 | |
99
27 | | y),
10-
| |______________^ ...ending here: the trait `std::ops::Add<()>` is not implemented for `u32`
10+
| |______________^ the trait `std::ops::Add<()>` is not implemented for `u32`
1111
|
1212
= note: no implementation for `u32 + ()`
1313

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
error[E0282]: type annotations needed
22
--> $DIR/issue-40294.rs:15:1
33
|
4-
15 | fn foo<'a,'b,T>(x: &'a T, y: &'b T)
5-
| _^ starting here...
4+
15 | / fn foo<'a,'b,T>(x: &'a T, y: &'b T)
65
16 | | where &'a T : Foo,
76
17 | | &'b T : Foo
87
18 | | {
98
19 | | x.foo();
109
20 | | y.foo();
1110
21 | | }
12-
| |_^ ...ending here: cannot infer type for `&'a T`
11+
| |_^ cannot infer type for `&'a T`
1312

1413
error: aborting due to previous error
1514

0 commit comments

Comments
 (0)
Please sign in to comment.