clippy: fix warnings in components/net (#31564)

* clippy: fix some warnings in components/net

* fix: review comments

* fix: tidy
This commit is contained in:
eri 2024-03-10 16:34:16 +01:00 committed by GitHub
parent 099bb0fa19
commit 67b277c992
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 325 additions and 379 deletions

View file

@ -385,7 +385,7 @@ fn test_cors_preflight_cache_fetch() {
static ACK: &'static [u8] = b"ACK";
let state = Arc::new(AtomicUsize::new(0));
let counter = state.clone();
let mut cache = CorsCache::new();
let mut cache = CorsCache::default();
let handler = move |request: HyperRequest<Body>, response: &mut HyperResponse<Body>| {
if request.method() == Method::OPTIONS && state.clone().fetch_add(1, Ordering::SeqCst) == 0
{
@ -757,7 +757,7 @@ fn test_fetch_with_hsts() {
let (server, url) = make_ssl_server(handler);
let mut context = FetchContext {
state: Arc::new(HttpState::new()),
state: Arc::new(HttpState::default()),
user_agent: DEFAULT_USER_AGENT.into(),
devtools_chan: None,
filemanager: Arc::new(Mutex::new(FileManager::new(
@ -816,7 +816,7 @@ fn test_load_adds_host_to_hsts_list_when_url_is_https() {
url.as_mut_url().set_scheme("https").unwrap();
let mut context = FetchContext {
state: Arc::new(HttpState::new()),
state: Arc::new(HttpState::default()),
user_agent: DEFAULT_USER_AGENT.into(),
devtools_chan: None,
filemanager: Arc::new(Mutex::new(FileManager::new(
@ -873,7 +873,7 @@ fn test_fetch_self_signed() {
url.as_mut_url().set_scheme("https").unwrap();
let mut context = FetchContext {
state: Arc::new(HttpState::new()),
state: Arc::new(HttpState::default()),
user_agent: DEFAULT_USER_AGENT.into(),
devtools_chan: None,
filemanager: Arc::new(Mutex::new(FileManager::new(

View file

@ -33,7 +33,7 @@ fn test_refreshing_resource_sets_done_chan_the_appropriate_value() {
response
.headers
.insert(EXPIRES, HeaderValue::from_str("-10").unwrap());
let mut cache = HttpCache::new();
let mut cache = HttpCache::default();
response_bodies.iter().for_each(|body| {
*response.body.lock().unwrap() = body.clone();
// First, store the 'normal' response.

View file

@ -103,7 +103,7 @@ fn new_fetch_context(
let sender = fc.unwrap_or_else(|| create_embedder_proxy());
FetchContext {
state: Arc::new(HttpState::new()),
state: Arc::new(HttpState::default()),
user_agent: DEFAULT_USER_AGENT.into(),
devtools_chan: dc.map(|dc| Arc::new(Mutex::new(dc))),
filemanager: Arc::new(Mutex::new(FileManager::new(

View file

@ -53,7 +53,7 @@ fn test_sniff_mp4_matcher_long() {
#[test]
fn test_validate_classifier() {
let classifier = MimeClassifier::new();
let classifier = MimeClassifier::default();
classifier.validate().expect("Validation error")
}
@ -74,7 +74,7 @@ fn test_sniff_with_flags(
let mut filename = PathBuf::from("tests/parsable_mime/");
filename.push(filename_orig);
let classifier = MimeClassifier::new();
let classifier = MimeClassifier::default();
let read_result = read_file(&filename);