From 5ab3bf858b3e60a7fc12c75f63743bd8a67375c1 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:37:58 +0000 Subject: [PATCH] Fix rust 1.60 clippy lints (#2014) This Pull Request fixes new / improved clippy lints with rust 1.60. --- boa_engine/src/builtins/array_buffer/mod.rs | 2 +- boa_engine/src/builtins/regexp/mod.rs | 8 ++++++-- boa_engine/src/value/display.rs | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/boa_engine/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs index 3f0524017d..b4d59d1f4b 100644 --- a/boa_engine/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -764,7 +764,7 @@ pub fn create_byte_data_block(size: usize, context: &mut Context) -> JsResult, + to_block: &mut [u8], mut to_index: usize, from_block: &[u8], mut from_index: usize, diff --git a/boa_engine/src/builtins/regexp/mod.rs b/boa_engine/src/builtins/regexp/mod.rs index b39d66a8a9..6bc784e0b4 100644 --- a/boa_engine/src/builtins/regexp/mod.rs +++ b/boa_engine/src/builtins/regexp/mod.rs @@ -1386,7 +1386,9 @@ impl RegExp { // the substring of S from nextSourcePosition to position, and replacement. accumulated_result = format!( "{accumulated_result}{}{replacement}", - arg_str.get(next_source_position..position).unwrap(), + arg_str + .get(next_source_position..position) + .expect("index of a regexp match cannot be greater than the input string"), ) .into(); @@ -1404,7 +1406,9 @@ impl RegExp { Ok(format!( "{}{}", accumulated_result, - arg_str.get(next_source_position..).unwrap() + arg_str + .get(next_source_position..) + .expect("next_source_position cannot be greater than the input string") ) .into()) } diff --git a/boa_engine/src/value/display.rs b/boa_engine/src/value/display.rs index 2e6d8855b7..1cee752262 100644 --- a/boa_engine/src/value/display.rs +++ b/boa_engine/src/value/display.rs @@ -117,8 +117,7 @@ pub(crate) fn log_string_from(x: &JsValue, print_internals: bool, print_children .borrow() .properties() .get(&PropertyKey::from("length")) - // TODO: do this in a better way `unwrap` - .unwrap() + .expect("array object must have 'length' property") // FIXME: handle accessor descriptors .expect_value() .as_number()