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

src/test/ui/nll/type-alias-free-regions.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ note: ...so that the expression is assignable
1616
|
1717
LL | C { f: b }
1818
| ^
19-
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
20-
found `std::boxed::Box<std::boxed::Box<&isize>>`
19+
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
20+
found `std::boxed::Box<std::boxed::Box<&isize>>`
2121
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 15:6...
2222
--> $DIR/type-alias-free-regions.rs:15:6
2323
|
@@ -28,8 +28,8 @@ note: ...so that the expression is assignable
2828
|
2929
LL | C { f: b }
3030
| ^^^^^^^^^^
31-
= note: expected `C<'a>`
32-
found `C<'_>`
31+
= note: expected `C<'a>`
32+
found `C<'_>`
3333

3434
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
3535
--> $DIR/type-alias-free-regions.rs:27:16
@@ -49,8 +49,8 @@ note: ...so that the expression is assignable
4949
|
5050
LL | C { f: Box::new(b.0) }
5151
| ^^^
52-
= note: expected `std::boxed::Box<&isize>`
53-
found `std::boxed::Box<&isize>`
52+
= note: expected `std::boxed::Box<&isize>`
53+
found `std::boxed::Box<&isize>`
5454
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 25:6...
5555
--> $DIR/type-alias-free-regions.rs:25:6
5656
|
@@ -61,8 +61,8 @@ note: ...so that the expression is assignable
6161
|
6262
LL | C { f: Box::new(b.0) }
6363
| ^^^^^^^^^^^^^^^^^^^^^^
64-
= note: expected `C<'a>`
65-
found `C<'_>`
64+
= note: expected `C<'a>`
65+
found `C<'_>`
6666

6767
error: aborting due to 2 previous errors
6868

src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.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 | <Foo<'a>>::C
1616
| ^^^^^^^^^^^^
17-
= note: expected `Foo<'_>`
18-
found `Foo<'a>`
17+
= note: expected `Foo<'_>`
18+
found `Foo<'a>`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that reference does not outlive borrowed content
2121
--> $DIR/constant-in-expr-inherent-1.rs:8:5

src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.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 | T::C
1616
| ^^^^
17-
= note: expected `Foo<'_>`
18-
found `Foo<'a>`
17+
= note: expected `Foo<'_>`
18+
found `Foo<'a>`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that reference does not outlive borrowed content
2121
--> $DIR/constant-in-expr-trait-item-3.rs:10:5

src/test/ui/object-lifetime/object-lifetime-default-elision.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ note: ...so that the expression is assignable
2424
|
2525
LL | ss
2626
| ^^
27-
= note: expected `&'b (dyn SomeTrait + 'b)`
28-
found `&dyn SomeTrait`
27+
= note: expected `&'b (dyn SomeTrait + 'b)`
28+
found `&dyn SomeTrait`
2929

3030
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
3131
--> $DIR/object-lifetime-default-elision.rs:71:5
@@ -53,8 +53,8 @@ note: ...so that the expression is assignable
5353
|
5454
LL | ss
5555
| ^^
56-
= note: expected `&'b (dyn SomeTrait + 'b)`
57-
found `&dyn SomeTrait`
56+
= note: expected `&'b (dyn SomeTrait + 'b)`
57+
found `&dyn SomeTrait`
5858

5959
error: aborting due to 2 previous errors
6060

src/test/ui/regions/region-object-lifetime-in-coercion.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ note: ...so that the expression is assignable
3939
|
4040
LL | Box::new(v)
4141
| ^
42-
= note: expected `&[u8]`
43-
found `&'a [u8]`
42+
= note: expected `&[u8]`
43+
found `&'a [u8]`
4444
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 25:9...
4545
--> $DIR/region-object-lifetime-in-coercion.rs:25:9
4646
|
@@ -51,8 +51,8 @@ note: ...so that the expression is assignable
5151
|
5252
LL | Box::new(v)
5353
| ^^^^^^^^^^^
54-
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
55-
found `std::boxed::Box<dyn Foo>`
54+
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
55+
found `std::boxed::Box<dyn Foo>`
5656

5757
error: aborting due to 4 previous errors
5858

