clippy: Fix last few warnings (#32270)

* Fix clippy in components/script

warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do (components/script/dom/htmlformelement.rs:896:20)

warning: `Box::new(_)` of default value (components/script/dom/paintworkletglobalscope.rs:291:29)

warning: this creates an owned instance just for comparison (components/script/dom/radionodelist.rs:105:50)

* Fix clippy in layout_thread (2013 and 2020)

warning: this `if` statement can be collapsed (components/layout_thread/lib.rs:876:17)

warning: the following explicit lifetimes could be elided: 'a (components/layout_thread/lib.rs:239 and 2020 same line)

warning: deref which would be done by auto-deref (components/layout_thread/lib.rs:500 and 1289)

warning: dereferencing a tuple pattern where every element takes a reference (components/layout_thread/lib.rs:503,1562 and 2020 line 1153)

warning: useless conversion to the same type: `style::invalidation::element::restyle_hints::RestyleHint` (components/layout_thread_2020/lib.rs:742:36)

* Fix clippy in components/servo

warning: constants have by default a `'static` lifetime (components/servo/lib.rs:1238:31)

warning: creating a `let` binding to a value of unit type, which usually
can't be used afterwards (5 occurances in components/servo/lib.rs)

* FIx clippy in ports/servoshell

warning: this expression creates a reference which is immediately dereferenced by the compiler (ports/servoshell/app.rs:251:89)

warning: using `clone` on type `Option<TopLevelBrowsingContextId>` which implements the `Copy` trait (ports/servoshell/webview.rs:122:9)
This commit is contained in:
Pi-Cla 2024-05-12 08:43:08 +00:00 committed by GitHub
parent 1f6d358cf9
commit 3d4fd0e550
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 49 additions and 55 deletions

View file

@ -1059,8 +1059,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
flags: FontInstanceFlags,
) -> FontInstanceKey {
let (sender, receiver) = unbounded();
let _ = self
.0
self.0
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
FontToCompositorMsg::AddFontInstance(font_key, size, flags, sender),
)));
@ -1070,8 +1069,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
let (sender, receiver) = unbounded();
let (bytes_sender, bytes_receiver) =
ipc::bytes_channel().expect("failed to create IPC channel");
let _ = self
.0
self.0
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
FontToCompositorMsg::AddFont(sender, index, bytes_receiver),
)));
@ -1081,8 +1079,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
fn add_system_font(&self, handle: NativeFontHandle) -> FontKey {
let (sender, receiver) = unbounded();
let _ = self
.0
self.0
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
FontToCompositorMsg::AddSystemFont(sender, handle),
)));
@ -1096,16 +1093,14 @@ struct CanvasWebrenderApi(CompositorProxy);
impl canvas_paint_thread::WebrenderApi for CanvasWebrenderApi {
fn generate_key(&self) -> Option<ImageKey> {
let (sender, receiver) = unbounded();
let _ = self
.0
self.0
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Canvas(
CanvasToCompositorMsg::GenerateKey(sender),
)));
receiver.recv().ok()
}
fn update_images(&self, updates: Vec<canvas_paint_thread::ImageUpdate>) {
let _ = self
.0
self.0
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Canvas(
CanvasToCompositorMsg::UpdateImages(updates),
)));
@ -1235,29 +1230,29 @@ enum UserAgent {
fn default_user_agent_string_for(agent: UserAgent) -> &'static str {
#[cfg(all(target_os = "linux", target_arch = "x86_64", not(target_env = "ohos")))]
const DESKTOP_UA_STRING: &'static str =
const DESKTOP_UA_STRING: &str =
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Servo/1.0 Firefox/111.0";
#[cfg(all(
target_os = "linux",
not(target_arch = "x86_64"),
not(target_env = "ohos")
))]
const DESKTOP_UA_STRING: &'static str =
const DESKTOP_UA_STRING: &str =
"Mozilla/5.0 (X11; Linux i686; rv:109.0) Servo/1.0 Firefox/111.0";
#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
const DESKTOP_UA_STRING: &'static str =
const DESKTOP_UA_STRING: &str =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Servo/1.0 Firefox/111.0";
#[cfg(all(target_os = "windows", not(target_arch = "x86_64")))]
const DESKTOP_UA_STRING: &'static str =
const DESKTOP_UA_STRING: &str =
"Mozilla/5.0 (Windows NT 10.0; rv:109.0) Servo/1.0 Firefox/111.0";
#[cfg(target_os = "macos")]
const DESKTOP_UA_STRING: &'static str =
const DESKTOP_UA_STRING: &str =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Servo/1.0 Firefox/111.0";
#[cfg(any(target_os = "android", target_env = "ohos"))]
const DESKTOP_UA_STRING: &'static str = "";
const DESKTOP_UA_STRING: &str = "";
match agent {
UserAgent::Desktop => DESKTOP_UA_STRING,