Return a single diagnostic from lex_token_trees.

It currently returns a `Vec` but in practice it always has one
diagnostic in it.

LLM disclosure: Claude Code identified this when I asked it to review
`tokentrees.rs`. I made the change by hand and tested it myself.
This commit is contained in:
Nicholas Nethercote
2026-04-27 15:18:42 +10:00
parent f53b654a88
commit c9d0bdccb2
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ pub(crate) fn lex_token_trees<'psess, 'src>(
Err(errs) => {
// We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch
// because the delimiter mismatch is more likely to be the root cause of error
unmatched_closing_delims.extend(errs);
unmatched_closing_delims.push(errs);
Err(unmatched_closing_delims)
}
}
+4 -4
View File
@@ -14,7 +14,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
pub(super) fn lex_token_trees(
&mut self,
is_delimited: bool,
) -> Result<(Spacing, TokenStream), Vec<Diag<'psess>>> {
) -> Result<(Spacing, TokenStream), Diag<'psess>> {
// Move past the opening delimiter.
let open_spacing = self.bump_minimal();
@@ -35,11 +35,11 @@ pub(super) fn lex_token_trees(
return if is_delimited {
Ok((open_spacing, TokenStream::new(buf)))
} else {
Err(vec![self.close_delim_err(delim)])
Err(self.close_delim_err(delim))
};
} else if self.token.kind == token::Eof {
return if is_delimited {
Err(vec![self.eof_err()])
Err(self.eof_err())
} else {
Ok((open_spacing, TokenStream::new(buf)))
};
@@ -54,7 +54,7 @@ pub(super) fn lex_token_trees(
fn lex_token_tree_open_delim(
&mut self,
open_delim: Delimiter,
) -> Result<TokenTree, Vec<Diag<'psess>>> {
) -> Result<TokenTree, Diag<'psess>> {
// The span for beginning of the delimited section.
let pre_span = self.token.span;