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`

0 commit comments

Comments
 (0)