From 67b277c992d59dfed7d9177d4a62a1517d28a5b5 Mon Sep 17 00:00:00 2001 From: eri Date: Sun, 10 Mar 2024 16:34:16 +0100 Subject: clippy: fix warnings in components/net (#31564) * clippy: fix some warnings in components/net * fix: review comments * fix: tidy --- components/net/fetch/methods.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'components/net/fetch/methods.rs') diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index f98297b197b..3cc177c342a 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -84,7 +84,7 @@ pub struct CancellationListener { impl CancellationListener { pub fn new(cancel_chan: Option>) -> Self { Self { - cancel_chan: cancel_chan, + cancel_chan, cancelled: false, } } @@ -121,7 +121,7 @@ pub async fn fetch(request: &mut Request, target: Target<'_>, context: &FetchCon .unwrap() .set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart)); - fetch_with_cors_cache(request, &mut CorsCache::new(), target, context).await; + fetch_with_cors_cache(request, &mut CorsCache::default(), target, context).await; } pub async fn fetch_with_cors_cache( @@ -161,7 +161,7 @@ pub async fn fetch_with_cors_cache( } // Step 8. - main_fetch(request, cache, false, false, target, &mut None, &context).await; + main_fetch(request, cache, false, false, target, &mut None, context).await; } /// @@ -209,15 +209,15 @@ pub async fn main_fetch( } // Step 2. - if request.local_urls_only { - if !matches!( + if request.local_urls_only && + !matches!( request.current_url().scheme(), "about" | "blob" | "data" | "filesystem" - ) { - response = Some(Response::network_error(NetworkError::Internal( - "Non-local scheme".into(), - ))); - } + ) + { + response = Some(Response::network_error(NetworkError::Internal( + "Non-local scheme".into(), + ))); } // Step 2.2. @@ -267,7 +267,7 @@ pub async fn main_fetch( ) }, }; - request.referrer = referrer_url.map_or(Referrer::NoReferrer, |url| Referrer::ReferrerUrl(url)); + request.referrer = referrer_url.map_or(Referrer::NoReferrer, Referrer::ReferrerUrl); // Step 9. // TODO: handle FTP URLs. @@ -451,7 +451,7 @@ pub async fn main_fetch( *body = ResponseBody::Empty; } - internal_response.get_network_error().map(|e| e.clone()) + internal_response.get_network_error().cloned() }; // Execute deferred rebinding of response. @@ -469,7 +469,7 @@ pub async fn main_fetch( response_loaded = true; // Step 19.2. - let ref integrity_metadata = &request.integrity_metadata; + let integrity_metadata = &request.integrity_metadata; if response.termination_reason.is_none() && !is_response_integrity_valid(integrity_metadata, &response) { @@ -502,8 +502,8 @@ pub async fn main_fetch( // in http_network_fetch. However, we can't yet follow the request // upload progress, so I'm keeping it here for now and pretending // the body got sent in one chunk - target.process_request_body(&request); - target.process_request_eof(&request); + target.process_request_body(request); + target.process_request_eof(request); } // Step 22. @@ -518,7 +518,7 @@ pub async fn main_fetch( target.process_response_eof(&response); if let Ok(http_cache) = context.state.http_cache.write() { - http_cache.update_awaiting_consumers(&request, &response); + http_cache.update_awaiting_consumers(request, &response); } // Steps 25-27. -- cgit v1.2.3