Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #20977 from chirizxc/patch-1
Move safe computation out of unsafe block
Laurențiu Nicola 6 months ago
parent 5ffe3f4 · parent c9b5683 · commit 3668c75
-rw-r--r--crates/rust-analyzer/src/line_index.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/line_index.rs b/crates/rust-analyzer/src/line_index.rs
index 9517620740..a18d0747b2 100644
--- a/crates/rust-analyzer/src/line_index.rs
+++ b/crates/rust-analyzer/src/line_index.rs
@@ -62,8 +62,8 @@ impl LineEndings {
// Account for removed `\r`.
// After `set_len`, `buf` is guaranteed to contain utf-8 again.
+ let new_len = buf.len() - gap_len;
let src = unsafe {
- let new_len = buf.len() - gap_len;
buf.set_len(new_len);
String::from_utf8_unchecked(buf)
};