(spans: &[SpanId])
| 145 | `[item1, item2]` instead of `[item1, item2,]`"; |
| 146 | |
| 147 | pub(crate) fn trailing_commas(spans: &[SpanId]) -> ArrayDiagnostic { |
| 148 | let (&first, rest) = spans.split_first().expect("spans must be non-empty"); |
| 149 | |
| 150 | let mut diagnostic = Diagnostic::new(ArrayDiagnosticCategory::TrailingComma, Critical::ERROR) |
| 151 | .primary(Label::new(first, "Remove this trailing comma")); |
| 152 | |
| 153 | for &span in rest { |
| 154 | diagnostic |
| 155 | .labels |
| 156 | .push(Label::new(span, "... and this trailing comma")); |
| 157 | } |
| 158 | |
| 159 | diagnostic.add_message(Message::help(TRAILING_COMMA_HELP)); |
| 160 | |
| 161 | diagnostic |
| 162 | } |
| 163 | |
| 164 | const LEADING_COMMA_HELP: &str = |
| 165 | "J-Expr does not support leading commas in arrays. Use `[item1, item2]` format."; |
no test coverage detected