Debian Codegraph @

gcc/testsuite/rust/compile/derive-partialeq1.rs

raw
1 #![feature(intrinsics)]
2
3 #[lang = "sized"]
4 trait Sized {}
5
6 #[lang = "copy"]
7 trait Copy {}
8
9 #[lang = "structural_peq"]
10 trait StructuralPartialEq {}
11
12 #[lang = "eq"]
13 pub trait PartialEq<Rhs: ?Sized = Self> {
14 /// This method tests for `self` and `other` values to be equal, and is used
15 /// by `==`.
16 #[must_use]
17 #[stable(feature = "rust1", since = "1.0.0")]
18 fn eq(&self, other: &Rhs) -> bool;
19
20 /// This method tests for `!=`.
21 #[inline]
22 #[must_use]
23 #[stable(feature = "rust1", since = "1.0.0")]
24 fn ne(&self, other: &Rhs) -> bool {
25 !self.eq(other)
26 }
27 }
28
29 #[derive(PartialEq, Copy)] // { dg-warning "unused name" }
30 struct Foo;
31
32 #[derive(PartialEq)]
33 struct Bar(Foo);
34
35 #[derive(PartialEq)]
36 struct Baz { _inner: Foo }
37
38 extern "C" {
39 fn puts(s: *const i8);
40 }
41
42 fn print(b: bool) {
43 if b {
44 unsafe { puts("true" as *const str as *const i8) }
45 } else {
46 unsafe { puts("false" as *const str as *const i8) }
47 }
48 }
49
50 fn main() -> i32 {
51 let x = Foo;
52
53 let b1 = x == Foo;
54 let b2 = Bar(x) != Bar(Foo);
55 let b3 = Baz { _inner: Foo } != Baz { _inner: x };
56
57 print(b1);
58 print(b2);
59 print(b3);
60
61 0
62 }