This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 6d8a52d
authored
Unrolled build for rust-lang#130234
Rollup merge of rust-lang#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 rust-lang#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 rust-lang#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 rust-lang#130030
r? `@WaffleLapkin` but feel free to reassignFile tree
122 files changed
+552
-394
lines changed- compiler
- rustc_borrowck/src
- diagnostics
- type_check
- rustc_codegen_cranelift/src
- rustc_codegen_ssa/src/mir
- rustc_const_eval/src
- check_consts
- interpret
- rustc_hir_typeck/src
- rustc_middle/src
- mir
- thir
- ty
- rustc_mir_build/src
- build
- expr
- matches
- thir
- cx
- rustc_mir_transform/src
- shim
- rustc_monomorphize/src
- rustc_smir/src/rustc_smir/convert
- stable_mir/src/mir
- src/tools
- clippy/clippy_utils/src
- miri/tests/fail
- tests
- mir-opt
- building
- const_prop
- copy-prop
- dataflow-const-prop
- inline
- pre-codegen
- sroa
- ui
- borrowck
- cast
- dropck
- dyn-star
- kindck
- lifetimes
- mismatched_types
- nll
- user-annotations
- regions
- suggestions/lifetimes
- traits
- trait-upcasting
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
122 files changed
+552
-394
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
| |||
740 | 744 | | |
741 | 745 | | |
742 | 746 | | |
743 | | - | |
| 747 | + | |
744 | 748 | | |
745 | 749 | | |
746 | 750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1975 | 1975 | | |
1976 | 1976 | | |
1977 | 1977 | | |
1978 | | - | |
1979 | | - | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
1980 | 1981 | | |
1981 | 1982 | | |
1982 | 1983 | | |
| |||
2007 | 2008 | | |
2008 | 2009 | | |
2009 | 2010 | | |
2010 | | - | |
| 2011 | + | |
2011 | 2012 | | |
2012 | 2013 | | |
2013 | 2014 | | |
2014 | 2015 | | |
2015 | 2016 | | |
2016 | 2017 | | |
2017 | 2018 | | |
2018 | | - | |
| 2019 | + | |
2019 | 2020 | | |
2020 | 2021 | | |
2021 | 2022 | | |
| |||
2036 | 2037 | | |
2037 | 2038 | | |
2038 | 2039 | | |
2039 | | - | |
| 2040 | + | |
2040 | 2041 | | |
2041 | 2042 | | |
2042 | 2043 | | |
| |||
2049 | 2050 | | |
2050 | 2051 | | |
2051 | 2052 | | |
2052 | | - | |
| 2053 | + | |
2053 | 2054 | | |
2054 | 2055 | | |
2055 | 2056 | | |
| |||
2062 | 2063 | | |
2063 | 2064 | | |
2064 | 2065 | | |
2065 | | - | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
2066 | 2070 | | |
2067 | 2071 | | |
2068 | 2072 | | |
2069 | 2073 | | |
2070 | 2074 | | |
2071 | | - | |
| 2075 | + | |
2072 | 2076 | | |
| 2077 | + | |
2073 | 2078 | | |
2074 | 2079 | | |
2075 | 2080 | | |
2076 | 2081 | | |
2077 | | - | |
| 2082 | + | |
2078 | 2083 | | |
2079 | 2084 | | |
2080 | 2085 | | |
| |||
2087 | 2092 | | |
2088 | 2093 | | |
2089 | 2094 | | |
2090 | | - | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2091 | 2099 | | |
2092 | 2100 | | |
2093 | 2101 | | |
| |||
2099 | 2107 | | |
2100 | 2108 | | |
2101 | 2109 | | |
| 2110 | + | |
2102 | 2111 | | |
2103 | 2112 | | |
2104 | 2113 | | |
2105 | 2114 | | |
2106 | | - | |
| 2115 | + | |
2107 | 2116 | | |
2108 | 2117 | | |
2109 | 2118 | | |
| |||
2116 | 2125 | | |
2117 | 2126 | | |
2118 | 2127 | | |
2119 | | - | |
| 2128 | + | |
2120 | 2129 | | |
2121 | 2130 | | |
2122 | 2131 | | |
2123 | 2132 | | |
2124 | 2133 | | |
2125 | 2134 | | |
2126 | 2135 | | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
2127 | 2140 | | |
2128 | 2141 | | |
2129 | 2142 | | |
2130 | 2143 | | |
2131 | | - | |
2132 | | - | |
2133 | | - | |
2134 | | - | |
2135 | | - | |
2136 | | - | |
2137 | | - | |
| 2144 | + | |
| 2145 | + | |
2138 | 2146 | | |
2139 | 2147 | | |
2140 | 2148 | | |
2141 | 2149 | | |
2142 | | - | |
| 2150 | + | |
2143 | 2151 | | |
2144 | 2152 | | |
2145 | 2153 | | |
| |||
2150 | 2158 | | |
2151 | 2159 | | |
2152 | 2160 | | |
| 2161 | + | |
2153 | 2162 | | |
2154 | 2163 | | |
2155 | 2164 | | |
2156 | 2165 | | |
2157 | 2166 | | |
2158 | | - | |
| 2167 | + | |
2159 | 2168 | | |
2160 | 2169 | | |
2161 | 2170 | | |
| |||
2166 | 2175 | | |
2167 | 2176 | | |
2168 | 2177 | | |
2169 | | - | |
| 2178 | + | |
2170 | 2179 | | |
2171 | 2180 | | |
2172 | 2181 | | |
2173 | | - | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
2174 | 2186 | | |
2175 | 2187 | | |
2176 | 2188 | | |
| |||
2180 | 2192 | | |
2181 | 2193 | | |
2182 | 2194 | | |
| 2195 | + | |
2183 | 2196 | | |
2184 | 2197 | | |
2185 | 2198 | | |
2186 | 2199 | | |
2187 | | - | |
| 2200 | + | |
2188 | 2201 | | |
2189 | 2202 | | |
2190 | 2203 | | |
| |||
2197 | 2210 | | |
2198 | 2211 | | |
2199 | 2212 | | |
2200 | | - | |
| 2213 | + | |
2201 | 2214 | | |
2202 | 2215 | | |
2203 | 2216 | | |
| |||
2242 | 2255 | | |
2243 | 2256 | | |
2244 | 2257 | | |
| 2258 | + | |
2245 | 2259 | | |
2246 | 2260 | | |
2247 | 2261 | | |
2248 | 2262 | | |
2249 | | - | |
| 2263 | + | |
2250 | 2264 | | |
2251 | 2265 | | |
2252 | 2266 | | |
| |||
2427 | 2441 | | |
2428 | 2442 | | |
2429 | 2443 | | |
2430 | | - | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
2431 | 2448 | | |
2432 | 2449 | | |
2433 | 2450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
655 | | - | |
| 655 | + | |
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
| 680 | + | |
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
| 691 | + | |
691 | 692 | | |
692 | 693 | | |
693 | 694 | | |
| |||
741 | 742 | | |
742 | 743 | | |
743 | 744 | | |
744 | | - | |
| 745 | + | |
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
| |||
763 | 764 | | |
764 | 765 | | |
765 | 766 | | |
766 | | - | |
| 767 | + | |
767 | 768 | | |
768 | 769 | | |
769 | 770 | | |
770 | 771 | | |
771 | 772 | | |
772 | 773 | | |
773 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
774 | 779 | | |
775 | 780 | | |
776 | 781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
| 468 | + | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
| 484 | + | |
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
| 499 | + | |
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
| 503 | + | |
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
511 | | - | |
| 511 | + | |
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
| 529 | + | |
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
| |||
0 commit comments