clippy: Fix assorted warnings in components/ (#31628)

* clippy: fix assorted warnings in `components/`

* fix: new and default

* fix: review comments
This commit is contained in:
eri 2024-03-13 09:31:58 +01:00 committed by GitHub
parent 0fda14263a
commit 03d64d0675
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 87 additions and 98 deletions

View file

@ -114,6 +114,7 @@ pub trait GenericPathBuilder {
control_point3: &Point2D<f32>,
);
fn close(&mut self);
#[allow(clippy::too_many_arguments)]
fn ellipse(
&mut self,
origin: Point2D<f32>,
@ -195,6 +196,7 @@ impl<'a> PathBuilderRef<'a> {
.arc(center, radius, start_angle, end_angle, ccw);
}
#[allow(clippy::too_many_arguments)]
pub fn ellipse(
&mut self,
center: &Point2D<f32>,
@ -978,6 +980,7 @@ impl<'a> CanvasData<'a> {
}
}
#[allow(clippy::too_many_arguments)]
pub fn ellipse(
&mut self,
center: &Point2D<f32>,

View file

@ -670,7 +670,7 @@ impl GenericDrawTarget for raqote::DrawTarget {
}
impl Filter {
fn to_raqote(&self) -> raqote::FilterMode {
fn to_raqote(self) -> raqote::FilterMode {
match self {
Filter::Bilinear => raqote::FilterMode::Bilinear,
Filter::Nearest => raqote::FilterMode::Nearest,
@ -847,7 +847,7 @@ pub trait ToRaqotePattern<'a> {
}
pub trait ToRaqoteGradientStop {
fn to_raqote(&self) -> raqote::GradientStop;
fn to_raqote(self) -> raqote::GradientStop;
}
/// Clamp a 0..1 number to a 0..255 range to u8.
@ -878,7 +878,7 @@ pub fn clamp_floor_256_f32(val: f32) -> u8 {
}
impl ToRaqoteGradientStop for CanvasGradientStop {
fn to_raqote(&self) -> raqote::GradientStop {
fn to_raqote(self) -> raqote::GradientStop {
let color = raqote::Color::new(
self.color.alpha.map(clamp_unit_f32).unwrap_or(0),
self.color.red.unwrap_or(0),
@ -890,7 +890,7 @@ impl ToRaqoteGradientStop for CanvasGradientStop {
}
}
impl<'a> ToRaqotePattern<'_> for FillOrStrokeStyle {
impl ToRaqotePattern<'_> for FillOrStrokeStyle {
#[allow(unsafe_code)]
fn to_raqote_pattern(self) -> Option<Pattern<'static>> {
use canvas_traits::canvas::FillOrStrokeStyle::*;

View file

@ -2514,8 +2514,8 @@ fn to_name_in_compiled_shader(s: &str) -> String {
fn from_name_in_compiled_shader(s: &str) -> String {
map_dot_separated(s, |s, mapped| {
mapped.push_str(if s.starts_with(ANGLE_NAME_PREFIX) {
&s[ANGLE_NAME_PREFIX.len()..]
mapped.push_str(if let Some(stripped) = s.strip_prefix(ANGLE_NAME_PREFIX) {
stripped
} else {
s
})
@ -2533,6 +2533,7 @@ fn map_dot_separated<F: Fn(&str, &mut String)>(s: &str, f: F) -> String {
mapped
}
#[allow(clippy::too_many_arguments)]
fn prepare_pixels(
internal_format: TexFormat,
data_type: TexDataType,
@ -3100,7 +3101,8 @@ impl WebXRBridge {
contexts: &mut dyn WebXRContexts<WebXRSurfman>,
context_id: WebXRContextId,
) {
for (_, manager) in &mut self.managers {
for manager in self.managers.values_mut() {
#[allow(clippy::unnecessary_to_owned)] // Needs mutable borrow later in destroy
for (other_id, layer_id) in manager.layers().to_vec() {
if other_id == context_id {
manager.destroy_layer(device, contexts, context_id, layer_id);