Commit df0d9b4
committed
Auto merge of rust-lang#110496 - WaffleLapkin:🏳️⚧️sound, r=compiler-errors
Don't transmute `&List<GenericArg>` <-> `&List<Ty>`
In rust-lang#93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`.
While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see rust-lang#94799 (comment), rust-lang#94841, rust-lang#110496 (comment)).
Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler).
Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc.
r? `@compiler-errors`File tree
5 files changed
+32
-57
lines changed- compiler
- rustc_middle/src/ty
- rustc_traits/src/chalk
- src/tools/clippy/clippy_utils/src
5 files changed
+32
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
1278 | 1280 | | |
1279 | 1281 | | |
1280 | 1282 | | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
1291 | | - | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
1300 | 1283 | | |
1301 | 1284 | | |
1302 | 1285 | | |
| |||
1320 | 1303 | | |
1321 | 1304 | | |
1322 | 1305 | | |
| 1306 | + | |
1323 | 1307 | | |
1324 | 1308 | | |
1325 | 1309 | | |
| |||
1594 | 1578 | | |
1595 | 1579 | | |
1596 | 1580 | | |
| 1581 | + | |
1597 | 1582 | | |
1598 | 1583 | | |
1599 | 1584 | | |
| |||
2193 | 2178 | | |
2194 | 2179 | | |
2195 | 2180 | | |
2196 | | - | |
2197 | | - | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
2204 | | - | |
2205 | | - | |
2206 | | - | |
2207 | | - | |
2208 | 2181 | | |
2209 | 2182 | | |
2210 | 2183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 70 | | |
84 | 71 | | |
85 | 72 | | |
| |||
268 | 255 | | |
269 | 256 | | |
270 | 257 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
278 | 268 | | |
279 | 269 | | |
280 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
351 | 365 | | |
352 | 366 | | |
353 | 367 | | |
354 | | - | |
355 | | - | |
356 | | - | |
| 368 | + | |
357 | 369 | | |
358 | 370 | | |
359 | 371 | | |
| |||
435 | 447 | | |
436 | 448 | | |
437 | 449 | | |
438 | | - | |
| 450 | + | |
439 | 451 | | |
440 | 452 | | |
441 | 453 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
978 | | - | |
| 978 | + | |
979 | 979 | | |
980 | 980 | | |
981 | 981 | | |
| |||
0 commit comments