|
| 1 | +mod core { |
| 2 | + mod marker { |
| 3 | + #[lang = "sized"] |
| 4 | + pub trait Sized {} |
| 5 | + |
| 6 | + #[lang = "phantom_data"] |
| 7 | + #[stable(feature = "rust1", since = "1.0.0")] |
| 8 | + pub struct PhantomData<T: ?Sized>; |
| 9 | + |
| 10 | + #[unstable(feature = "structural_match", issue = "31434")] |
| 11 | + #[lang = "structural_teq"] |
| 12 | + pub trait StructuralEq { |
| 13 | + // Empty. |
| 14 | + } |
| 15 | + |
| 16 | + #[unstable(feature = "structural_match", issue = "31434")] |
| 17 | + #[lang = "structural_peq"] |
| 18 | + pub trait StructuralPartialEq { |
| 19 | + // Empty. |
| 20 | + } |
| 21 | + } |
| 22 | + |
| 23 | + pub mod cmp { |
| 24 | + use super::marker::Sized; |
| 25 | + |
| 26 | + #[lang = "eq"] |
| 27 | + pub trait PartialEq<Rhs: ?Sized = Self> { |
| 28 | + fn eq(&self, other: &Rhs) -> bool; |
| 29 | + |
| 30 | + fn ne(&self, other: &Rhs) -> bool { |
| 31 | + !self.eq(other) |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + pub trait Eq: PartialEq<Self> { |
| 36 | + fn assert_receiver_is_total_eq(&self) {} |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + pub mod ptr { |
| 41 | + |
| 42 | + use super::cmp::{Eq, PartialEq}; |
| 43 | + |
| 44 | + macro_rules! fnptr_impls_safety_abi { |
| 45 | + ($FnTy: ty, $($Arg: ident),*) => { |
| 46 | + #[stable(feature = "fnptr_impls", since = "1.4.0")] |
| 47 | + impl<Ret, $($Arg),*> PartialEq for $FnTy { |
| 48 | + #[inline] |
| 49 | + fn eq(&self, other: &Self) -> bool { |
| 50 | + *self as usize == *other as usize |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + #[stable(feature = "fnptr_impls", since = "1.4.0")] |
| 55 | + impl<Ret, $($Arg),*> Eq for $FnTy {} |
| 56 | + |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + fnptr_impls_safety_abi! { extern "Rust" fn() -> Ret, } |
| 61 | + fnptr_impls_safety_abi! { extern "C" fn() -> Ret, } |
| 62 | + fnptr_impls_safety_abi! { unsafe extern "Rust" fn() -> Ret, } |
| 63 | + fnptr_impls_safety_abi! { unsafe extern "C" fn() -> Ret, } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +#[derive(PartialEq, Eq)] |
| 68 | +struct AllowedBelow { |
| 69 | + // { dg-warning "struct is never constructed" "" { target *-*-* } .-1 } |
| 70 | + f: fn(), |
| 71 | +} |
0 commit comments