Skip to content

Commit 485bbeb

Browse files
ektuupull[bot]
authored andcommitted
clippy: Fix some warnings in components/script (servo#31849)
* clippy: fixed some warnings in components/script * fixed formatting * fix formatting
1 parent 5c9eec9 commit 485bbeb

7 files changed

+24
-27
lines changed

components/script/dom/mutationobserver.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl MutationObserver {
169169
.options
170170
.attribute_filter
171171
.iter()
172-
.any(|s| &**s == &**name)
172+
.any(|s| **s == **name)
173173
{
174174
continue;
175175
}
@@ -181,9 +181,9 @@ impl MutationObserver {
181181
None
182182
};
183183
// Step 3.1.1
184-
let idx = interested_observers.iter().position(|(o, _)| {
185-
&**o as *const _ == &*registered.observer as *const _
186-
});
184+
let idx = interested_observers
185+
.iter()
186+
.position(|(o, _)| std::ptr::eq(&**o, &*registered.observer));
187187
if let Some(idx) = idx {
188188
interested_observers[idx].1 = paired_string;
189189
} else {
@@ -202,9 +202,9 @@ impl MutationObserver {
202202
None
203203
};
204204
// Step 3.1.1
205-
let idx = interested_observers.iter().position(|(o, _)| {
206-
&**o as *const _ == &*registered.observer as *const _
207-
});
205+
let idx = interested_observers
206+
.iter()
207+
.position(|(o, _)| std::ptr::eq(&**o, &*registered.observer));
208208
if let Some(idx) = idx {
209209
interested_observers[idx].1 = paired_string;
210210
} else {
@@ -260,7 +260,7 @@ impl MutationObserver {
260260
impl MutationObserverMethods for MutationObserver {
261261
/// <https://dom.spec.whatwg.org/#dom-mutationobserver-observe>
262262
fn Observe(&self, target: &Node, options: &MutationObserverInit) -> Fallible<()> {
263-
let attribute_filter = options.attributeFilter.clone().unwrap_or(vec![]);
263+
let attribute_filter = options.attributeFilter.clone().unwrap_or_default();
264264
let attribute_old_value = options.attributeOldValue.unwrap_or(false);
265265
let mut attributes = options.attributes.unwrap_or(false);
266266
let mut character_data = options.characterData.unwrap_or(false);

components/script/dom/mutationrecord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ impl MutationRecord {
8787
None,
8888
None,
8989
None,
90-
added_nodes.as_ref().map(|list| &**list),
91-
removed_nodes.as_ref().map(|list| &**list),
90+
added_nodes.as_deref(),
91+
removed_nodes.as_deref(),
9292
next_sibling,
9393
prev_sibling,
9494
)),

components/script/dom/namednodemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl NamedNodeMapMethods for NamedNodeMap {
114114
continue;
115115
}
116116

117-
if !names.iter().any(|name| &*name == s) {
117+
if !names.iter().any(|name| name == s) {
118118
names.push(DOMString::from(s));
119119
}
120120
}

components/script/dom/navigationpreloadmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl NavigationPreloadManager {
3838
global: &GlobalScope,
3939
registration: &ServiceWorkerRegistration,
4040
) -> DomRoot<NavigationPreloadManager> {
41-
let manager = NavigationPreloadManager::new_inherited(&*registration);
41+
let manager = NavigationPreloadManager::new_inherited(registration);
4242
reflect_dom_object(Box::new(manager), global)
4343
}
4444
}

components/script/dom/performance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::dom::performancenavigationtiming::PerformanceNavigationTiming;
2929
use crate::dom::performanceobserver::PerformanceObserver as DOMPerformanceObserver;
3030
use crate::dom::window::Window;
3131

32-
const INVALID_ENTRY_NAMES: &'static [&'static str] = &[
32+
const INVALID_ENTRY_NAMES: &[&str] = &[
3333
"navigationStart",
3434
"unloadEventStart",
3535
"unloadEventEnd",

components/script/dom/performanceobserver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList;
2727
use crate::script_runtime::JSContext;
2828

2929
/// List of allowed performance entry types, in alphabetical order.
30-
pub const VALID_ENTRY_TYPES: &'static [&'static str] = &[
30+
pub const VALID_ENTRY_TYPES: &[&str] = &[
3131
// "frame", //TODO Frame Timing API
3232
"mark", // User Timing API
3333
"measure", // User Timing API

components/script/dom/permissions.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,20 +288,17 @@ pub fn get_descriptor_permission_state(
288288
// and let the user decide to grant the permission or not.
289289
let state = if allowed_in_nonsecure_contexts(&permission_name) {
290290
PermissionState::Prompt
291+
} else if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
292+
PermissionState::Granted
291293
} else {
292-
if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
293-
PermissionState::Granted
294-
} else {
295-
globalscope
296-
.permission_state_invocation_results()
297-
.borrow_mut()
298-
.remove(&permission_name.to_string());
299-
300-
prompt_user_from_embedder(
301-
PermissionPrompt::Insecure(embedder_traits::PermissionName::from(permission_name)),
302-
&globalscope,
303-
)
304-
}
294+
globalscope
295+
.permission_state_invocation_results()
296+
.borrow_mut()
297+
.remove(&permission_name.to_string());
298+
prompt_user_from_embedder(
299+
PermissionPrompt::Insecure(embedder_traits::PermissionName::from(permission_name)),
300+
&globalscope,
301+
)
305302
};
306303

307304
// Step 3.

0 commit comments

Comments
 (0)