From efc7f9513ee3901f3e9735f6d191140d16f6affd Mon Sep 17 00:00:00 2001 From: alexion Date: Fri, 18 Sep 2026 22:33:56 -0400 Subject: [PATCH] style(xatu): format source ranges --- src/xatu/ast.rs | 6 ++++++ src/xatu/rules.rs | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/xatu/ast.rs b/src/xatu/ast.rs index 5629ef5..3e22150 100644 --- a/src/xatu/ast.rs +++ b/src/xatu/ast.rs @@ -16,6 +16,12 @@ pub struct SourceRange { pub end: usize, } +impl std::fmt::Display for SourceRange { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "{}..{}", self.start, self.end) + } +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct Node { pub range: SourceRange, diff --git a/src/xatu/rules.rs b/src/xatu/rules.rs index dff3ac9..28edf39 100644 --- a/src/xatu/rules.rs +++ b/src/xatu/rules.rs @@ -19,12 +19,11 @@ pub struct Diagnostic { impl std::fmt::Display for Diagnostic { fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let start = self.finding.range.start; - let end = self.finding.range.end; - let rule_id = self.finding.rule_id; - let message = self.finding.message; - - write!(formatter, "{start}..{end}: {rule_id}: {message}") + write!( + formatter, + "{}: {}: {}", + self.finding.range, self.finding.rule_id, self.finding.message, + ) } }