Commit bd549b9
[WIP] Generalize SizeEq to SizeCompat
This requires us to generalize our prior support for transmuting between
unsized types. In particular, we previously used the `SizeEq` trait to
denote that two types have equal sizes in the face of a cast operation
(in particular, that `*const T as *const U` preserves referent size). In
this commit, we add support for metadata fix-up, which means that we
support casts for which `*const T as *const U` does *not* preserve
referent size. Instead, we compute an affine function at compile time
and apply it at runtime - computing the destination type's metadata as a
function of the source metadata, `dst_meta = A + src_meta * B`. `A` and
`B` are computed at compile time.
We generalize `SizeEq` to permit its `cast_from_raw` method to perform a
runtime metadata fix-up operation.
Makes progress on #1817
Co-authored-by: Jack Wrenn <[email protected]>
gherrit-pr-id: I6c793a9620ad75bdc0d26ab7c7cd1a0c7bef1b8b1 parent 81a0fd9 commit bd549b9
File tree
6 files changed
+208
-129
lines changed- src
- pointer
- util
6 files changed
+208
-129
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | | - | |
| 177 | + | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
400 | | - | |
| 399 | + | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
404 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
405 | 407 | | |
406 | | - | |
407 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
408 | 412 | | |
409 | 413 | | |
410 | | - | |
411 | | - | |
412 | | - | |
| 414 | + | |
| 415 | + | |
413 | 416 | | |
414 | 417 | | |
415 | | - | |
416 | | - | |
| 418 | + | |
| 419 | + | |
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
421 | 424 | | |
422 | | - | |
| 425 | + | |
423 | 426 | | |
424 | 427 | | |
425 | 428 | | |
426 | 429 | | |
427 | 430 | | |
428 | 431 | | |
429 | | - | |
430 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
431 | 437 | | |
432 | 438 | | |
433 | 439 | | |
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
437 | | - | |
| 443 | + | |
438 | 444 | | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
442 | 448 | | |
443 | 449 | | |
444 | 450 | | |
445 | | - | |
| 451 | + | |
446 | 452 | | |
447 | 453 | | |
448 | 454 | | |
449 | 455 | | |
450 | 456 | | |
451 | 457 | | |
452 | 458 | | |
453 | | - | |
454 | | - | |
455 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
456 | 465 | | |
457 | 466 | | |
458 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
620 | | - | |
| 620 | + | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
| 623 | + | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
393 | 396 | | |
394 | | - | |
| 397 | + | |
395 | 398 | | |
396 | 399 | | |
397 | 400 | | |
| |||
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
405 | | - | |
| 408 | + | |
406 | 409 | | |
407 | 410 | | |
408 | 411 | | |
| |||
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
416 | 422 | | |
417 | 423 | | |
418 | 424 | | |
| |||
858 | 864 | | |
859 | 865 | | |
860 | 866 | | |
861 | | - | |
862 | | - | |
863 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
864 | 874 | | |
865 | 875 | | |
866 | 876 | | |
| |||
0 commit comments