creusot icon indicating copy to clipboard operation
creusot copied to clipboard

Deriving `PartialEq` is not supported for enums with more than one variant.

Open sarsko opened this issue 2 years ago • 2 comments

Deriving Eq works just fine, whereas deriving PartialEq gives the following error:

thread 'rustc' panicked at 'not implemented', creusot/src/translation/traits.rs:246:14

Example:

#[derive(PartialEq)]
enum Example {
    Example,
    Example2
}

Do note that this does not error

#[derive(PartialEq)]
enum Example {
    Example,
}

and that this does not error

#[derive(Eq)]
enum Example {
    Example,
    Example2
}

even though Eq requires PartialEq

sarsko avatar Oct 29 '21 21:10 sarsko

The crash is definitely a bug, but derived instances won't be very helpful for you in Creusot as you'd have no contract on their behavior.

xldenis avatar Oct 29 '21 21:10 xldenis

You're probably better off manually defining the instances :/ at least then you can add a contract.

xldenis avatar Oct 29 '21 21:10 xldenis

Should be supported now that we have a PartialEq derive.

xldenis avatar Sep 28 '23 09:09 xldenis