diff --git a/components/devtools/actors/browsing_context.rs b/components/devtools/actors/browsing_context.rs index 0d86494bf55..d584a28621b 100644 --- a/components/devtools/actors/browsing_context.rs +++ b/components/devtools/actors/browsing_context.rs @@ -157,14 +157,12 @@ impl Actor for BrowsingContextActor { fn handle_message( &self, _registry: &ActorRegistry, - msg_type: &str, + _msg_type: &str, _msg: &Map, _stream: &mut TcpStream, _id: StreamId, ) -> Result { - Ok(match msg_type { - _ => ActorMessageStatus::Ignored, - }) + Ok(ActorMessageStatus::Ignored) } fn cleanup(&self, id: StreamId) { diff --git a/components/devtools/actors/watcher.rs b/components/devtools/actors/watcher.rs index 1c68e921493..d772d2ae75e 100644 --- a/components/devtools/actors/watcher.rs +++ b/components/devtools/actors/watcher.rs @@ -193,11 +193,8 @@ impl Actor for WatcherActor { let target = registry.find::(&self.browsing_context_actor); - match resource { - "document-event" => { - target.document_event(stream); - }, - _ => {}, + if resource == "document-event" { + target.document_event(stream); } let _ = stream.write_json_packet(&EmptyReplyMsg { from: self.name() }); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index d206f8b6bdf..a11d1024ba1 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1505,7 +1505,7 @@ impl Fragment { if let Some(ref inline_fragment_context) = self.inline_context { for node in &inline_fragment_context.nodes { if node.style.get_box().position == Position::Relative { - rel_pos = rel_pos + from_style(&*node.style, containing_block_size); + rel_pos = rel_pos + from_style(&node.style, containing_block_size); } } } diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs index 014e22ca4da..880e48bfcb3 100644 --- a/components/layout_2020/flow/inline/mod.rs +++ b/components/layout_2020/flow/inline/mod.rs @@ -1711,14 +1711,14 @@ impl InlineFormattingContext { } fn next_character_prevents_soft_wrap_opportunity(&self, index: usize) -> bool { - let Some(character) = self.text_content[index..].chars().skip(1).next() else { + let Some(character) = self.text_content[index..].chars().nth(1) else { return false; }; char_prevents_soft_wrap_opportunity_when_before_or_after_atomic(character) } fn previous_character_prevents_soft_wrap_opportunity(&self, index: usize) -> bool { - let Some(character) = self.text_content[0..index].chars().rev().next() else { + let Some(character) = self.text_content[0..index].chars().next_back() else { return false; }; char_prevents_soft_wrap_opportunity_when_before_or_after_atomic(character) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index b9a52ee4986..d4e34e7b182 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -306,9 +306,7 @@ impl Layout for LayoutThread { } fn query_content_box(&self, node: OpaqueNode) -> Option> { - let Some(mut root_flow) = self.root_flow_for_query() else { - return None; - }; + let mut root_flow = self.root_flow_for_query()?; let root_flow_ref = FlowRef::deref_mut(&mut root_flow); process_content_box_request(node, root_flow_ref) @@ -1010,7 +1008,7 @@ impl LayoutThread { for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets { self.stylist .append_stylesheet(stylesheet.clone(), &ua_or_user_guard); - self.load_all_web_fonts_from_stylesheet_with_guard(&stylesheet, &ua_or_user_guard); + self.load_all_web_fonts_from_stylesheet_with_guard(stylesheet, &ua_or_user_guard); } if self.stylist.quirks_mode() != QuirksMode::NoQuirks { diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index c49b5eda437..34019fa789d 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -178,10 +178,10 @@ where } #[inline] - pub fn get(&self, k: &Q) -> Option<&V> + pub fn get(&self, k: &Q) -> Option<&V> where K: std::borrow::Borrow, - Q: Hash + Eq, + Q: Hash + Eq + ?Sized, { self.0.get(k) } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index f8526967796..ddf95e976cf 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2987,9 +2987,10 @@ impl Document { /// pub(crate) fn deliver_resize_loop_error_notification(&self) { let global_scope = self.window.upcast::(); - let mut error_info: ErrorInfo = Default::default(); - error_info.message = - "ResizeObserver loop completed with undelivered notifications.".to_string(); + let error_info: ErrorInfo = crate::dom::bindings::error::ErrorInfo { + message: "ResizeObserver loop completed with undelivered notifications.".to_string(), + ..Default::default() + }; global_scope.report_an_error(error_info, HandleValue::null()); } } diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 0336b6d800f..bd1ab6fd178 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -3107,7 +3107,7 @@ impl GlobalScope { DeviceLostReason::Unknown => GPUDeviceLostReason::Unknown, DeviceLostReason::Destroyed => GPUDeviceLostReason::Destroyed, }; - let _ac = enter_realm(&*self); + let _ac = enter_realm(self); if let Some(device) = self .gpu_devices .borrow_mut() diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 59f38e42c17..997fa3c849d 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -780,7 +780,7 @@ impl HTMLMediaElement { // Step 9.obj. Mode::Object => { // Step 9.obj.1. - *self.current_src.borrow_mut() = "".to_owned(); + "".clone_into(&mut self.current_src.borrow_mut()); // Step 9.obj.2. // FIXME(nox): The rest of the steps should be ran in parallel. diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index c3bf89a1124..60efbb474cb 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -88,11 +88,8 @@ impl HTMLMetaElement { // https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv } else if !self.HttpEquiv().is_empty() { // TODO: Implement additional http-equiv candidates - match self.HttpEquiv().to_ascii_lowercase().as_str() { - "refresh" => { - self.declarative_refresh(); - }, - _ => {}, + if self.HttpEquiv().to_ascii_lowercase().as_str() == "refresh" { + self.declarative_refresh(); } } } diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index 0fa6d2cdc4b..074203f4320 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -529,7 +529,7 @@ impl RequestMethods for Request { // https://fetch.spec.whatwg.org/#dom-request-url fn Url(&self) -> USVString { let r = self.request.borrow(); - USVString(r.url_list.get(0).map_or("", |u| u.as_str()).into()) + USVString(r.url_list.first().map_or("", |u| u.as_str()).into()) } // https://fetch.spec.whatwg.org/#dom-request-headers diff --git a/components/script/dom/resizeobserver.rs b/components/script/dom/resizeobserver.rs index b2e0b42ad88..48603c7ffc2 100644 --- a/components/script/dom/resizeobserver.rs +++ b/components/script/dom/resizeobserver.rs @@ -118,11 +118,11 @@ impl ResizeObserver { let height = box_size.height().to_f64_px(); let size_impl = ResizeObserverSizeImpl::new(width, height); let window = window_from_node(&**target); - let observer_size = ResizeObserverSize::new(&*window, size_impl); + let observer_size = ResizeObserverSize::new(&window, size_impl); // Note: content rect is built from content box size. let content_rect = DOMRectReadOnly::new( - &*window.upcast(), + window.upcast(), None, box_size.origin.x.to_f64_px(), box_size.origin.y.to_f64_px(), @@ -130,9 +130,9 @@ impl ResizeObserver { height, ); let entry = ResizeObserverEntry::new( - &*window, + &window, target, - &*content_rect, + &content_rect, &[], &[&*observer_size], &[], diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 254504e3b44..88006e9adb2 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -206,10 +206,10 @@ impl RTCPeerConnection { let signaller = this.make_signaller(); *this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller)); if let Some(ref servers) = config.iceServers { - if let Some(server) = servers.get(0) { + if let Some(server) = servers.first() { let server = match server.urls { StringOrStringSequence::String(ref s) => Some(s.clone()), - StringOrStringSequence::StringSequence(ref s) => s.get(0).cloned(), + StringOrStringSequence::StringSequence(ref s) => s.first().cloned(), }; if let Some(server) = server { let policy = match config.bundlePolicy { diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index ade1fdf4613..3066abcbe61 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -134,7 +134,7 @@ fn start_element(node: &Element, serializer: &mut S) -> io::Resul }) .collect::>(); let attr_refs = attrs.iter().map(|(qname, value)| { - let ar: AttrRef = (&qname, &**value); + let ar: AttrRef = (qname, &**value); ar }); serializer.start_elem(name, attr_refs)?; diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index b3ddf5fd91b..344d41af031 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -622,8 +622,8 @@ impl TestBindingMethods for TestBinding { arg.type_.as_ref().map(|s| s == "success").unwrap_or(false) && arg.nonRequiredNullable.is_none() && arg.nonRequiredNullable2 == Some(None) && - arg.noCallbackImport == None && - arg.noCallbackImport2 == None + arg.noCallbackImport.is_none() && + arg.noCallbackImport2.is_none() } fn PassBoolean(&self, _: bool) {} diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index 43767c4a42a..3f1a7e98d72 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -3134,16 +3134,14 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { let buff = IpcSharedMemory::from_bytes(unsafe { &src_data.as_slice()[src_byte_offset..] }); - let expected_byte_length = match { - self.base.validate_tex_image_2d_data( - width, - height, - format, - data_type, - unpacking_alignment, - Some(&*src_data), - ) - } { + let expected_byte_length = match self.base.validate_tex_image_2d_data( + width, + height, + format, + data_type, + unpacking_alignment, + Some(&*src_data), + ) { Ok(byte_length) => byte_length, Err(()) => return Ok(()), }; @@ -3968,7 +3966,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { buffer.map(|b| b.id()), )); - for slot in &[&generic_slot, &indexed_binding.buffer] { + for slot in &[generic_slot, &indexed_binding.buffer] { if let Some(old) = slot.get() { old.decrement_attached_counter(Operation::Infallible); } @@ -4046,7 +4044,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { size, )); - for slot in &[&generic_slot, &indexed_binding.buffer] { + for slot in &[generic_slot, &indexed_binding.buffer] { if let Some(old) = slot.get() { old.decrement_attached_counter(Operation::Infallible); } diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index cf92577fa68..b4aa745dcc8 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -279,11 +279,11 @@ impl WebGLExtensions { } pub fn is_tex_type_enabled(&self, data_type: GLenum) -> bool { - self.features + !self + .features .borrow() .disabled_tex_types - .get(&data_type) - .is_none() + .contains(&data_type) } pub fn add_effective_tex_internal_format( @@ -321,11 +321,11 @@ impl WebGLExtensions { } pub fn is_filterable(&self, text_data_type: u32) -> bool { - self.features + !self + .features .borrow() .not_filterable_tex_types - .get(&text_data_type) - .is_none() + .contains(&text_data_type) } pub fn enable_hint_target(&self, name: GLenum) { diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index cf827726906..42482e7abd0 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -4292,16 +4292,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { let unpacking_alignment = self.texture_unpacking_alignment.get(); - let expected_byte_length = match { - self.validate_tex_image_2d_data( - width, - height, - format, - data_type, - unpacking_alignment, - pixels.as_ref(), - ) - } { + let expected_byte_length = match self.validate_tex_image_2d_data( + width, + height, + format, + data_type, + unpacking_alignment, + pixels.as_ref(), + ) { Ok(byte_length) => byte_length, Err(()) => return Ok(()), }; @@ -4479,16 +4477,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { let unpacking_alignment = self.texture_unpacking_alignment.get(); - let expected_byte_length = match { - self.validate_tex_image_2d_data( - width, - height, - format, - data_type, - unpacking_alignment, - pixels.as_ref(), - ) - } { + let expected_byte_length = match self.validate_tex_image_2d_data( + width, + height, + format, + data_type, + unpacking_alignment, + pixels.as_ref(), + ) { Ok(byte_length) => byte_length, Err(()) => return Ok(()), }; diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 9b4e5b2cbdc..33fcc0a493f 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1053,7 +1053,7 @@ impl XMLHttpRequest { }, }; - *self.response_url.borrow_mut() = metadata.final_url[..Position::AfterQuery].to_owned(); + metadata.final_url[..Position::AfterQuery].clone_into(&mut self.response_url.borrow_mut()); // XXXManishearth Clear cache entries in case of a network error self.process_partial_response(XHRProgress::HeadersReceived( diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 85d482c9f11..054fee49c87 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -438,10 +438,7 @@ impl XRSession { self.outside_raf.set(false); let len = self.current_raf_callback_list.borrow().len(); for i in 0..len { - let callback = self.current_raf_callback_list.borrow()[i] - .1 - .as_ref() - .map(Rc::clone); + let callback = self.current_raf_callback_list.borrow()[i].1.clone(); if let Some(callback) = callback { let _ = callback.Call__(time, &frame, ExceptionHandling::Report); } diff --git a/components/script/lib.rs b/components/script/lib.rs index 4d984dd5990..57d8427cd8c 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -9,7 +9,7 @@ // crate. Issue a warning if `crown` is not being used to compile, but not when // building rustdoc or running clippy. #![register_tool(crown)] -#![cfg_attr(any(doc, clippy, feature = "cargo-clippy"), allow(unknown_lints))] +#![cfg_attr(any(doc, clippy), allow(unknown_lints))] #![deny(crown_is_not_used)] // These are used a lot so let's keep them for now diff --git a/components/script/script_module.rs b/components/script/script_module.rs index 9578002c5be..0d67385c6bf 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -578,7 +578,7 @@ impl ModuleTree { let url = ModuleTree::resolve_module_specifier( *cx, - &base_url, + base_url, specifier.handle().into_handle(), ); @@ -815,7 +815,7 @@ impl ModuleTree { if incomplete_count_before_remove > 0 { parent_tree.remove_incomplete_fetch_url(&self.url); - parent_tree.advance_finished_and_link(&global); + parent_tree.advance_finished_and_link(global); } } } @@ -831,7 +831,7 @@ impl ModuleTree { (None, None) => { let module_record = self.get_record().borrow(); if let Some(record) = &*module_record { - let instantiated = self.instantiate_module_tree(&global, record.handle()); + let instantiated = self.instantiate_module_tree(global, record.handle()); if let Err(exception) = instantiated { self.set_rethrow_error(exception); diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 4aad9317a45..49daa897862 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -748,8 +748,8 @@ pub unsafe fn get_reports(cx: *mut RawJSContext, path_seg: String) -> Vec> = Cell::new(None)); -thread_local!(static GC_SLICE_START: Cell> = Cell::new(None)); +thread_local!(static GC_CYCLE_START: Cell> = const { Cell::new(None) }); +thread_local!(static GC_SLICE_START: Cell> = const { Cell::new(None) }); #[allow(unsafe_code)] unsafe extern "C" fn gc_slice_callback( @@ -803,7 +803,7 @@ unsafe extern "C" fn debug_gc_callback( } thread_local!( - static THREAD_ACTIVE: Cell = Cell::new(true); + static THREAD_ACTIVE: Cell = const { Cell::new(true) }; ); pub(crate) fn runtime_is_alive() -> bool { diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 0d70eea49e2..9427f52a959 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -165,7 +165,7 @@ use crate::{devtools, webdriver_handlers}; pub type ImageCacheMsg = (PipelineId, PendingImageResponse); -thread_local!(static SCRIPT_THREAD_ROOT: Cell> = Cell::new(None)); +thread_local!(static SCRIPT_THREAD_ROOT: Cell> = const { Cell::new(None) }); pub unsafe fn trace_thread(tr: *mut JSTracer) { SCRIPT_THREAD_ROOT.with(|root| { diff --git a/components/script/textinput.rs b/components/script/textinput.rs index a15d25ed4e0..19c85979ffa 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -982,7 +982,7 @@ impl TextInput { /// Whether the content is empty. pub fn is_empty(&self) -> bool { - self.lines.len() <= 1 && self.lines.get(0).map_or(true, |line| line.is_empty()) + self.lines.len() <= 1 && self.lines.first().map_or(true, |line| line.is_empty()) } /// The length of the content in bytes.