Skip to content

Commit

Permalink
fix many clippy warnings (servo#33510)
Browse files Browse the repository at this point in the history
Signed-off-by: Gae24 <[email protected]>
  • Loading branch information
Gae24 authored Sep 21, 2024
1 parent 4e4b137 commit f986160
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion components/fonts/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions components/layout/display_list/webrender_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/flow/inline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion components/net/http_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/gamepadhapticactuator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/htmlimageelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions components/script/dom/htmllinkelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/xmlhttprequest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down
8 changes: 3 additions & 5 deletions components/script/dom/xrreferencespaceevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
13 changes: 6 additions & 7 deletions components/script/stylesheet_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions components/shared/net/fetch/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion components/shared/net/pub_domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f986160

Please sign in to comment.