lisette_diagnostics/
attribute.rs1use crate::LisetteDiagnostic;
2use syntax::ast::Span;
3
4pub fn field_attribute_without_struct_attribute(
5 field_span: &Span,
6 attribute_name: &str,
7) -> LisetteDiagnostic {
8 LisetteDiagnostic::error("Orphan field attribute")
9 .with_attribute_code("orphan_field_attribute")
10 .with_span_label(field_span, "field has attribute but struct does not")
11 .with_help(format!(
12 "Add `#[{}]` atop the struct definition to enable field-level attributes",
13 attribute_name
14 ))
15}
16
17pub fn duplicate_tag_key(span: &Span, key: &str, first_span: &Span) -> LisetteDiagnostic {
18 LisetteDiagnostic::error("Duplicate tag")
19 .with_attribute_code("duplicate_tag")
20 .with_span_label(span, "duplicate")
21 .with_span_label(first_span, "first occurrence")
22 .with_help(format!(
23 "Remove one of the `{}` attributes - each tag key may appear only once per field",
24 key
25 ))
26}
27
28pub fn conflicting_case_transforms(span: &Span) -> LisetteDiagnostic {
29 LisetteDiagnostic::error("Conflicting case transforms")
30 .with_attribute_code("conflicting_case_transforms")
31 .with_span_label(span, "conflicting")
32 .with_help("Choose either `snake_case` or `camel_case`, not both")
33}