Skip to content

cmp::max changed behavior in nightly #64710

Closed
@emilio

Description

@emilio

This program (playground) changed behavior between 97e58c0...1dd1884.

And broke bindgen as a result in funny ways.

use std::cmp;

#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord)]
pub enum SizednessResult {
    NonZeroSized,
    DependsOnTypeParam,
    ZeroSized,
}

impl cmp::PartialOrd for SizednessResult {
    fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> {
        use self::SizednessResult::*;

        match (*self, *rhs) {
            (x, y) if x == y => Some(cmp::Ordering::Equal),
            (NonZeroSized, _) => Some(cmp::Ordering::Greater),
            (_, NonZeroSized) => Some(cmp::Ordering::Less),
            (DependsOnTypeParam, _) => Some(cmp::Ordering::Greater),
            (_, DependsOnTypeParam) => Some(cmp::Ordering::Less),
            _ => unreachable!(),
        }
    }
}

fn main() {
    println!("{:?}", cmp::max(SizednessResult::ZeroSized, SizednessResult::NonZeroSized))
}

I suspect #64047.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions