Stop using DiagnosticBuilder::buffer in the parser.

One consequence is that errors returned by
`maybe_new_parser_from_source_str` now must be consumed, so a bunch of
places that previously ignored those errors now cancel them. (Most of
them explicitly dropped the errors before. I guess that was to indicate
"we are explicitly ignoring these", though I'm not 100% sure.)
This commit is contained in:
Nicholas Nethercote 2024-01-11 14:22:44 +11:00
parent d02150fd45
commit 6656413a5c
8 changed files with 39 additions and 32 deletions

View file

@ -69,8 +69,8 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String
let mut parser =
match rustc_parse::maybe_new_parser_from_source_str(&sess, file_name, snippet.clone()) {
Ok(parser) => parser,
Err(diagnostics) => {
drop(diagnostics);
Err(errs) => {
errs.into_iter().for_each(|err| err.cancel());
return None;
}
};