From c9102e54bbd0950362c1f991c7bc3cf3cd9147a4 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 20 Oct 2024 12:13:42 -0400 Subject: [PATCH] refactor(rustfix): only compute snippets when needed --- crates/rustfix/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/rustfix/src/lib.rs b/crates/rustfix/src/lib.rs index a1e2c47cf..0283d1a93 100644 --- a/crates/rustfix/src/lib.rs +++ b/crates/rustfix/src/lib.rs @@ -167,8 +167,6 @@ pub fn collect_suggestions( } } - let snippets = diagnostic.spans.iter().map(span_to_snippet).collect(); - let solutions: Vec<_> = diagnostic .children .iter() @@ -204,7 +202,7 @@ pub fn collect_suggestions( } else { Some(Suggestion { message: diagnostic.message.clone(), - snippets, + snippets: diagnostic.spans.iter().map(span_to_snippet).collect(), solutions, }) }