Skip to content

Commit 89b878f

Browse files
gagboGerry Agbobada
authored andcommitted
This is redone by using `saturating_add_signed` instead of having an extra helper function. The function is stable since Rust 1.66
1 parent be60482 commit 89b878f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/parinfer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::std;
22
use std::collections::HashMap;
33
use std::borrow::Cow;
4+
use std::convert::TryInto;
45
use unicode_segmentation::UnicodeSegmentation;
56
use unicode_width::UnicodeWidthStr;
67
use types::*;
@@ -1556,7 +1557,7 @@ fn finish_new_paren_trail<'a>(result: &mut State<'a>) {
15561557

15571558
fn add_indent<'a>(result: &mut State<'a>, delta: Delta) {
15581559
let orig_indent = result.x;
1559-
let new_indent = (orig_indent as Delta + delta) as Column;
1560+
let new_indent = orig_indent.saturating_add_signed(delta.try_into().expect("Delta (i64) has values that fit in a usize"));
15601561
let indent_str = repeat_string(BLANK_SPACE, new_indent);
15611562
let line_no = result.line_no;
15621563
replace_within_line(result, line_no, 0, orig_indent, &indent_str);

0 commit comments

Comments
 (0)