Skip to content

Commit 64f6437

Browse files
committed
Convert Eq impl to check Ord::Equal
1 parent be0d6f1 commit 64f6437

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/librustc_ast/ast.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub type GenericBounds = Vec<GenericBound>;
310310
/// Specifies the enforced ordering for generic parameters. In the future,
311311
/// if we wanted to relax this order, we could override `PartialEq` and
312312
/// `PartialOrd`, to allow the kinds to be unordered.
313-
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
313+
#[derive(Hash, Clone, Copy)]
314314
pub enum ParamKindOrd {
315315
Lifetime,
316316
Type,
@@ -340,6 +340,12 @@ impl PartialOrd for ParamKindOrd {
340340
Some(self.cmp(other))
341341
}
342342
}
343+
impl PartialEq for ParamKindOrd {
344+
fn eq(&self, other: &Self) -> bool {
345+
self.cmp(other) == Ordering::Equal
346+
}
347+
}
348+
impl Eq for ParamKindOrd {}
343349

344350
impl fmt::Display for ParamKindOrd {
345351
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

src/test/ui/const-generics/argument_order.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
1111
| ^^^^^^^
1212
|
1313
= note: lifetime arguments must be provided before type arguments
14-
= help: reorder the arguments: lifetimes, then consts, then types, then consts, then types: `<'a, 'b, N, T, M, U>`
14+
= help: reorder the arguments: lifetimes, then consts: `<'a, 'b, N, T, M, U>`
1515

1616
error: aborting due to 2 previous errors
1717

0 commit comments

Comments
 (0)