Skip to content

Commit 2c29462

Browse files
committed
Fix type inference failures in PartialOrd/Ord impls
1 parent bc05181 commit 2c29462

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/trait_handlers/ord/ord_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl TraitHandler for OrdEnumHandler {
210210
} else {
211211
let discriminant_cmp = quote! {
212212
unsafe {
213-
::core::cmp::Ord::cmp(&*<*const _>::from(self).cast::<#discriminant_type>(), &*<*const _>::from(other).cast::<#discriminant_type>())
213+
::core::cmp::Ord::cmp(&*<*const Self>::from(self).cast::<#discriminant_type>(), &*<*const Self>::from(other).cast::<#discriminant_type>())
214214
}
215215
};
216216

src/trait_handlers/partial_ord/partial_ord_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl TraitHandler for PartialOrdEnumHandler {
215215
} else {
216216
let discriminant_cmp = quote! {
217217
unsafe {
218-
::core::cmp::Ord::cmp(&*<*const _>::from(self).cast::<#discriminant_type>(), &*<*const _>::from(other).cast::<#discriminant_type>())
218+
::core::cmp::Ord::cmp(&*<*const Self>::from(self).cast::<#discriminant_type>(), &*<*const Self>::from(other).cast::<#discriminant_type>())
219219
}
220220
};
221221

tests/ord_enum.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,3 +630,11 @@ fn use_partial_ord_attr_ignore() {
630630
assert_eq!(Ordering::Less, Enum::Tuple(1, 2).cmp(&Enum::Tuple(1, 3)));
631631
assert_eq!(Ordering::Equal, Enum::Tuple(2, 2).cmp(&Enum::Tuple(1, 2)));
632632
}
633+
634+
struct PoisonTypeInference;
635+
636+
impl From<&PoisonTypeInference> for *const () {
637+
fn from(value: &PoisonTypeInference) -> Self {
638+
value as *const PoisonTypeInference as *const ()
639+
}
640+
}

0 commit comments

Comments
 (0)