Auto merge of #16748 - Veykril:on-demand-validation-err, r=Veykril

internal: Compute syntax validation errors on demand

The LRU cache causes us to re-parse trees quite often, yet we don't use the validation errors at all. With this we push calculating them off to the caller who is interested in them.
This commit is contained in:
bors 2024-03-04 11:19:16 +00:00
commit a7e9f12bf7
11 changed files with 45 additions and 44 deletions

View file

@ -299,7 +299,7 @@ pub fn diagnostics(
let mut res = Vec::new();
// [#34344] Only take first 128 errors to prevent slowing down editor/ide, the number 128 is chosen arbitrarily.
res.extend(parse.errors().iter().take(128).map(|err| {
res.extend(parse.errors().into_iter().take(128).map(|err| {
Diagnostic::new(
DiagnosticCode::RustcHardError("syntax-error"),
format!("Syntax Error: {err}"),