Skip to content

Commit b5b25f8

Browse files
committed
Put backticks around field names, types and paths in error messages
Added to `DispatchFromDyn` and `CoerceUnsized` error messages
1 parent 6f2a161 commit b5b25f8

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/librustc_typeck/coherence/builtin.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ fn visit_implementation_of_dispatch_from_dyn<'a, 'tcx>(
215215
&format!(
216216
"the trait `DispatchFromDyn` may only be implemented \
217217
for a coercion between structures with the same \
218-
definition; expected {}, found {}",
218+
definition; expected `{}`, found `{}`",
219219
source_path, target_path,
220220
)
221221
).emit();
@@ -271,7 +271,7 @@ fn visit_implementation_of_dispatch_from_dyn<'a, 'tcx>(
271271
"currently, {} fields need coercions: {}",
272272
coerced_fields.len(),
273273
coerced_fields.iter().map(|field| {
274-
format!("{} ({} to {})",
274+
format!("`{}` (`{}` to `{}`)",
275275
field.ident,
276276
field.ty(tcx, substs_a),
277277
field.ty(tcx, substs_b),
@@ -398,7 +398,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
398398
E0377,
399399
"the trait `CoerceUnsized` may only be implemented \
400400
for a coercion between structures with the same \
401-
definition; expected {}, found {}",
401+
definition; expected `{}`, found `{}`",
402402
source_path,
403403
target_path);
404404
return err_info;
@@ -503,7 +503,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
503503
diff_fields.len(),
504504
diff_fields.iter()
505505
.map(|&(i, a, b)| {
506-
format!("{} ({} to {})", fields[i].ident, a, b)
506+
format!("`{}` (`{}` to `{}`)", fields[i].ident, a, b)
507507
})
508508
.collect::<Vec<_>>()
509509
.join(", ")));

src/test/ui/error-codes/E0375.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions
66
|
77
= note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced
8-
= note: currently, 2 fields need coercions: b (T to U), c (U to T)
8+
= note: currently, 2 fields need coercions: `b` (`T` to `U`), `c` (`U` to `T`)
99

1010
error: aborting due to previous error
1111

src/test/ui/invalid_dispatch_from_dyn_impls.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LL | | {} //~^^^ ERROR [E0378]
1919
| |__^
2020
|
2121
= note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced
22-
= note: currently, 2 fields need coercions: ptr1 (*const T to *const U), ptr2 (*const T to *const U)
22+
= note: currently, 2 fields need coercions: `ptr1` (`*const T` to `*const U`), `ptr2` (`*const T` to `*const U`)
2323

2424
error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced, none found
2525
--> $DIR/invalid_dispatch_from_dyn_impls.rs:41:1

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{
55
| ^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions
66
|
77
= note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced
8-
= note: currently, 2 fields need coercions: _ptr (*const T to *const U), _boo (NotPhantomData<T> to NotPhantomData<U>)
8+
= note: currently, 2 fields need coercions: `_ptr` (`*const T` to `*const U`), `_boo` (`NotPhantomData<T>` to `NotPhantomData<U>`)
99

1010
error: aborting due to previous error
1111

0 commit comments

Comments
 (0)