src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ note: ...so that the types are compatible
1414
|
1515
LL | impl<'a> Foo<'static> for &'a i32 {
1616
| ^^^^^^^^^^^^
17-
= note: expected `Foo<'static>`
18-
found `Foo<'static>`
17+
= note: expected `Foo<'static>`
18+
found `Foo<'static>`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that the type `&i32` will meet its required lifetime bounds
2121
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
@@ -39,8 +39,8 @@ note: ...so that the types are compatible
3939
|
4040
LL | impl<'a,'b> Foo<'b> for &'a i64 {
4141
| ^^^^^^^
42-
= note: expected `Foo<'b>`
43-
found `Foo<'_>`
42+
= note: expected `Foo<'b>`
43+
found `Foo<'_>`
4444
note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9...
4545
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9
4646
|

src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.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 | impl<'a> Foo for &'a i32 {
1616
| ^^^
17-
= note: expected `Foo`
18-
found `Foo`
17+
= note: expected `Foo`
18+
found `Foo`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that the type `&i32` will meet its required lifetime bounds
2121
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10

src/test/ui/regions/regions-close-object-into-object-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ note: ...so that the expression is assignable
2020
|
2121
LL | box B(&*v) as Box<dyn X>
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^
23-
= note: expected `std::boxed::Box<(dyn X + 'static)>`
24-
found `std::boxed::Box<dyn X>`
23+
= note: expected `std::boxed::Box<(dyn X + 'static)>`
24+
found `std::boxed::Box<dyn X>`
2525

2626
error: aborting due to previous error
2727

src/test/ui/regions/regions-close-object-into-object-4.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ note: ...so that the expression is assignable
2020
|
2121
LL | box B(&*v) as Box<dyn X>
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^
23-
= note: expected `std::boxed::Box<(dyn X + 'static)>`
24-
found `std::boxed::Box<dyn X>`
23+
= note: expected `std::boxed::Box<(dyn X + 'static)>`
24+
found `std::boxed::Box<dyn X>`
2525

2626
error: aborting due to previous error
2727

src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ note: ...so that the expression is assignable
2424
|
2525
LL | box v as Box<dyn SomeTrait + 'a>
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27-
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
28-
found `std::boxed::Box<dyn SomeTrait>`
27+
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
28+
found `std::boxed::Box<dyn SomeTrait>`
2929

3030
error: aborting due to previous error
3131

src/test/ui/regions/regions-creating-enums4.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ note: ...so that the expression is assignable
1414
|
1515
LL | Ast::Add(x, y)
1616
| ^
17-
= note: expected `&Ast<'_>`
18-
found `&Ast<'a>`
17+
= note: expected `&Ast<'_>`
18+
found `&Ast<'a>`
1919
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 6:19...
2020
--> $DIR/regions-creating-enums4.rs:6:19
2121
|
@@ -26,8 +26,8 @@ note: ...so that the expression is assignable
2626
|
2727
LL | Ast::Add(x, y)
2828
| ^^^^^^^^^^^^^^
29-
= note: expected `Ast<'b>`
30-
found `Ast<'_>`
29+
= note: expected `Ast<'b>`
30+
found `Ast<'_>`
3131

3232
error: aborting due to previous error
3333

src/test/ui/regions/regions-nested-fns.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ LL | | if false { return ay; }
3939
LL | | return z;
4040
LL | | }));
4141
| |_____^
42-
= note: expected `&isize`
43-
found `&isize`
42+
= note: expected `&isize`
43+
found `&isize`
4444

4545
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
4646
--> $DIR/regions-nested-fns.rs:14:27

src/test/ui/regions/regions-normalize-in-where-clause-list.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ LL | | where <() as Project<'a, 'b>>::Item : Eq
2929
LL | | {
3030
LL | | }
3131
| |_^
32-
= note: expected `Project<'a, 'b>`
33-
found `Project<'_, '_>`
32+
= note: expected `Project<'a, 'b>`
33+
found `Project<'_, '_>`
3434

3535
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
3636
--> $DIR/regions-normalize-in-where-clause-list.rs:22:1

src/test/ui/regions/regions-ret-borrowed-1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ note: ...so that the expression is assignable
1414
|
1515
LL | with(|o| o)
1616
| ^
17-
= note: expected `&isize`
18-
found `&isize`
17+
= note: expected `&isize`
18+
found `&isize`
1919
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 9:14...
2020
--> $DIR/regions-ret-borrowed-1.rs:9:14
2121
|

src/test/ui/regions/regions-ret-borrowed.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ note: ...so that the expression is assignable
1414
|
1515
LL | with(|o| o)
1616
| ^
17-
= note: expected `&isize`
18-
found `&isize`
17+
= note: expected `&isize`
18+
found `&isize`
1919
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 12:14...
2020
--> $DIR/regions-ret-borrowed.rs:12:14
2121
|

0 commit comments

Comments
 (0)