Skip to content

Commit 936d760

Browse files
authoredJun 16, 2024
Rollup merge of #126127 - Alexendoo:other-trait-diag, r=pnkfelix
Spell out other trait diagnostic I recently saw somebody confused about the diagnostic thinking it was suggesting to add an `as` cast. This change is longer but I think it's clearer
2 parents e4bc7de + d0112c6 commit 936d760

Some content is hidden

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

42 files changed

+348
-348
lines changed
 

‎compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20682068
if all_traits_equal {
20692069
format!("\n {}", c.self_ty())
20702070
} else {
2071-
format!("\n {c}")
2071+
format!("\n `{}` implements `{}`", c.self_ty(), c.print_only_trait_path())
20722072
}
20732073
})
20742074
.collect();

‎tests/ui/binop/binary-op-suggest-deref.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ LL | let _ = FOO & (*"Sized".to_string().into_boxed_str());
303303
|
304304
= help: the trait `BitAnd<str>` is not implemented for `i32`
305305
= help: the following other types implement trait `BitAnd<Rhs>`:
306-
<&'a i32 as BitAnd<i32>>
307-
<&i32 as BitAnd<&i32>>
308-
<i32 as BitAnd<&i32>>
309-
<i32 as BitAnd>
306+
`&'a i32` implements `BitAnd<i32>`
307+
`&i32` implements `BitAnd<&i32>`
308+
`i32` implements `BitAnd<&i32>`
309+
`i32` implements `BitAnd`
310310

311311
error[E0277]: the size for values of type `str` cannot be known at compilation time
312312
--> $DIR/binary-op-suggest-deref.rs:78:17

0 commit comments

Comments
 (0)
Please sign in to comment.