diff --git a/cli/generate/src/render.rs b/cli/generate/src/render.rs index 87447fd3..09685526 100644 --- a/cli/generate/src/render.rs +++ b/cli/generate/src/render.rs @@ -873,7 +873,7 @@ impl Generator { && chars.ranges().all(|r| { let start = *r.start() as u32; let end = *r.end() as u32; - end <= start + 1 && end <= u16::MAX as u32 + end <= start + 1 && u16::try_from(end).is_ok() }) { leading_simple_transition_count += 1; diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index bf12896b..6827ba78 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -2203,7 +2203,7 @@ impl<'cursor> TreeCursor<'cursor> { pub fn goto_first_child_for_byte(&mut self, index: usize) -> Option { let result = unsafe { ffi::ts_tree_cursor_goto_first_child_for_byte(&mut self.0, index as u32) }; - (result >= 0).then_some(result as usize) + result.try_into().ok() } /// Move this cursor to the first child of its current node that contains or @@ -2215,7 +2215,7 @@ impl<'cursor> TreeCursor<'cursor> { pub fn goto_first_child_for_point(&mut self, point: Point) -> Option { let result = unsafe { ffi::ts_tree_cursor_goto_first_child_for_point(&mut self.0, point.into()) }; - (result >= 0).then_some(result as usize) + result.try_into().ok() } /// Re-initialize this tree cursor to start at the original node that the diff --git a/xtask/src/bump.rs b/xtask/src/bump.rs index ba54eede..cd7dc7eb 100644 --- a/xtask/src/bump.rs +++ b/xtask/src/bump.rs @@ -205,7 +205,7 @@ fn update_cmake(next_version: &Version) -> Result<()> { let end_quote = line.rfind('"').unwrap(); format!( "{}{next_version}{}", - &line[..start_quote + 1], + &line[..=start_quote], &line[end_quote..] ) } else { diff --git a/xtask/src/check_wasm_exports.rs b/xtask/src/check_wasm_exports.rs index 50cd3af6..ffa92779 100644 --- a/xtask/src/check_wasm_exports.rs +++ b/xtask/src/check_wasm_exports.rs @@ -120,7 +120,7 @@ fn check_wasm_exports() -> Result<()> { let mut missing = exports .iter() .filter(|&symbol| !wasm_exports.contains(symbol)) - .map(|symbol| symbol.as_str()) + .map(String::as_str) .collect::>(); missing.sort_unstable();