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 }) } }