Skip to content

Commit 3668c75

Browse files
authored
Merge pull request #20977 from chirizxc/patch-1
Move safe computation out of unsafe block
2 parents 5ffe3f4 + c9b5683 commit 3668c75

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/rust-analyzer/src/line_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ impl LineEndings {
6262

6363
// Account for removed `\r`.
6464
// After `set_len`, `buf` is guaranteed to contain utf-8 again.
65+
let new_len = buf.len() - gap_len;
6566
let src = unsafe {
66-
let new_len = buf.len() - gap_len;
6767
buf.set_len(new_len);
6868
String::from_utf8_unchecked(buf)
6969
};

0 commit comments

Comments
 (0)