Skip to content

Commit 3fea832

Browse files
committed
Fix spacing of expected/found notes without a label
1 parent ff991d6 commit 3fea832

29 files changed

+88
-79
lines changed

src/librustc_errors/diagnostic.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,18 @@ impl Diagnostic {
193193
expected_extra: &dyn fmt::Display,
194194
found_extra: &dyn fmt::Display,
195195
) -> &mut Self {
196-
let expected_label = format!("expected {}", expected_label);
197-
198-
let found_label = format!("found {}", found_label);
196+
let expected_label = expected_label.to_string();
197+
let expected_label = if expected_label.is_empty() {
198+
"expected".to_string()
199+
} else {
200+
format!("expected {}", expected_label)
201+
};
202+
let found_label = found_label.to_string();
203+
let found_label = if found_label.is_empty() {
204+
"found".to_string()
205+
} else {
206+
format!("found {}", found_label)
207+
};
199208
let (found_padding, expected_padding) = if expected_label.len() > found_label.len() {
200209
(expected_label.len() - found_label.len(), 0)
201210
} else {

src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ note: ...so that the expression is assignable
1414
|
1515
LL | bar(foo, x)
1616
| ^
17-
= note: expected `Type<'_>`
18-
found `Type<'a>`
17+
= note: expected `Type<'_>`
18+
found `Type<'a>`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that the expression is assignable
2121
--> $DIR/project-fn-ret-invariant.rs:48:4
2222
|
2323
LL | bar(foo, x)
2424
| ^^^^^^^^^^^
25-
= note: expected `Type<'static>`
26-
found `Type<'_>`
25+
= note: expected `Type<'static>`
26+
found `Type<'_>`
2727

2828
error: aborting due to previous error
2929

src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ note: ...so that the expression is assignable
1414
|
1515
LL | static_val(x);
1616
| ^
17-
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
18-
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
17+
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
18+
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that the types are compatible
2121
--> $DIR/dyn-trait.rs:20:5
2222
|
2323
LL | static_val(x);
2424
| ^^^^^^^^^^
25-
= note: expected `StaticTrait`
26-
found `StaticTrait`
25+
= note: expected `StaticTrait`
26+
found `StaticTrait`
2727

2828
error: aborting due to previous error
2929

src/test/ui/issues/issue-16683.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ note: ...so that the types are compatible
2626
|
2727
LL | self.a();
2828
| ^
29-
= note: expected `&'a Self`
30-
found `&Self`
29+
= note: expected `&'a Self`
30+
found `&Self`
3131

3232
error: aborting due to previous error
3333

src/test/ui/issues/issue-17758.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ note: ...so that the types are compatible
2727
|
2828
LL | self.foo();
2929
| ^^^
30-
= note: expected `&'a Self`
31-
found `&Self`
30+
= note: expected `&'a Self`
31+
found `&Self`
3232

3333
error: aborting due to previous error
3434

src/test/ui/issues/issue-20831-debruijn.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ note: ...so that the types are compatible
117117
|
118118
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
119119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120-
= note: expected `Publisher<'_>`
121-
found `Publisher<'_>`
120+
= note: expected `Publisher<'_>`
121+
found `Publisher<'_>`
122122

123123
error: aborting due to 4 previous errors
124124

src/test/ui/issues/issue-52213.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ note: ...so that the types are compatible
1414
|
1515
LL | match (&t,) {
1616
| ^^^^^
17-
= note: expected `(&&(T,),)`
18-
found `(&&'a (T,),)`
17+
= note: expected `(&&(T,),)`
18+
found `(&&'a (T,),)`
1919
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 1:27...
2020
--> $DIR/issue-52213.rs:1:27
2121
|

src/test/ui/issues/issue-55796.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ note: ...so that the expression is assignable
2020
|
2121
LL | Box::new(self.out_edges(u).map(|e| e.target()))
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23-
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
24-
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
23+
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
24+
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
2525

2626
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
2727
--> $DIR/issue-55796.rs:21:9
@@ -45,8 +45,8 @@ note: ...so that the expression is assignable
4545
|
4646
LL | Box::new(self.in_edges(u).map(|e| e.target()))
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48-
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
49-
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
48+
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
49+
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
5050

5151
error: aborting due to 2 previous errors
5252

src/test/ui/nll/issue-55394.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ note: ...so that the expression is assignable
2626
|
2727
LL | Foo { bar }
2828
| ^^^^^^^^^^^
29-
= note: expected `Foo<'_>`
30-
found `Foo<'_>`
29+
= note: expected `Foo<'_>`
30+
found `Foo<'_>`
3131

3232
error: aborting due to previous error
3333

src/test/ui/nll/normalization-bounds-error.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ note: ...so that the types are compatible
1919
|
2020
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22-
= note: expected `Visitor<'d>`
23-
found `Visitor<'_>`
22+
= note: expected `Visitor<'d>`
23+
found `Visitor<'_>`
2424

2525
error: aborting due to previous error
2626

0 commit comments

Comments
 (0)