Skip to content

Remove Ord and PartialOrd from StorageSlot #2517

@PhilippGackstatter

Description

@PhilippGackstatter

We currently implement Ord for StorageSlot:

impl Ord for StorageSlot {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.name().cmp(&other.name)
}
}
impl PartialOrd for StorageSlot {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}

This is incorrect because Ord and Eq must agree, but Eq compares the slot content while Ord only compares the key. This was only implemented as a convenience to be able to easily sort a Vec<StorageSlot>. We should remove this and replace slot.sort_unstable with sort_unstable_by or sort_unstable_by_key to sort by the storage slot's name instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rustIssues that affect or pull requests that update Rust code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions