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/stray_equal_sign.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/diagnostics/stray_equal_sign.rs (limited to 'src/diagnostics/stray_equal_sign.rs') diff --git a/src/diagnostics/stray_equal_sign.rs b/src/diagnostics/stray_equal_sign.rs new file mode 100644 index 0000000..29674da --- /dev/null +++ b/src/diagnostics/stray_equal_sign.rs @@ -0,0 +1,22 @@ +use miette::Diagnostic; +use thiserror::Error; + +use crate::{diagnostics::AstDiagnostic, parse::Attribute, tokenize::Span}; + +#[derive(Error, Debug, Diagnostic)] +#[error("Stray equal sign found not attached to any attributes")] +#[diagnostic(code(StrayEqualSign), severity(Error))] +pub struct StrayEqualSign { + #[label(primary, "An equal sign is not a valid attribute")] + token: Span, +} + +impl AstDiagnostic for StrayEqualSign { + fn handle_attribute(attribute: &crate::parse::Attribute<'_>) -> Option { + let Attribute::StrayEqualSign(token) = attribute else { + return None; + }; + + Some(Self { token: token.span }) + } +} -- cgit v1.2.3