1
Fork 0

Remove SpecOptionPartialEq

This commit is contained in:
clubby789 2024-03-05 13:26:47 +00:00
parent f296c162d8
commit 5f254d8b66
5 changed files with 51 additions and 136 deletions

View file

@ -34,13 +34,7 @@ mod newtype;
#[proc_macro]
#[cfg_attr(
feature = "nightly",
allow_internal_unstable(
step_trait,
rustc_attrs,
trusted_step,
spec_option_partial_eq,
min_specialization
)
allow_internal_unstable(step_trait, rustc_attrs, trusted_step, min_specialization)
)]
pub fn newtype_index(input: TokenStream) -> TokenStream {
newtype::newtype(input)

View file

@ -156,32 +156,6 @@ impl Parse for Newtype {
}
};
let spec_partial_eq_impl = if let Lit::Int(max) = &max {
if let Ok(max_val) = max.base10_parse::<u32>() {
quote! {
#gate_rustc_only
impl core::option::SpecOptionPartialEq for #name {
#[inline]
fn eq(l: &Option<Self>, r: &Option<Self>) -> bool {
if #max_val < u32::MAX {
l.map(|i| i.as_u32()).unwrap_or(#max_val+1) == r.map(|i| i.as_u32()).unwrap_or(#max_val+1)
} else {
match (l, r) {
(Some(l), Some(r)) => r == l,
(None, None) => true,
_ => false
}
}
}
}
}
} else {
quote! {}
}
} else {
quote! {}
};
Ok(Self(quote! {
#(#attrs)*
#[derive(Clone, Copy, PartialEq, Eq, Hash, #(#derive_paths),*)]
@ -283,8 +257,6 @@ impl Parse for Newtype {
#step
#spec_partial_eq_impl
impl From<#name> for u32 {
#[inline]
fn from(v: #name) -> u32 {