summaryrefslogtreecommitdiffstats
path: root/vendor/chalk-engine/src/derived.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/chalk-engine/src/derived.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/chalk-engine/src/derived.rs')
-rw-r--r--vendor/chalk-engine/src/derived.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/chalk-engine/src/derived.rs b/vendor/chalk-engine/src/derived.rs
new file mode 100644
index 000000000..b3cdc3d0d
--- /dev/null
+++ b/vendor/chalk-engine/src/derived.rs
@@ -0,0 +1,34 @@
+// These impls for PartialEq, Eq, etc are written by hand. This is
+// because the `#[derive()]` would add requirements onto the context
+// object that are not needed.
+
+use super::*;
+use std::cmp::{Eq, PartialEq};
+use std::hash::{Hash, Hasher};
+use std::mem;
+
+///////////////////////////////////////////////////////////////////////////
+
+impl<I: Interner> PartialEq for Literal<I> {
+ fn eq(&self, other: &Literal<I>) -> bool {
+ match (self, other) {
+ (Literal::Positive(goal1), Literal::Positive(goal2))
+ | (Literal::Negative(goal1), Literal::Negative(goal2)) => goal1 == goal2,
+
+ _ => false,
+ }
+ }
+}
+
+impl<I: Interner> Eq for Literal<I> {}
+
+impl<I: Interner> Hash for Literal<I> {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ mem::discriminant(self).hash(state);
+ match self {
+ Literal::Positive(goal) | Literal::Negative(goal) => {
+ goal.hash(state);
+ }
+ }
+ }
+}