Skip to content

Commit 70319f5

Browse files
authored
Fix tests on nightly (#1999)
Ensure that `PartialOrd` and `Ord` implementations for `Alignment` are the same instead of having one be manual and one be derived. This is required to account for a small behavior change in nightly Rust.
1 parent f3c9567 commit 70319f5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/wit-parser/src/sizealign.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use std::{
2+
cmp::Ordering,
23
num::NonZeroUsize,
34
ops::{Add, AddAssign},
45
};
56

67
use crate::{FlagsRepr, Int, Resolve, Type, TypeDef, TypeDefKind};
78

89
/// Architecture specific alignment
9-
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
10+
#[derive(Eq, PartialEq, Clone, Copy)]
1011
pub enum Alignment {
1112
/// This represents 4 byte alignment on 32bit and 8 byte alignment on 64bit architectures
1213
Pointer,
@@ -29,11 +30,17 @@ impl std::fmt::Debug for Alignment {
2930
}
3031
}
3132

33+
impl PartialOrd for Alignment {
34+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
35+
Some(self.cmp(other))
36+
}
37+
}
38+
3239
impl Ord for Alignment {
3340
/// Needed for determining the max alignment of an object from its parts.
3441
/// The ordering is: Bytes(1) < Bytes(2) < Bytes(4) < Pointer < Bytes(8)
3542
/// as a Pointer is either four or eight byte aligned, depending on the architecture
36-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
43+
fn cmp(&self, other: &Self) -> Ordering {
3744
match (self, other) {
3845
(Alignment::Pointer, Alignment::Pointer) => std::cmp::Ordering::Equal,
3946
(Alignment::Pointer, Alignment::Bytes(b)) => {

0 commit comments

Comments
 (0)