about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-02-24 19:21:45 -0500
committerGitHub <noreply@github.com>2025-02-24 19:21:45 -0500
commit0bb00e2085b169bfc21e58b299f67f44c906d2fa (patch)
treef5126f1db3325a493fdca88f16e7630b2107618b /library/std/src
parent748af6b3e441fb624ee96d48d6e3935642427a91 (diff)
parentb46acc01916ba3e8b8f8ab9d89608861d1d4cb87 (diff)
downloadrust-0bb00e2085b169bfc21e58b299f67f44c906d2fa.tar.gz
rust-0bb00e2085b169bfc21e58b299f67f44c906d2fa.zip
Rollup merge of #137289 - compiler-errors:coerce-unsized-errors, r=oli-obk
Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`

Firstly, this PR consolidates and reworks the error diagnostics for `CoercePointee` and `DispatchFromDyn`. There was a ton of duplication for no reason -- this reworks both the errors and also the error codes, since they can be shared between both traits since they report the same thing.

Secondly, when encountering a struct with multiple fields that must be coerced, point out the field spans, rather than mentioning the fields by name. This makes the error message clearer, but also means that we don't mention the `__S` dummy parameter for `derive(CoercePointee)`.

Thirdly, emit a custom error message when we encounter a trait error that comes from the recursive field `CoerceUnsized`/`DispatchFromDyn` trait check. **Note:** This is the only one I'm not too satisfied with -- I think it could use some more refinement, but ideally it explains that the field must be an unsize-able pointer... Feedback welcome.

Finally, don't emit `DispatchFromDyn` validity errors if we detect `CoerceUnsized` validity errors from an impl of the same ADT.

This is best reviewed per commit.

r? `@oli-obk` perhaps?

cc `@dingxiangfei2009` -- sorry for making my own attempt at this PR, but I wanted to see if I could implement a fix for #136796 in a less complicated way, since communicating over github review comments can be a bit slow. I'll leave comments inline to explain my thinking about the diagnostics changes.
Diffstat (limited to 'library/std/src')
0 files changed, 0 insertions, 0 deletions