clippy: Fix some warnings in components/script (#31849)

* clippy: fixed some warnings in components/script

* fixed formatting

* fix formatting
This commit is contained in:
Ekta Siwach 2024-03-25 15:52:21 +05:30 committed by GitHub
parent dbe3cb8a3c
commit d8adeb1b44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 24 additions and 27 deletions

View file

@ -169,7 +169,7 @@ impl MutationObserver {
.options
.attribute_filter
.iter()
.any(|s| &**s == &**name)
.any(|s| **s == **name)
{
continue;
}
@ -181,9 +181,9 @@ impl MutationObserver {
None
};
// Step 3.1.1
let idx = interested_observers.iter().position(|(o, _)| {
&**o as *const _ == &*registered.observer as *const _
});
let idx = interested_observers
.iter()
.position(|(o, _)| std::ptr::eq(&**o, &*registered.observer));
if let Some(idx) = idx {
interested_observers[idx].1 = paired_string;
} else {
@ -202,9 +202,9 @@ impl MutationObserver {
None
};
// Step 3.1.1
let idx = interested_observers.iter().position(|(o, _)| {
&**o as *const _ == &*registered.observer as *const _
});
let idx = interested_observers
.iter()
.position(|(o, _)| std::ptr::eq(&**o, &*registered.observer));
if let Some(idx) = idx {
interested_observers[idx].1 = paired_string;
} else {
@ -260,7 +260,7 @@ impl MutationObserver {
impl MutationObserverMethods for MutationObserver {
/// <https://dom.spec.whatwg.org/#dom-mutationobserver-observe>
fn Observe(&self, target: &Node, options: &MutationObserverInit) -> Fallible<()> {
let attribute_filter = options.attributeFilter.clone().unwrap_or(vec![]);
let attribute_filter = options.attributeFilter.clone().unwrap_or_default();
let attribute_old_value = options.attributeOldValue.unwrap_or(false);
let mut attributes = options.attributes.unwrap_or(false);
let mut character_data = options.characterData.unwrap_or(false);

View file

@ -87,8 +87,8 @@ impl MutationRecord {
None,
None,
None,
added_nodes.as_ref().map(|list| &**list),
removed_nodes.as_ref().map(|list| &**list),
added_nodes.as_deref(),
removed_nodes.as_deref(),
next_sibling,
prev_sibling,
)),

View file

@ -114,7 +114,7 @@ impl NamedNodeMapMethods for NamedNodeMap {
continue;
}
if !names.iter().any(|name| &*name == s) {
if !names.iter().any(|name| name == s) {
names.push(DOMString::from(s));
}
}

View file

@ -38,7 +38,7 @@ impl NavigationPreloadManager {
global: &GlobalScope,
registration: &ServiceWorkerRegistration,
) -> DomRoot<NavigationPreloadManager> {
let manager = NavigationPreloadManager::new_inherited(&*registration);
let manager = NavigationPreloadManager::new_inherited(registration);
reflect_dom_object(Box::new(manager), global)
}
}

View file

@ -29,7 +29,7 @@ use crate::dom::performancenavigationtiming::PerformanceNavigationTiming;
use crate::dom::performanceobserver::PerformanceObserver as DOMPerformanceObserver;
use crate::dom::window::Window;
const INVALID_ENTRY_NAMES: &'static [&'static str] = &[
const INVALID_ENTRY_NAMES: &[&str] = &[
"navigationStart",
"unloadEventStart",
"unloadEventEnd",

View file

@ -27,7 +27,7 @@ use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList;
use crate::script_runtime::JSContext;
/// List of allowed performance entry types, in alphabetical order.
pub const VALID_ENTRY_TYPES: &'static [&'static str] = &[
pub const VALID_ENTRY_TYPES: &[&str] = &[
// "frame", //TODO Frame Timing API
"mark", // User Timing API
"measure", // User Timing API

View file

@ -288,20 +288,17 @@ pub fn get_descriptor_permission_state(
// and let the user decide to grant the permission or not.
let state = if allowed_in_nonsecure_contexts(&permission_name) {
PermissionState::Prompt
} else {
if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
} else if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
PermissionState::Granted
} else {
globalscope
.permission_state_invocation_results()
.borrow_mut()
.remove(&permission_name.to_string());
prompt_user_from_embedder(
PermissionPrompt::Insecure(embedder_traits::PermissionName::from(permission_name)),
&globalscope,
)
}
};
// Step 3.