From 8399983fd45bc0f11eac9def280c0833ffb93c04 Mon Sep 17 00:00:00 2001 From: Mica White Date: Sun, 12 Jul 2026 19:49:14 -0400 Subject: initial commit --- src/diagnostics/too_many_equal_signs.rs | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/diagnostics/too_many_equal_signs.rs (limited to 'src/diagnostics/too_many_equal_signs.rs') diff --git a/src/diagnostics/too_many_equal_signs.rs b/src/diagnostics/too_many_equal_signs.rs new file mode 100644 index 0000000..b20cb83 --- /dev/null +++ b/src/diagnostics/too_many_equal_signs.rs @@ -0,0 +1,35 @@ +use miette::Diagnostic; +use thiserror::Error; + +use crate::{diagnostics::AstDiagnostic, parse::Attribute, tokenize::Span}; + +#[derive(Error, Debug, Diagnostic)] +#[error("Multiple equal signs in a row")] +#[diagnostic(code(TooManyEqualSigns), severity(Error))] +pub struct TooManyEqualSigns { + #[label(primary, "only one equal sign should be present")] + token: Span, +} + +impl AstDiagnostic for TooManyEqualSigns { + fn handle_attribute(attribute: &crate::parse::Attribute<'_>) -> Option { + let Attribute::NamedArgumentWithTooManyEqualSigns { equal_signs, .. } = attribute else { + return None; + }; + + Some(Self { + token: Span { + start: equal_signs + .first() + .expect("at least two equal signs") + .span + .start, + end: equal_signs + .last() + .expect("at least two equal signs") + .span + .end, + }, + }) + } +} -- cgit v1.2.3