rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
93.58k stars 12.05k forks source link

Support Result<T, E> across FFI when niche optimization can be used (v2) #124747

Closed dtolnay closed 1 week ago

dtolnay commented 1 week ago

This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a CI bug.

r? ghost

Original PR description:


Allow allow enums like Result<T, E> to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe.

Implementation of https://github.com/rust-lang/rfcs/pull/3391 Tracking issue: https://github.com/rust-lang/rust/issues/110503

Additional ABI and codegen tests were added in https://github.com/rust-lang/rust/pull/115372

dtolnay commented 1 week ago

@bors r=davidtwco

bors commented 1 week ago

:pushpin: Commit ed532cc186a651a3e4b848ffbef8c080018f1732 has been approved by davidtwco

It is now in the queue for this repository.

bors commented 1 week ago

:hourglass: Testing commit ed532cc186a651a3e4b848ffbef8c080018f1732 with merge 80420a693f89ce4201a8e43b8d5191c7ee0fa368...

bors commented 1 week ago

:sunny: Test successful - checks-actions Approved by: davidtwco Pushing 80420a693f89ce4201a8e43b8d5191c7ee0fa368 to master...

rust-timer commented 1 week ago

Finished benchmarking commit (80420a693f89ce4201a8e43b8d5191c7ee0fa368): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment. | | mean | range | count | |:----------------------------------:|:----:|:------------:|:-----:| | Regressions ❌
(primary) | - | - | 0 | | Regressions ❌
(secondary) | 4.9% | [4.9%, 4.9%] | 1 | | Improvements ✅
(primary) | - | - | 0 | | Improvements ✅
(secondary) | - | - | 0 | | All ❌✅ (primary) | - | - | 0 |

Cycles

Results This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment. | | mean | range | count | |:----------------------------------:|:----:|:------------:|:-----:| | Regressions ❌
(primary) | - | - | 0 | | Regressions ❌
(secondary) | 2.1% | [2.0%, 2.2%] | 3 | | Improvements ✅
(primary) | - | - | 0 | | Improvements ✅
(secondary) | - | - | 0 | | All ❌✅ (primary) | - | - | 0 |

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 675.885s -> 676.339s (0.07%) Artifact size: 315.88 MiB -> 315.76 MiB (-0.04%)