aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/issue-4090-1.rs
blob: 9f83835ee4a3f28cec8dba4ccf45e33f3114da8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
mod core {
    mod marker {
        #[lang = "sized"]
        pub trait Sized {}

        #[lang = "phantom_data"]
        #[stable(feature = "rust1", since = "1.0.0")]
        pub struct PhantomData<T: ?Sized>;

        #[unstable(feature = "structural_match", issue = "31434")]
        #[lang = "structural_teq"]
        pub trait StructuralEq {
            // Empty.
        }

        #[unstable(feature = "structural_match", issue = "31434")]
        #[lang = "structural_peq"]
        pub trait StructuralPartialEq {
            // Empty.
        }
    }

    pub mod cmp {
        use super::marker::Sized;

        #[lang = "eq"]
        pub trait PartialEq<Rhs: ?Sized = Self> {
            fn eq(&self, other: &Rhs) -> bool;

            fn ne(&self, other: &Rhs) -> bool {
                !self.eq(other)
            }
        }

        pub trait Eq: PartialEq<Self> {
            fn assert_receiver_is_total_eq(&self) {}
        }
    }

    pub mod ptr {

        use super::cmp::{Eq, PartialEq};

        macro_rules! fnptr_impls_safety_abi {
            ($FnTy: ty, $($Arg: ident),*) => {
                #[stable(feature = "fnptr_impls", since = "1.4.0")]
                impl<Ret, $($Arg),*> PartialEq for $FnTy {
                    #[inline]
                    fn eq(&self, other: &Self) -> bool {
                        *self as usize == *other as usize
                    }
                }

                #[stable(feature = "fnptr_impls", since = "1.4.0")]
                impl<Ret, $($Arg),*> Eq for $FnTy {}

            }
        }

        fnptr_impls_safety_abi! { extern "Rust" fn() -> Ret, }
    }
}

#[derive(PartialEq, Eq)]
struct AllowedBelow {
    // { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
    f: fn(),
}