(spans: &[SpanId])
| 165 | "J-Expr does not support leading commas in arrays. Use `[item1, item2]` format."; |
| 166 | |
| 167 | pub(crate) fn leading_commas(spans: &[SpanId]) -> ArrayDiagnostic { |
| 168 | let (&first, rest) = spans.split_first().expect("spans must be non-empty"); |
| 169 | |
| 170 | let mut diagnostic = Diagnostic::new(ArrayDiagnosticCategory::LeadingComma, Critical::ERROR) |
| 171 | .primary(Label::new(first, "Remove this leading comma")); |
| 172 | |
| 173 | for &span in rest { |
| 174 | diagnostic |
| 175 | .labels |
| 176 | .push(Label::new(span, "... and this leading comma")); |
| 177 | } |
| 178 | |
| 179 | diagnostic.add_message(Message::help(LEADING_COMMA_HELP)); |
| 180 | |
| 181 | diagnostic |
| 182 | } |
| 183 | |
| 184 | const CONSECUTIVE_COMMA_HELP: &str = |
| 185 | "J-Expr requires exactly one comma between array elements. Use `[item1, item2, item3]` format."; |
no test coverage detected