diff options
| author | bors <bors@rust-lang.org> | 2022-11-26 08:56:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-26 08:56:20 +0000 |
| commit | 8841bee954ecf0e6820c9990feb3a76cb04e7d96 (patch) | |
| tree | 33cdcb23858966c692ec79816aaf6ca593b9eaca /compiler/rustc_macros/src/lib.rs | |
| parent | f8a2e491ebec34113563cf8683f6fec2646cebb1 (diff) | |
| parent | b9a95d89902a6c9ba17dae21d84c2c04454bdddd (diff) | |
| download | rust-8841bee954ecf0e6820c9990feb3a76cb04e7d96.tar.gz rust-8841bee954ecf0e6820c9990feb3a76cb04e7d96.zip | |
Auto merge of #103556 - clubby789:specialize-option-partial-eq, r=scottmcm
Manually implement PartialEq for Option<T> and specialize non-nullable types This PR manually implements `PartialEq` and `StructuralPartialEq` for `Option`, which seems to produce slightly better codegen than the automatically derived implementation. It also allows specializing on the `core::num::NonZero*` and `core::ptr::NonNull` types, taking advantage of the niche optimization by transmuting the `Option<T>` to `T` to be compared directly, which can be done in just two instructions. A comparison of the original, new and specialized code generation is available [here](https://godbolt.org/z/dE4jxdYsa).
Diffstat (limited to 'compiler/rustc_macros/src/lib.rs')
| -rw-r--r-- | compiler/rustc_macros/src/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index a2a01b66690..ac916bb6068 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -48,7 +48,7 @@ pub fn symbols(input: TokenStream) -> TokenStream { /// `u32::MAX`. You can also customize things like the `Debug` impl, /// what traits are derived, and so forth via the macro. #[proc_macro] -#[allow_internal_unstable(step_trait, rustc_attrs, trusted_step)] +#[allow_internal_unstable(step_trait, rustc_attrs, trusted_step, spec_option_partial_eq)] pub fn newtype_index(input: TokenStream) -> TokenStream { newtype::newtype(input) } |
