From 5c33fc70656757e6d61560da3edc4e4135cb6fff Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:39:47 +0000 Subject: [PATCH] refactor(diagnostics): implement `Eq` and `Ord` for `InfoPosition` (#12505) Implement these traits to shorten code elsewhere. --- apps/oxlint/src/output_formatter/default.rs | 10 +--------- crates/oxc_diagnostics/src/reporter.rs | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/oxlint/src/output_formatter/default.rs b/apps/oxlint/src/output_formatter/default.rs index e3fbc62ed2e62..79cae15a6b553 100644 --- a/apps/oxlint/src/output_formatter/default.rs +++ b/apps/oxlint/src/output_formatter/default.rs @@ -134,15 +134,7 @@ mod test_implementation { self.diagnostics.sort_by_cached_key(|diagnostic| { let info = Info::new(diagnostic); - ( - info.filename, - info.start.line, - info.start.column, - info.end.line, - info.end.column, - info.rule_id, - info.message, - ) + (info.filename, info.start, info.end, info.rule_id, info.message) }); for diagnostic in &self.diagnostics { diff --git a/crates/oxc_diagnostics/src/reporter.rs b/crates/oxc_diagnostics/src/reporter.rs index 9759f9eb0fee1..8d45503a7255e 100644 --- a/crates/oxc_diagnostics/src/reporter.rs +++ b/crates/oxc_diagnostics/src/reporter.rs @@ -101,7 +101,7 @@ pub struct Info { pub rule_id: Option, } -#[derive(Debug)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)] pub struct InfoPosition { pub line: usize, pub column: usize,