Add derive-key implementation for IsEq

This commit is contained in:
Ayaz Hafiz 2022-10-05 14:44:30 -05:00
parent 16d12a51c2
commit 4c30e4c4bb
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 13 additions and 0 deletions

View file

@ -76,6 +76,7 @@ pub enum DeriveBuiltin {
ToEncoder,
Decoder,
Hash,
IsEq,
}
impl TryFrom<Symbol> for DeriveBuiltin {
@ -86,6 +87,7 @@ impl TryFrom<Symbol> for DeriveBuiltin {
Symbol::ENCODE_TO_ENCODER => Ok(DeriveBuiltin::ToEncoder),
Symbol::DECODE_DECODER => Ok(DeriveBuiltin::Decoder),
Symbol::HASH_HASH => Ok(DeriveBuiltin::Hash),
Symbol::EQ_IS_EQ => Ok(DeriveBuiltin::IsEq),
_ => Err(value),
}
}
@ -112,6 +114,11 @@ impl Derived {
}
FlatHash::Key(repr) => Ok(Derived::Key(DeriveKey::Hash(repr))),
},
DeriveBuiltin::IsEq => {
// If obligation checking passes, we always lower derived implementations of `isEq`
// to the `Eq` low-level, to be fulfilled by the backends.
Ok(Derived::SingleLambdaSetImmediate(Symbol::BOOL_EQ))
}
}
}
}