Skip to content

Commit 6f8f706

Browse files
committed
Surround types with backticks in type errors
1 parent 94c6425 commit 6f8f706

File tree

351 files changed

+1086
-1086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+1086
-1086
lines changed

src/librustc/ty/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ impl<'tcx> ty::TyS<'tcx> {
222222
pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
223223
match self.kind {
224224
ty::Bool | ty::Char | ty::Int(_) |
225-
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => format!("{}", self).into(),
226-
ty::Tuple(ref tys) if tys.is_empty() => format!("{}", self).into(),
225+
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => format!("`{}`", self).into(),
226+
ty::Tuple(ref tys) if tys.is_empty() => format!("`{}`", self).into(),
227227

228228
ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.def_path_str(def.did)).into(),
229229
ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(),
@@ -244,7 +244,7 @@ impl<'tcx> ty::TyS<'tcx> {
244244
if tymut_string != "_" && (
245245
ty.is_simple_text() || tymut_string.len() < "mutable reference".len()
246246
) {
247-
format!("&{}", tymut_string).into()
247+
format!("`&{}`", tymut_string).into()
248248
} else { // Unknown type name, it's long or has type arguments
249249
match mutbl {
250250
hir::Mutability::Mutable => "mutable reference",
@@ -256,7 +256,7 @@ impl<'tcx> ty::TyS<'tcx> {
256256
ty::FnPtr(_) => "fn pointer".into(),
257257
ty::Dynamic(ref inner, ..) => {
258258
if let Some(principal) = inner.principal() {
259-
format!("trait {}", tcx.def_path_str(principal.def_id())).into()
259+
format!("trait `{}`", tcx.def_path_str(principal.def_id())).into()
260260
} else {
261261
"trait".into()
262262
}

src/librustc/ty/wf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
209209
// LL | impl Bar for Foo {
210210
// | ---------------- in this `impl` item
211211
// LL | type Ok = ();
212-
// | ^^^^^^^^^^^^^ expected u32, found ()
212+
// | ^^^^^^^^^^^^^ expected `u32`, found `()`
213213
// |
214214
// = note: expected type `u32`
215215
// found type `()`
@@ -228,7 +228,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
228228
// LL | impl Bar for Foo {
229229
// | ---------------- in this `impl` item
230230
// LL | type Ok = ();
231-
// | ^^^^^^^^^^^^^ expected u32, found ()
231+
// | ^^^^^^^^^^^^^ expected `u32`, found `()`
232232
// ...
233233
// LL | impl Bar2 for Foo2 {
234234
// | ---------------- in this `impl` item

src/librustc_typeck/check/_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
285285
// || ----- expected because of this
286286
// LL || } else {
287287
// LL || 10u32
288-
// || ^^^^^ expected i32, found u32
288+
// || ^^^^^ expected `i32`, found `u32`
289289
// LL || };
290290
// ||_____- if and else have incompatible types
291291
// ```
@@ -294,7 +294,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
294294
// The entire expression is in one line, only point at the arms
295295
// ```
296296
// LL | let x = if true { 10i32 } else { 10u32 };
297-
// | ----- ^^^^^ expected i32, found u32
297+
// | ----- ^^^^^ expected `i32`, found `u32`
298298
// | |
299299
// | expected because of this
300300
// ```
@@ -323,7 +323,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
323323
// | || ^
324324
// | ||_____|
325325
// | |______if and else have incompatible types
326-
// | expected integer, found ()
326+
// | expected integer, found `()`
327327
// ```
328328
// by not pointing at the entire expression:
329329
// ```
@@ -335,7 +335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
335335
// | ____________^
336336
// 5 | |
337337
// 6 | | };
338-
// | |_____^ expected integer, found ()
338+
// | |_____^ expected integer, found `()`
339339
// ```
340340
if outer_sp.is_some() {
341341
outer_sp = Some(self.tcx.sess.source_map().def_span(span));

src/librustc_typeck/check/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4747
/// 4 | let temp: usize = match a + b {
4848
/// | ----- this expression has type `usize`
4949
/// 5 | Ok(num) => num,
50-
/// | ^^^^^^^ expected usize, found enum `std::result::Result`
50+
/// | ^^^^^^^ expected `usize`, found enum `std::result::Result`
5151
/// |
5252
/// = note: expected type `usize`
5353
/// found type `std::result::Result<_, _>`

src/test/rustdoc-ui/failed-doctest-missing-codes.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ error[E0308]: mismatched types
99
--> $DIR/failed-doctest-missing-codes.rs:9:13
1010
|
1111
LL | let x: () = 5i32;
12-
| ^^^^ expected (), found i32
12+
| ^^^^ expected `()`, found `i32`
1313

1414
error: aborting due to previous error
1515

src/test/ui/arg-type-mismatch.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/arg-type-mismatch.rs:5:30
33
|
44
LL | fn main() { let i: (); i = f(()); }
5-
| ^^ expected isize, found ()
5+
| ^^ expected `isize`, found `()`
66

77
error: aborting due to previous error
88

src/test/ui/array-break-length.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0308]: mismatched types
1414
--> $DIR/array-break-length.rs:3:9
1515
|
1616
LL | |_: [_; break]| {}
17-
| ^^^^^^^^^^^^^^^^^^ expected (), found closure
17+
| ^^^^^^^^^^^^^^^^^^ expected `()`, found closure
1818
|
1919
= note: expected unit type `()`
2020
found closure `[closure@$DIR/array-break-length.rs:3:9: 3:27]`
@@ -23,7 +23,7 @@ error[E0308]: mismatched types
2323
--> $DIR/array-break-length.rs:8:9
2424
|
2525
LL | |_: [_; continue]| {}
26-
| ^^^^^^^^^^^^^^^^^^^^^ expected (), found closure
26+
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure
2727
|
2828
= note: expected unit type `()`
2929
found closure `[closure@$DIR/array-break-length.rs:8:9: 8:30]`

src/test/ui/array-not-vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
fn main() {
22
let _x: i32 = [1, 2, 3];
33
//~^ ERROR mismatched types
4-
//~| expected i32, found array
4+
//~| expected `i32`, found array
55

66
let x: &[i32] = &[1, 2, 3];
77
let _y: &i32 = x;
88
//~^ ERROR mismatched types
99
//~| expected reference `&i32`
1010
//~| found reference `&[i32]`
11-
//~| expected i32, found slice
11+
//~| expected `i32`, found slice
1212
}

src/test/ui/array-not-vector.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0308]: mismatched types
22
--> $DIR/array-not-vector.rs:2:19
33
|
44
LL | let _x: i32 = [1, 2, 3];
5-
| ^^^^^^^^^ expected i32, found array `[{integer}; 3]`
5+
| ^^^^^^^^^ expected `i32`, found array `[{integer}; 3]`
66

77
error[E0308]: mismatched types
88
--> $DIR/array-not-vector.rs:7:20
99
|
1010
LL | let _y: &i32 = x;
11-
| ^ expected i32, found slice `[i32]`
11+
| ^ expected `i32`, found slice `[i32]`
1212
|
1313
= note: expected reference `&i32`
1414
found reference `&[i32]`

src/test/ui/associated-const/associated-const-generic-obligations.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | const FROM: Self::Out;
55
| --------- type in trait
66
...
77
LL | const FROM: &'static str = "foo";
8-
| ^^^^^^^^^^^^ expected associated type, found &str
8+
| ^^^^^^^^^^^^ expected associated type, found `&str`
99
|
1010
= note: expected associated type `<T as Foo>::Out`
1111
found reference `&'static str`

src/test/ui/associated-const/associated-const-impl-wrong-type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | const BAR: u32;
55
| --- type in trait
66
...
77
LL | const BAR: i32 = -1;
8-
| ^^^ expected u32, found i32
8+
| ^^^ expected `u32`, found `i32`
99

1010
error: aborting due to previous error
1111

src/test/ui/associated-types/associated-types-eq-3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub fn main() {
3737
let a = 42;
3838
foo1(a);
3939
//~^ ERROR type mismatch resolving
40-
//~| expected struct `Bar`, found usize
40+
//~| expected struct `Bar`, found `usize`
4141
baz(&a);
4242
//~^ ERROR type mismatch resolving
43-
//~| expected struct `Bar`, found usize
43+
//~| expected struct `Bar`, found `usize`
4444
}

src/test/ui/associated-types/associated-types-eq-3.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ LL | fn foo1<I: Foo<A=Bar>>(x: I) {
1616
| ---- ----- required by this bound in `foo1`
1717
...
1818
LL | foo1(a);
19-
| ^^^^ expected struct `Bar`, found usize
19+
| ^^^^ expected struct `Bar`, found `usize`
2020

2121
error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
2222
--> $DIR/associated-types-eq-3.rs:41:9
2323
|
2424
LL | baz(&a);
25-
| ^^ expected struct `Bar`, found usize
25+
| ^^ expected struct `Bar`, found `usize`
2626
|
2727
= note: required for the cast to the object type `dyn Foo<A = Bar>`
2828

src/test/ui/associated-types/associated-types-eq-hr.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize>
77
| ------------- required by this bound in `foo`
88
...
99
LL | foo::<UintStruct>();
10-
| ^^^^^^^^^^^^^^^^^ expected isize, found usize
10+
| ^^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
1111
|
1212
= note: expected reference `&isize`
1313
found reference `&usize`
@@ -21,7 +21,7 @@ LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize>
2121
| ------------- required by this bound in `bar`
2222
...
2323
LL | bar::<IntStruct>();
24-
| ^^^^^^^^^^^^^^^^ expected usize, found isize
24+
| ^^^^^^^^^^^^^^^^ expected `usize`, found `isize`
2525
|
2626
= note: expected reference `&usize`
2727
found reference `&isize`

src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
22
--> $DIR/associated-types-multiple-types-one-trait.rs:13:5
33
|
44
LL | want_y(t);
5-
| ^^^^^^ expected i32, found associated type
5+
| ^^^^^^ expected `i32`, found associated type
66
...
77
LL | fn want_y<T:Foo<Y=i32>>(t: &T) { }
88
| ------ ----- required by this bound in `want_y`
@@ -16,7 +16,7 @@ error[E0271]: type mismatch resolving `<T as Foo>::X == u32`
1616
--> $DIR/associated-types-multiple-types-one-trait.rs:18:5
1717
|
1818
LL | want_x(t);
19-
| ^^^^^^ expected u32, found associated type
19+
| ^^^^^^ expected `u32`, found associated type
2020
...
2121
LL | fn want_x<T:Foo<X=u32>>(t: &T) { }
2222
| ------ ----- required by this bound in `want_x`

src/test/ui/associated-types/associated-types-overridden-binding-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as std::iter::It
22
--> $DIR/associated-types-overridden-binding-2.rs:6:43
33
|
44
LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter();
5-
| ^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
5+
| ^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
66
|
77
= note: required for the cast to the object type `dyn std::iter::Iterator<Item = u32, Item = i32>`
88

src/test/ui/associated-types/associated-types-path-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn f2<T: Foo>(a: T) -> T::A {
1818
pub fn f1_int_int() {
1919
f1(2i32, 4i32);
2020
//~^ ERROR mismatched types
21-
//~| expected u32, found i32
21+
//~| expected `u32`, found `i32`
2222
}
2323

2424
pub fn f1_int_uint() {
@@ -40,7 +40,7 @@ pub fn f1_uint_int() {
4040
pub fn f2_int() {
4141
let _: i32 = f2(2i32);
4242
//~^ ERROR mismatched types
43-
//~| expected i32, found u32
43+
//~| expected `i32`, found `u32`
4444
}
4545

4646
pub fn main() { }

src/test/ui/associated-types/associated-types-path-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/associated-types-path-2.rs:19:14
33
|
44
LL | f1(2i32, 4i32);
5-
| ^^^^ expected u32, found i32
5+
| ^^^^ expected `u32`, found `i32`
66
|
77
help: change the type of the numeric literal from `i32` to `u32`
88
|
@@ -43,7 +43,7 @@ error[E0308]: mismatched types
4343
--> $DIR/associated-types-path-2.rs:41:18
4444
|
4545
LL | let _: i32 = f2(2i32);
46-
| ^^^^^^^^ expected i32, found u32
46+
| ^^^^^^^^ expected `i32`, found `u32`
4747
|
4848
help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit
4949
|

src/test/ui/associated-types/issue-44153.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn visit() {}
55
| ---------- required by `Visit::visit`
66
...
77
LL | <() as Visit>::visit();
8-
| ^^^^^^^^^^^^^^^^^^^^ expected (), found &()
8+
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()`
99
|
1010
= note: required because of the requirements on the impl of `Visit` for `()`
1111

src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | type Ok;
77
LL | impl Bar for Foo {
88
| ---------------- in this `impl` item
99
LL | type Ok = ();
10-
| ^^^^^^^^^^^^^ expected u32, found ()
10+
| ^^^^^^^^^^^^^ expected `u32`, found `()`
1111

1212
error: aborting due to previous error
1313

src/test/ui/async-await/async-block-control-flow-static-semantics.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ error[E0308]: mismatched types
2222
--> $DIR/async-block-control-flow-static-semantics.rs:13:43
2323
|
2424
LL | fn return_targets_async_block_not_fn() -> u8 {
25-
| --------------------------------- ^^ expected u8, found ()
25+
| --------------------------------- ^^ expected `u8`, found `()`
2626
| |
2727
| implicitly returns `()` as its body has no tail or `return` expression
2828

2929
error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
3030
--> $DIR/async-block-control-flow-static-semantics.rs:18:39
3131
|
3232
LL | let _: &dyn Future<Output = ()> = &block;
33-
| ^^^^^^ expected (), found u8
33+
| ^^^^^^ expected `()`, found `u8`
3434
|
3535
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
3636

@@ -45,21 +45,21 @@ LL | | return 0u8;
4545
... |
4646
LL | |
4747
LL | | }
48-
| |_^ expected u8, found ()
48+
| |_^ expected `u8`, found `()`
4949

5050
error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
5151
--> $DIR/async-block-control-flow-static-semantics.rs:27:39
5252
|
5353
LL | let _: &dyn Future<Output = ()> = &block;
54-
| ^^^^^^ expected (), found u8
54+
| ^^^^^^ expected `()`, found `u8`
5555
|
5656
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
5757

5858
error[E0308]: mismatched types
5959
--> $DIR/async-block-control-flow-static-semantics.rs:48:44
6060
|
6161
LL | fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
62-
| ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
62+
| ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()`
6363
| |
6464
| implicitly returns `()` as its body has no tail or `return` expression
6565
|
@@ -70,7 +70,7 @@ error[E0308]: mismatched types
7070
--> $DIR/async-block-control-flow-static-semantics.rs:57:50
7171
|
7272
LL | fn rethrow_targets_async_block_not_async_fn() -> Result<u8, MyErr> {
73-
| ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
73+
| ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()`
7474
| |
7575
| implicitly returns `()` as its body has no tail or `return` expression
7676
|

src/test/ui/async-await/dont-suggest-missing-await.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/dont-suggest-missing-await.rs:14:18
33
|
44
LL | take_u32(x)
5-
| ^ expected u32, found opaque type
5+
| ^ expected `u32`, found opaque type
66
|
77
= note: expected type `u32`
88
found opaque type `impl std::future::Future`

src/test/ui/async-await/suggest-missing-await-closure.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | take_u32(x)
55
| ^
66
| |
7-
| expected u32, found opaque type
7+
| expected `u32`, found opaque type
88
| help: consider using `.await` here: `x.await`
99
|
1010
= note: expected type `u32`

src/test/ui/async-await/suggest-missing-await.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | take_u32(x)
55
| ^
66
| |
7-
| expected u32, found opaque type
7+
| expected `u32`, found opaque type
88
| help: consider using `.await` here: `x.await`
99
|
1010
= note: expected type `u32`

src/test/ui/binop/binop-logic-float.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0308]: mismatched types
22
--> $DIR/binop-logic-float.rs:1:21
33
|
44
LL | fn main() { let x = 1.0_f32 || 2.0_f32; }
5-
| ^^^^^^^ expected bool, found f32
5+
| ^^^^^^^ expected `bool`, found `f32`
66

77
error[E0308]: mismatched types
88
--> $DIR/binop-logic-float.rs:1:32
99
|
1010
LL | fn main() { let x = 1.0_f32 || 2.0_f32; }
11-
| ^^^^^^^ expected bool, found f32
11+
| ^^^^^^^ expected `bool`, found `f32`
1212

1313
error: aborting due to 2 previous errors
1414

0 commit comments

Comments
 (0)