Shut up clippy.

This commit is contained in:
Stephen Chung
2022-08-27 16:26:41 +08:00
parent d80184ba14
commit bf5d6ab35a
28 changed files with 313 additions and 205 deletions

View File

@@ -700,16 +700,15 @@ pub fn get_builtin_op_assignment_fn(op: &str, x: &Dynamic, y: &Dynamic) -> Optio
}),
_ => None,
};
} else {
return match op {
"+=" => Some(|_, args| {
let x = std::mem::take(args[1]);
let array = &mut *args[0].write_lock::<Array>().expect(BUILTIN);
Ok(push(array, x).into())
}),
_ => None,
};
}
return match op {
"+=" => Some(|_, args| {
let x = std::mem::take(args[1]);
let array = &mut *args[0].write_lock::<Array>().expect(BUILTIN);
Ok(push(array, x).into())
}),
_ => None,
};
}
#[cfg(not(feature = "no_index"))]

View File

@@ -68,7 +68,7 @@ impl<'a> ArgBackup<'a> {
// Replace the first reference with a reference to the clone, force-casting the lifetime.
// Must remember to restore it later with `restore_first_arg`.
//
// # Safety
// SAFETY:
//
// Blindly casting a reference to another lifetime saves allocation and string cloning,
// but must be used with the utmost care.
@@ -608,7 +608,7 @@ impl Engine {
let num_params = args[1].as_int().expect("`INT`");
return Ok((
if num_params < 0 {
if num_params < 0 || num_params > crate::MAX_USIZE_INT {
false
} else {
let hash_script = calc_fn_hash(fn_name.as_str(), num_params as usize);
@@ -1100,7 +1100,7 @@ impl Engine {
.as_int()
.map_err(|typ| self.make_type_mismatch_err::<crate::INT>(typ, arg_pos))?;
return Ok(if num_params < 0 {
return Ok(if num_params < 0 || num_params > crate::MAX_USIZE_INT {
false
} else {
let hash_script = calc_fn_hash(&fn_name, num_params as usize);

View File

@@ -47,9 +47,7 @@ pub fn by_value<T: Variant + Clone>(data: &mut Dynamic) -> T {
// If T is `&str`, data must be `ImmutableString`, so map directly to it
data.flatten_in_place();
let ref_str = data.as_str_ref().expect("&str");
// # Safety
//
// We already checked that `T` is `&str`, so it is safe to cast here.
// SAFETY: We already checked that `T` is `&str`, so it is safe to cast here.
return unsafe { mem::transmute_copy::<_, T>(&ref_str) };
}
if TypeId::of::<T>() == TypeId::of::<String>() {