2023-05-15 23:41:41 +00:00
|
|
|
//@run-rustfix
|
2023-05-15 21:50:28 +00:00
|
|
|
#![allow(unused)]
|
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
use std::cmp::Ordering;
|
|
|
|
|
|
|
|
// lint
|
|
|
|
|
|
|
|
#[derive(Eq, PartialEq)]
|
|
|
|
struct A(u32);
|
|
|
|
|
|
|
|
impl Ord for A {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for A {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// do not lint
|
|
|
|
|
|
|
|
#[derive(Eq, PartialEq)]
|
|
|
|
struct B(u32);
|
|
|
|
|
|
|
|
impl Ord for B {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for B {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 23:41:41 +00:00
|
|
|
// lint, but we can't give a suggestion since &Self is not named
|
2023-05-15 21:50:28 +00:00
|
|
|
|
|
|
|
#[derive(Eq, PartialEq)]
|
|
|
|
struct C(u32);
|
|
|
|
|
|
|
|
impl Ord for C {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for C {
|
|
|
|
fn partial_cmp(&self, _: &Self) -> Option<Ordering> {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-15 23:41:41 +00:00
|
|
|
// do not lint derived
|
|
|
|
|
|
|
|
#[derive(Eq, Ord, PartialEq, PartialOrd)]
|
|
|
|
struct D(u32);
|
|
|
|
|
|
|
|
// do not lint if ord is not manually implemented
|
|
|
|
|
|
|
|
#[derive(Eq, PartialEq)]
|
|
|
|
struct E(u32);
|
|
|
|
|
|
|
|
impl PartialOrd for E {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// do not lint since ord has more restrictive bounds
|
|
|
|
|
|
|
|
#[derive(Eq, PartialEq)]
|
|
|
|
struct Uwu<A>(A);
|
|
|
|
|
|
|
|
impl<A: std::fmt::Debug + Ord + PartialOrd> Ord for Uwu<A> {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<A: Ord + PartialOrd> PartialOrd for Uwu<A> {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
todo!();
|
|
|
|
}
|
|
|
|
}
|