From 68b61c9832b59e9084bcc72c6e8e3d24e5be8bab Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Thu, 21 Mar 2024 15:41:26 -0500 Subject: [PATCH] Fix new lints from rust 1.77 (#1845) --- src/wasm-lib/kcl/src/ast/types.rs | 8 ++------ src/wasm-lib/kcl/src/lsp/copilot/cache.rs | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/wasm-lib/kcl/src/ast/types.rs b/src/wasm-lib/kcl/src/ast/types.rs index ab883e2be..af749152c 100644 --- a/src/wasm-lib/kcl/src/ast/types.rs +++ b/src/wasm-lib/kcl/src/ast/types.rs @@ -159,9 +159,7 @@ impl Program { /// Returns a value that includes the given character position. /// This is a bit more recursive than `get_body_item_for_position`. pub fn get_value_for_position(&self, pos: usize) -> Option<&Value> { - let Some(item) = self.get_body_item_for_position(pos) else { - return None; - }; + let item = self.get_body_item_for_position(pos)?; // Recurse over the item. match item { @@ -177,9 +175,7 @@ impl Program { if self.non_code_meta.contains(pos) { return Some(&self.non_code_meta); } - let Some(item) = self.get_body_item_for_position(pos) else { - return None; - }; + let item = self.get_body_item_for_position(pos)?; // Recurse over the item. let value = match item { diff --git a/src/wasm-lib/kcl/src/lsp/copilot/cache.rs b/src/wasm-lib/kcl/src/lsp/copilot/cache.rs index ad7fce8dd..ce5b5a413 100644 --- a/src/wasm-lib/kcl/src/lsp/copilot/cache.rs +++ b/src/wasm-lib/kcl/src/lsp/copilot/cache.rs @@ -77,9 +77,7 @@ impl CopilotCache { } pub fn get_cached_result(&self, uri: &String, last_line: u32) -> Option { - let Some(cached_line) = self.get_last_line(uri) else { - return None; - }; + let cached_line = self.get_last_line(uri)?; if last_line != cached_line { return None; };