e4a3627c24
Generalize `get_nullable_type` to allow types where null is all-ones. Generalize get_nullable_type to accept types that have an all-ones bit pattern as their sentry "null" value. This will allow [`OwnedFd`], [`BorrowedFd`], [`OwnedSocket`], and [`BorrowedSocket`] to be marked with `#[rustc_nonnull_optimization_guaranteed]`, which will allow `Option<OwnedFd>`, `Option<BorrowedFd>`, `Option<OwnedSocket>`, and `Option<BorrowedSocket>` to be used in FFI declarations, as described in the [I/O safety RFC]. For example, it will allow a function like `open` on Unix and `WSASocketW` on Windows to be declared using `Option<OwnedFd>` and `Option<OwnedSocket>` return types, respectively. The actual change to add `#[rustc_nonnull_optimization_guaranteed]` to the abovementioned types will be a separate PR, as it'll depend on having this patch in the stage0 compiler. Also, update the diagnostics to mention that "niche optimizations" are used in libstd as well as libcore, as `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` are already in use in libstd. [`OwnedFd`]: |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |