refactor: enable clippy::similar_names lint

This commit is contained in:
Benoît CORTIER
2024-11-20 01:28:31 +09:00
committed by Benoît Cortier
parent 7c7ca4dbd1
commit d26e64e4c2
6 changed files with 15 additions and 3 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ trait_duplication_in_bounds = "warn"
type_repetition_in_bounds = "warn"
checked_conversions = "warn"
get_unwrap = "warn"
# TODO: similar_names = "warn" # Reduce risk of confusing similar names together, and protects against typos when variable shadowing was intended.
similar_names = "warn" # Reduce risk of confusing similar names together, and protects against typos when variable shadowing was intended.
str_to_string = "warn"
string_to_string = "warn"
# TODO: std_instead_of_alloc = "warn"
+2 -2
View File
@@ -77,8 +77,8 @@ pub fn encode_dvc_messages(
while off < total_length {
let first = off == 0;
let rem = total_length.checked_sub(off).unwrap();
let size = core::cmp::min(rem, DrdynvcDataPdu::MAX_DATA_SIZE);
let remaining_length = total_length.checked_sub(off).unwrap();
let size = core::cmp::min(remaining_length, DrdynvcDataPdu::MAX_DATA_SIZE);
let end = off
.checked_add(size)
.ok_or_else(|| other_err!("encode_dvc_messages", "overflow occurred"))?;
@@ -231,6 +231,8 @@ pub struct Rgb {
impl From<YCbCr> for Rgb {
fn from(YCbCr { y, cb, cr }: YCbCr) -> Self {
#![allow(clippy::similar_names)] // Its hard to find better names here.
// We scale the factors by << 16 into 32-bit integers in order to
// avoid slower floating point multiplications. Since the final
// result needs to be scaled by >> 5 we will extract only the
@@ -259,6 +261,8 @@ impl From<YCbCr> for Rgb {
impl From<Rgb> for YCbCr {
fn from(Rgb { r, g, b }: Rgb) -> Self {
#![allow(clippy::similar_names)] // Its hard to find better names here.
// We scale the factors by << 15 into 32-bit integers in order
// to avoid slower floating point multiplications. Since the
// terms need to be scaled by << 5 we simply scale the final
@@ -163,6 +163,7 @@ impl<'a> BitmapStreamDecoderImpl<'a> {
}
fn write_aycocg_planes_to_rgb24(&self, params: AYCoCgParams, planes: &[u8], dst: &mut Vec<u8>) {
#![allow(clippy::similar_names)] // Its hard to find better names for co, cg, etc.
let sample_shift = params.chroma_subsampling as usize;
let (y_offset, co_offset, cg_offset) = (
@@ -225,6 +226,8 @@ impl<'a> BitmapStreamDecoderImpl<'a> {
/// Perform YCoCg -> RGB conversion with color loss reduction (CLL) correction.
fn ycocg_with_cll_to_rgb(cll: u8, y: u8, co: u8, cg: u8) -> Rgb {
#![allow(clippy::similar_names)] // Its hard to find better names for co, cg, etc.
// We decrease CLL by 1 to skip division by 2 for co & cg components during computation of
// the following color conversion matrix:
// |R| |1 1/2 -1/2| |Y |
@@ -488,6 +488,8 @@ impl PduBufferParsing<'_> for Quant {
type Error = RfxError;
fn from_buffer_consume(buffer: &mut &[u8]) -> Result<Self, Self::Error> {
#![allow(clippy::similar_names)] // Its hard to do better than ll3, lh3, etc without going overly verbose.
let level3 = buffer.read_u16::<LittleEndian>()?;
let ll3 = level3.get_bits(0..4) as u8;
let lh3 = level3.get_bits(4..8) as u8;
@@ -565,6 +567,8 @@ impl<'a> PduBufferParsing<'a> for Tile<'a> {
type Error = RfxError;
fn from_buffer_consume(buffer: &mut &'a [u8]) -> Result<Self, Self::Error> {
#![allow(clippy::similar_names)] // Its hard to find better names for cr, cb, etc.
let header = BlockHeader::from_buffer_consume_with_expected_type(buffer, BlockType::Tile)?;
let mut buffer = buffer.split_to(header.data_length);
+1
View File
@@ -23,6 +23,7 @@ impl RfxEncoder {
}
// FIXME: rewrite to use WriteCursor
#[allow(clippy::similar_names)] // Its hard to find better names for cr, cb, etc.
pub(crate) fn encode(&mut self, bitmap: &BitmapUpdate) -> EncodeResult<Vec<u8>> {
let width = bitmap.width.get();
let height = bitmap.height.get();