about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2024-09-24 19:47:48 -0400
committerGitHub <noreply@github.com>2024-09-24 19:47:48 -0400
commit75296fc72117153c9165f41575c4439087bd40f0 (patch)
treea514b30ead2a155f96eed4f892e40da5b3a1a99e /compiler/rustc_codegen_llvm/src
parent363ae4188316b8b22cf6c1890bc73d84d05f70a4 (diff)
parentb62e72ce8c31bbfd028136570a5e46bee233d4f3 (diff)
downloadrust-75296fc72117153c9165f41575c4439087bd40f0.tar.gz
rust-75296fc72117153c9165f41575c4439087bd40f0.zip
Rollup merge of #130234 - lukas-code:ptr-cast-errors, r=WaffleLapkin
improve compile errors for invalid ptr-to-ptr casts with trait objects

This is a follow-up to https://github.com/rust-lang/rust/pull/120248 to improve some of its error messages.

1. Make the borrowcheck error for "type annotation requires that x must outlive y" actually point at the type annotation, i.e. the type `T` in a `x as T` cast. This makes the error more consistent with other errors caused by type annotation in other places, such as
```text
error: lifetime may not live long enough
 --> src/lib.rs:4:12
  |
3 | fn bar(a: &i32) {
  |           - let's call the lifetime of this reference `'1`
4 |     let b: &'static i32 = a;
  |            ^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
```

2. Don't say "cast" when we actually mean "coercion" and give borrowcheck errors from actual casts (which is currently just the check added in https://github.com/rust-lang/rust/pull/120248) a higher priority than ones from coercions. This can improve the errors for ptr-to-ptr cast between trait objects because they are are lowered as an upcast "unsizing" coercion if possible (which may be the identity upcast) followed by the actual cast.

3. Bring back the old "casting X as Y is invalid" message for type mismatch in the principals and reword the "vtable kinds may not match" message to more accurately describe the pointer metadata and not refer to "vtables" if the metadata is unknown.

fixes https://github.com/rust-lang/rust/issues/130030

r? `@WaffleLapkin` but feel free to reassign
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions