Put backticks around field names, types and paths in error messages

Added to `DispatchFromDyn` and `CoerceUnsized` error messages
This commit is contained in:
Michael Hewson 2018-10-09 01:13:07 -04:00
parent 6f2a161b1b
commit b5b25f8196
4 changed files with 7 additions and 7 deletions

View File

@ -215,7 +215,7 @@ fn visit_implementation_of_dispatch_from_dyn<'a, 'tcx>(
&format!( &format!(
"the trait `DispatchFromDyn` may only be implemented \ "the trait `DispatchFromDyn` may only be implemented \
for a coercion between structures with the same \ for a coercion between structures with the same \
definition; expected {}, found {}", definition; expected `{}`, found `{}`",
source_path, target_path, source_path, target_path,
) )
).emit(); ).emit();
@ -271,7 +271,7 @@ fn visit_implementation_of_dispatch_from_dyn<'a, 'tcx>(
"currently, {} fields need coercions: {}", "currently, {} fields need coercions: {}",
coerced_fields.len(), coerced_fields.len(),
coerced_fields.iter().map(|field| { coerced_fields.iter().map(|field| {
format!("{} ({} to {})", format!("`{}` (`{}` to `{}`)",
field.ident, field.ident,
field.ty(tcx, substs_a), field.ty(tcx, substs_a),
field.ty(tcx, substs_b), field.ty(tcx, substs_b),
@ -398,7 +398,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
E0377, E0377,
"the trait `CoerceUnsized` may only be implemented \ "the trait `CoerceUnsized` may only be implemented \
for a coercion between structures with the same \ for a coercion between structures with the same \
definition; expected {}, found {}", definition; expected `{}`, found `{}`",
source_path, source_path,
target_path); target_path);
return err_info; return err_info;
@ -503,7 +503,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
diff_fields.len(), diff_fields.len(),
diff_fields.iter() diff_fields.iter()
.map(|&(i, a, b)| { .map(|&(i, a, b)| {
format!("{} ({} to {})", fields[i].ident, a, b) format!("`{}` (`{}` to `{}`)", fields[i].ident, a, b)
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", "))); .join(", ")));

View File

@ -5,7 +5,7 @@ LL | impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions | ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions
| |
= note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced
= note: currently, 2 fields need coercions: b (T to U), c (U to T) = note: currently, 2 fields need coercions: `b` (`T` to `U`), `c` (`U` to `T`)
error: aborting due to previous error error: aborting due to previous error

View File

@ -19,7 +19,7 @@ LL | | {} //~^^^ ERROR [E0378]
| |__^ | |__^
| |
= note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced
= note: currently, 2 fields need coercions: ptr1 (*const T to *const U), ptr2 (*const T to *const U) = note: currently, 2 fields need coercions: `ptr1` (`*const T` to `*const U`), `ptr2` (`*const T` to `*const U`)
error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced, none found error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced, none found
--> $DIR/invalid_dispatch_from_dyn_impls.rs:41:1 --> $DIR/invalid_dispatch_from_dyn_impls.rs:41:1

View File

@ -5,7 +5,7 @@ LL | impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{
| ^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions | ^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions
| |
= note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced
= note: currently, 2 fields need coercions: _ptr (*const T to *const U), _boo (NotPhantomData<T> to NotPhantomData<U>) = note: currently, 2 fields need coercions: `_ptr` (`*const T` to `*const U`), `_boo` (`NotPhantomData<T>` to `NotPhantomData<U>`)
error: aborting due to previous error error: aborting due to previous error