fix many clippy warnings (#33510)

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24 2024-09-21 15:58:31 +02:00 committed by GitHub
parent 4e4b137eaa
commit f986160ed4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 29 additions and 34 deletions

View file

@ -458,7 +458,7 @@ pub struct GlyphStore {
is_rtl: bool,
}
impl<'a> GlyphStore {
impl GlyphStore {
/// Initializes the glyph store, but doesn't actually shape anything.
///
/// Use the `add_*` methods to store glyph data.

View file

@ -252,7 +252,7 @@ impl DisplayItem {
match *self {
DisplayItem::Rectangle(ref mut item) => {
let mut rect_item = item.item.clone();
let mut rect_item = item.item;
rect_item.common = build_common_item_properties(&item.base);
rect_item.bounds = item.item.bounds.translate(stacking_context_offset);
@ -261,7 +261,7 @@ impl DisplayItem {
IsContentful(false)
},
DisplayItem::Text(ref mut item) => {
let mut text_item = item.item.clone();
let mut text_item = item.item;
text_item.bounds = text_item.bounds.translate(stacking_context_offset);
text_item.common = build_common_item_properties(&item.base);
@ -277,7 +277,7 @@ impl DisplayItem {
IsContentful(true)
},
DisplayItem::Image(ref mut item) => {
let mut image_item = item.item.clone();
let mut image_item = item.item;
image_item.common = build_common_item_properties(&item.base);
image_item.bounds = item.item.bounds.translate(stacking_context_offset);
@ -286,7 +286,7 @@ impl DisplayItem {
IsContentful(true)
},
DisplayItem::RepeatingImage(ref mut item) => {
let mut image_item = item.item.clone();
let mut image_item = item.item;
image_item.common = build_common_item_properties(&item.base);
image_item.bounds = item.item.bounds.translate(stacking_context_offset);
@ -295,7 +295,7 @@ impl DisplayItem {
IsContentful(true)
},
DisplayItem::Border(ref mut item) => {
let mut border_item = item.item.clone();
let mut border_item = item.item;
border_item.common = build_common_item_properties(&item.base);
border_item.bounds = item.item.bounds.translate(stacking_context_offset);
@ -307,7 +307,7 @@ impl DisplayItem {
IsContentful(false)
},
DisplayItem::Gradient(ref mut item) => {
let mut gradient_item = item.item.clone();
let mut gradient_item = item.item;
gradient_item.common = build_common_item_properties(&item.base);
gradient_item.bounds = item.item.bounds.translate(stacking_context_offset);
@ -317,7 +317,7 @@ impl DisplayItem {
IsContentful(false)
},
DisplayItem::RadialGradient(ref mut item) => {
let mut gradient_item = item.item.clone();
let mut gradient_item = item.item;
gradient_item.common = build_common_item_properties(&item.base);
gradient_item.bounds = item.item.bounds.translate(stacking_context_offset);
@ -327,7 +327,7 @@ impl DisplayItem {
IsContentful(false)
},
DisplayItem::Line(ref mut item) => {
let mut line_item = item.item.clone();
let mut line_item = item.item;
line_item.common = build_common_item_properties(&item.base);
line_item.area = item.item.area.translate(stacking_context_offset);
@ -336,7 +336,7 @@ impl DisplayItem {
IsContentful(false)
},
DisplayItem::BoxShadow(ref mut item) => {
let mut shadow_item = item.item.clone();
let mut shadow_item = item.item;
shadow_item.common = build_common_item_properties(&item.base);
shadow_item.box_bounds = item.item.box_bounds.translate(stacking_context_offset);

View file

@ -1685,7 +1685,7 @@ impl InlineFormattingContext {
FlowLayout {
fragments: layout.fragments,
content_block_size: content_block_size,
content_block_size,
collapsible_margins_in_children,
baselines: layout.baselines,
}

View file

@ -182,7 +182,7 @@ fn calculate_response_age(response: &Response) -> Duration {
.get(header::AGE)
.and_then(|age_header| age_header.to_str().ok())
.and_then(|age_string| age_string.parse::<u64>().ok())
.map(|seconds| Duration::from_secs(seconds))
.map(Duration::from_secs)
.unwrap_or_default()
}

View file

@ -98,7 +98,7 @@ fn find_python() -> PathBuf {
for name in &candidates {
// Command::new() allows us to omit the `.exe` suffix on windows
if Command::new(&name)
if Command::new(name)
.arg("--version")
.output()
.is_ok_and(|out| out.status.success())

View file

@ -96,7 +96,7 @@ impl GamepadHapticActuator {
}
Self {
reflector_: Reflector::new(),
gamepad_index: gamepad_index,
gamepad_index,
effects,
playing_effect_promise: DomRefCell::new(None),
sequence_id: Cell::new(0),

View file

@ -7,7 +7,7 @@ use std::collections::HashSet;
use std::default::Default;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::{char, i32, mem};
use std::{char, mem};
use app_units::{Au, AU_PER_PX};
use base::id::PipelineId;

View file

@ -656,9 +656,7 @@ impl LinkProcessingOptions {
assert!(!self.href.is_empty());
// Step 2. If options's destination is null, then return null.
let Some(destination) = self.destination else {
return None;
};
let destination = self.destination?;
// Step 3. Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL.
// TODO: The spec passes a base url which is incompatible with the

View file

@ -478,7 +478,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
let name_str = name.as_str().ok_or(Error::Syntax)?;
// Step 5: If (name, value) is a forbidden request-header, then return.
if is_forbidden_request_header(name_str, &value) {
if is_forbidden_request_header(name_str, value) {
return Ok(());
}

View file

@ -114,11 +114,9 @@ impl XRReferenceSpaceEventMethods for XRReferenceSpaceEvent {
/// <https://www.w3.org/TR/webxr/#dom-xrreferencespaceevent-transform>
fn GetTransform(&self) -> Option<DomRoot<XRRigidTransform>> {
if let Some(ref transform) = self.transform {
Some(DomRoot::from_ref(&**transform))
} else {
None
}
self.transform
.as_ref()
.map(|transform| DomRoot::from_ref(&**transform))
}
/// <https://dom.spec.whatwg.org/#dom-event-istrusted>

View file

@ -99,13 +99,12 @@ impl FetchResponseListener for StylesheetContext {
fn process_request_eof(&mut self) {}
fn process_response(&mut self, metadata: Result<FetchMetadata, NetworkError>) {
if let Ok(FetchMetadata::Filtered { ref filtered, .. }) = metadata {
match *filtered {
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect(_) => {
self.origin_clean = false;
},
_ => {},
}
if let Ok(FetchMetadata::Filtered {
filtered: FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect(_),
..
}) = metadata
{
self.origin_clean = false;
}
self.metadata = metadata.ok().map(|m| match m {

View file

@ -37,7 +37,7 @@ pub fn get_decode_and_split_header_name(name: &str, headers: &HeaderMap) -> Opti
// Step 1: Let value be the result of getting name from list.
// Step 2: If value is null, then return null.
// Step 3: Return the result of getting, decoding, and splitting value.
get_value_from_header_list(name, headers).map(|value| get_decode_and_split_header_value(value))
get_value_from_header_list(name, headers).map(get_decode_and_split_header_value)
}
/// <https://fetch.spec.whatwg.org/#header-value-get-decode-and-split>
@ -93,7 +93,7 @@ pub fn get_decode_and_split_header_value(value: Vec<u8>) -> Vec<String> {
temporary_value = String::new();
}
return values;
values
}
/// <https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points>

View file

@ -28,7 +28,7 @@ pub struct PubDomainRules {
exceptions: HashSet<String>,
}
static PUB_DOMAINS: LazyLock<PubDomainRules> = LazyLock::new(|| load_pub_domains());
static PUB_DOMAINS: LazyLock<PubDomainRules> = LazyLock::new(load_pub_domains);
impl<'a> FromIterator<&'a str> for PubDomainRules {
fn from_iter<T>(iter: T) -> Self