Debian Codegraph @

gcc/testsuite/rust/execute/torture/derive-partialeq1.rs

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