From 7f1ef4c7fe7d68b08894eb0e944448505178f79d Mon Sep 17 00:00:00 2001 From: eri Date: Mon, 11 Mar 2024 11:22:28 +0100 Subject: [PATCH] clippy: Fix warnings in `components/constellation` (#31610) * clippy: fix warnings in components/constellation * fix: review comments --- components/constellation/browsingcontext.rs | 4 +- components/constellation/constellation.rs | 144 +++++++++---------- components/constellation/event_loop.rs | 2 +- components/constellation/network_listener.rs | 4 +- components/constellation/pipeline.rs | 38 ++--- components/constellation/session_history.rs | 32 ++--- components/constellation/timer_scheduler.rs | 2 +- 7 files changed, 114 insertions(+), 112 deletions(-) diff --git a/components/constellation/browsingcontext.rs b/components/constellation/browsingcontext.rs index c7f43e0d977..d7bfaab3d74 100644 --- a/components/constellation/browsingcontext.rs +++ b/components/constellation/browsingcontext.rs @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +#![allow(clippy::too_many_arguments)] + use std::collections::{HashMap, HashSet}; use euclid::Size2D; @@ -198,7 +200,7 @@ impl<'a> Iterator for AllBrowsingContextsIterator<'a> { let child_browsing_context_ids = browsing_context .pipelines .iter() - .filter_map(|pipeline_id| pipelines.get(&pipeline_id)) + .filter_map(|pipeline_id| pipelines.get(pipeline_id)) .flat_map(|pipeline| pipeline.children.iter()); self.stack.extend(child_browsing_context_ids); return Some(browsing_context); diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index bed908bc798..74ce41354cd 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -84,6 +84,8 @@ //! //! See +#![allow(clippy::too_many_arguments)] + use std::borrow::{Cow, ToOwned}; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet, VecDeque}; @@ -708,7 +710,7 @@ where ROUTER.add_route( webrender_ipc_receiver.to_opaque(), Box::new(move |message| { - let _ = compositor_proxy.send(CompositorMsg::Forwarded( + compositor_proxy.send(CompositorMsg::Forwarded( ForwardedToCompositorMsg::Layout( message.to().expect("conversion failure"), ), @@ -720,7 +722,7 @@ where ROUTER.add_route( webrender_image_ipc_receiver.to_opaque(), Box::new(move |message| { - let _ = compositor_proxy.send(CompositorMsg::Forwarded( + compositor_proxy.send(CompositorMsg::Forwarded( ForwardedToCompositorMsg::Net( message.to().expect("conversion failure"), ), @@ -743,12 +745,12 @@ where background_monitor_register, background_monitor_control_senders: background_hang_monitor_control_ipc_senders, layout_sender: layout_ipc_sender, - script_receiver: script_receiver, - compositor_receiver: compositor_receiver, + script_receiver, + compositor_receiver, layout_factory, - layout_receiver: layout_receiver, - network_listener_sender: network_listener_sender, - network_listener_receiver: network_listener_receiver, + layout_receiver, + network_listener_sender, + network_listener_receiver, embedder_proxy: state.embedder_proxy, compositor_proxy: state.compositor_proxy, webviews: WebViewManager::default(), @@ -758,7 +760,7 @@ where private_resource_threads: state.private_resource_threads, font_cache_thread: state.font_cache_thread, sw_managers: Default::default(), - swmanager_receiver: swmanager_receiver, + swmanager_receiver, swmanager_ipc_sender, browsing_context_group_set: Default::default(), browsing_context_group_next_id: Default::default(), @@ -854,7 +856,7 @@ where Some(browsing_context_id) => { let opener = self .browsing_contexts - .get(&browsing_context_id) + .get(browsing_context_id) .ok_or("Opener was closed before the openee started")?; self.browsing_context_group_set .get(&opener.bc_group_id) @@ -866,7 +868,7 @@ where .filter_map(|(_, bc_group)| { if bc_group .top_level_browsing_context_set - .contains(&top_level_browsing_context_id) + .contains(top_level_browsing_context_id) { Some(bc_group) } else { @@ -911,7 +913,7 @@ where .top_level_browsing_context_set .contains(&top_level_browsing_context_id) { - Some(id.clone()) + Some(*id) } else { None } @@ -925,10 +927,10 @@ where }, }; if let Some(bc_group) = self.browsing_context_group_set.get_mut(&bc_group_id) { - if !bc_group + if bc_group .event_loops .insert(host.clone(), event_loop) - .is_none() + .is_some() { warn!( "Double-setting an event-loop for {:?} at {:?}", @@ -1024,7 +1026,7 @@ where opener, script_to_constellation_chan: ScriptToConstellationChan { sender: self.script_sender.clone(), - pipeline_id: pipeline_id, + pipeline_id, }, namespace_request_sender: self.namespace_ipc_sender.clone(), pipeline_namespace_id: self.next_pipeline_namespace_id(), @@ -1151,7 +1153,7 @@ where }) .last() { - Some(id) => id.clone(), + Some(id) => *id, None => { warn!("Top-level was unexpectedly removed from its top_level_browsing_context_set"); return; @@ -1209,7 +1211,7 @@ where let scheduler_timeout = self .timer_scheduler .check_timers() - .map(|timeout| after(timeout)) + .map(after) .unwrap_or(never()); // Get one incoming request. @@ -1401,12 +1403,12 @@ where } }, None => { - return warn!( + warn!( "{}: AllowNavigationResponse for unknown request", pipeline_id - ); + ) }, - }; + } }, FromCompositorMsg::ClearCache => { self.public_resource_threads.clear_cache(); @@ -1771,7 +1773,7 @@ where let result = self .browsing_contexts .get(&browsing_context_id) - .and_then(|bc| Some(bc.top_level_id)); + .map(|bc| bc.top_level_id); if let Err(e) = response_sender.send(result) { warn!( "Sending reply to get top for browsing context info failed ({:?}).", @@ -1789,7 +1791,7 @@ where .get(&browsing_context_id) .and_then(|bc| self.pipelines.get(&bc.pipeline_id)) .and_then(|pipeline| pipeline.children.get(index)) - .map(|maybe_bcid| *maybe_bcid); + .copied(); if let Err(e) = response_sender.send(result) { warn!( "Sending reply to get child browsing context ID failed ({:?}).", @@ -1825,15 +1827,13 @@ where // the active media session. // Events coming from inactive media sessions are discarded. if self.active_media_session.is_some() { - match event { - MediaSessionEvent::PlaybackStateChange(ref state) => { - match state { - MediaSessionPlaybackState::Playing | - MediaSessionPlaybackState::Paused => (), - _ => return, - }; - }, - _ => (), + if let MediaSessionEvent::PlaybackStateChange(ref state) = event { + if !matches!( + state, + MediaSessionPlaybackState::Playing | MediaSessionPlaybackState::Paused + ) { + return; + } }; } self.active_media_session = Some(pipeline_id); @@ -1869,7 +1869,7 @@ where pipeline_id: &PipelineId, origin: &ImmutableOrigin, ) -> Result<(), ()> { - let pipeline_origin = match self.pipelines.get(&pipeline_id) { + let pipeline_origin = match self.pipelines.get(pipeline_id) { Some(pipeline) => pipeline.load_data.url.origin(), None => { warn!("Received message from closed or unknown pipeline."); @@ -1909,7 +1909,7 @@ where continue; } - if let Some(broadcast_ipc_sender) = self.broadcast_routers.get(&router) { + if let Some(broadcast_ipc_sender) = self.broadcast_routers.get(router) { if broadcast_ipc_sender.send(message.clone()).is_err() { warn!("Failed to broadcast message to router: {:?}", router); } @@ -1974,12 +1974,9 @@ where { return warn!("Attempt to add channel name from an unexpected origin."); } - let channels = self - .broadcast_channels - .entry(origin) - .or_insert_with(HashMap::new); + let channels = self.broadcast_channels.entry(origin).or_default(); - let routers = channels.entry(channel_name).or_insert_with(Vec::new); + let routers = channels.entry(channel_name).or_default(); routers.push(router_id); } @@ -2045,7 +2042,7 @@ where }; let browsing_context_group = if let Some(bcg) = self .browsing_context_group_set - .get_mut(&browsing_context_group_id) + .get_mut(browsing_context_group_id) { bcg } else { @@ -2074,7 +2071,7 @@ where FromScriptMsg::RequestAdapter(response_sender, options, ids) => match webgpu_chan { None => { if let Err(e) = response_sender.send(None) { - return warn!("Failed to send request adapter message: {}", e); + warn!("Failed to send request adapter message: {}", e) } }, Some(webgpu_chan) => { @@ -2090,13 +2087,13 @@ where }, FromScriptMsg::GetWebGPUChan(response_sender) => { if response_sender.send(webgpu_chan).is_err() { - return warn!( + warn!( "{}: Failed to send WebGPU channel to pipeline", source_pipeline_id - ); + ) } }, - _ => return warn!("Wrong message type in handle_wgpu_request"), + _ => warn!("Wrong message type in handle_wgpu_request"), } } @@ -2347,7 +2344,7 @@ where // In both the managed and completion of a transfer case, we forward the message. // Note that in both cases, if the port is transferred before the message is handled, // it will be sent back here and buffered while the transfer is ongoing. - if let Some(ipc_sender) = self.message_port_routers.get(&router_id) { + if let Some(ipc_sender) = self.message_port_routers.get(router_id) { let _ = ipc_sender.send(MessagePortMsg::NewTask(port_id, task)); } else { warn!("No message-port sender for {:?}", router_id); @@ -2694,7 +2691,7 @@ where let receivers = self .browsing_context_group_set .values() - .map(|browsing_context_group| { + .flat_map(|browsing_context_group| { browsing_context_group.webgpus.values().map(|webgpu| { let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!"); if let Err(e) = webgpu.exit(sender) { @@ -2705,8 +2702,7 @@ where } }) }) - .flatten() - .filter_map(|r| r); + .flatten(); for receiver in receivers { if let Err(e) = receiver.recv() { @@ -2978,7 +2974,7 @@ where let new_bc_group_id = self.next_browsing_context_group_id(); new_bc_group .top_level_browsing_context_set - .insert(top_level_browsing_context_id.clone()); + .insert(top_level_browsing_context_id); self.browsing_context_group_set .insert(new_bc_group_id, new_bc_group); @@ -3226,10 +3222,10 @@ where browsing_context_is_visible, ); self.add_pending_change(SessionHistoryChange { - top_level_browsing_context_id: top_level_browsing_context_id, - browsing_context_id: browsing_context_id, - new_pipeline_id: new_pipeline_id, - replace: replace, + top_level_browsing_context_id, + browsing_context_id, + new_pipeline_id, + replace, // Browsing context for iframe already exists. new_browsing_context_info: None, window_size: load_info.window_size.initial_viewport, @@ -3363,7 +3359,7 @@ where }; bc_group .top_level_browsing_context_set - .insert(new_top_level_browsing_context_id.clone()); + .insert(new_top_level_browsing_context_id); self.add_pending_change(SessionHistoryChange { top_level_browsing_context_id: new_top_level_browsing_context_id, @@ -3564,9 +3560,9 @@ where is_visible, ); self.add_pending_change(SessionHistoryChange { - top_level_browsing_context_id: top_level_browsing_context_id, - browsing_context_id: browsing_context_id, - new_pipeline_id: new_pipeline_id, + top_level_browsing_context_id, + browsing_context_id, + new_pipeline_id, replace, // `load_url` is always invoked on an existing browsing context. new_browsing_context_info: None, @@ -3660,7 +3656,7 @@ where match replacement_enabled { HistoryEntryReplacement::Disabled => { - let diff = SessionHistoryDiff::HashDiff { + let diff = SessionHistoryDiff::Hash { pipeline_reloader: NeedsToReload::No(pipeline_id), new_url, old_url, @@ -3697,7 +3693,7 @@ where .rev() { match diff { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { browsing_context_id, ref new_reloader, .. @@ -3705,7 +3701,7 @@ where browsing_context_changes .insert(browsing_context_id, new_reloader.clone()); }, - SessionHistoryDiff::PipelineDiff { + SessionHistoryDiff::Pipeline { ref pipeline_reloader, new_history_state_id, ref new_url, @@ -3721,7 +3717,7 @@ where url_to_load.insert(pipeline_id, new_url.clone()); }, }, - SessionHistoryDiff::HashDiff { + SessionHistoryDiff::Hash { ref pipeline_reloader, ref new_url, .. @@ -3749,7 +3745,7 @@ where for diff in session_history.past.drain(past_length - back..).rev() { match diff { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { browsing_context_id, ref old_reloader, .. @@ -3757,7 +3753,7 @@ where browsing_context_changes .insert(browsing_context_id, old_reloader.clone()); }, - SessionHistoryDiff::PipelineDiff { + SessionHistoryDiff::Pipeline { ref pipeline_reloader, old_history_state_id, ref old_url, @@ -3773,7 +3769,7 @@ where url_to_load.insert(pipeline_id, old_url.clone()); }, }, - SessionHistoryDiff::HashDiff { + SessionHistoryDiff::Hash { ref pipeline_reloader, ref old_url, .. @@ -4004,7 +4000,7 @@ where }, }; - let diff = SessionHistoryDiff::PipelineDiff { + let diff = SessionHistoryDiff::Pipeline { pipeline_reloader: NeedsToReload::No(pipeline_id), new_history_state_id: history_state_id, new_url: url, @@ -4439,7 +4435,7 @@ where CompositorEvent::KeyboardEvent(event), ); if let Err(e) = event_loop.send(control_msg) { - return self.handle_send_error(pipeline_id, e); + self.handle_send_error(pipeline_id, e) } }, WebDriverCommandMsg::MouseButtonAction(mouse_event_type, mouse_button, x, y) => { @@ -4475,9 +4471,9 @@ where }, }; match self.pipelines.get(&pipeline_id) { - None => return warn!("{pipeline_id}: Tried to notify visibility after closure"), + None => warn!("{pipeline_id}: Tried to notify visibility after closure"), Some(pipeline) => pipeline.notify_visibility(visible), - }; + } } fn notify_history_changed(&self, top_level_browsing_context_id: TopLevelBrowsingContextId) { @@ -4518,7 +4514,7 @@ where // is the LoadData of the parent browsing context. let resolve_load_data_future = |previous_load_data: &mut LoadData, diff: &SessionHistoryDiff| match *diff { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { browsing_context_id, ref new_reloader, .. @@ -4544,7 +4540,7 @@ where let resolve_load_data_past = |previous_load_data: &mut LoadData, diff: &SessionHistoryDiff| match *diff { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { browsing_context_id, ref old_reloader, .. @@ -4698,7 +4694,7 @@ where NeedsToReload::Yes(..) => (None, None), } } else { - let diff = SessionHistoryDiff::BrowsingContextDiff { + let diff = SessionHistoryDiff::BrowsingContext { browsing_context_id: change.browsing_context_id, new_reloader: NeedsToReload::No(change.new_pipeline_id), old_reloader: NeedsToReload::No(old_pipeline_id), @@ -4713,12 +4709,12 @@ where for diff in diffs_to_close { match diff { - SessionHistoryDiff::BrowsingContextDiff { new_reloader, .. } => { + SessionHistoryDiff::BrowsingContext { new_reloader, .. } => { if let Some(pipeline_id) = new_reloader.alive_pipeline_id() { pipelines_to_close.push(pipeline_id); } }, - SessionHistoryDiff::PipelineDiff { + SessionHistoryDiff::Pipeline { pipeline_reloader, new_history_state_id, .. @@ -4807,7 +4803,7 @@ where .rev() .map(|diff| diff.alive_old_pipeline()) .skip(history_length) - .filter_map(|maybe_pipeline| maybe_pipeline) + .flatten() .collect::>(); // The future is stored with oldest entries front, so we must @@ -4819,7 +4815,7 @@ where .rev() .map(|diff| diff.alive_new_pipeline()) .skip(history_length) - .filter_map(|maybe_pipeline| maybe_pipeline), + .flatten(), ); pipelines_to_evict @@ -5088,7 +5084,7 @@ where .iter() .filter(|pipeline_id| **pipeline_id != pipeline.id); for id in pipeline_ids { - if let Some(pipeline) = self.pipelines.get(&id) { + if let Some(pipeline) = self.pipelines.get(id) { let _ = pipeline .event_loop .send(ConstellationControlMsg::ResizeInactive( diff --git a/components/constellation/event_loop.rs b/components/constellation/event_loop.rs index 7849cceb9c0..dacf55bfe24 100644 --- a/components/constellation/event_loop.rs +++ b/components/constellation/event_loop.rs @@ -31,7 +31,7 @@ impl EventLoop { /// Create a new event loop from the channel to its script thread. pub fn new(script_chan: IpcSender) -> Rc { Rc::new(EventLoop { - script_chan: script_chan, + script_chan, dont_send_or_sync: PhantomData, }) } diff --git a/components/constellation/network_listener.rs b/components/constellation/network_listener.rs index cddfff8dbfa..a3dd8c11027 100644 --- a/components/constellation/network_listener.rs +++ b/components/constellation/network_listener.rs @@ -54,7 +54,7 @@ impl NetworkListener { request_builder: self.request_builder.clone(), resource_threads: self.resource_threads.clone(), sender: self.sender.clone(), - pipeline_id: self.pipeline_id.clone(), + pipeline_id: self.pipeline_id, should_send: false, }; @@ -119,7 +119,7 @@ impl NetworkListener { self.request_builder.referrer = metadata .referrer .clone() - .map(|referrer_url| Referrer::ReferrerUrl(referrer_url)) + .map(Referrer::ReferrerUrl) .unwrap_or(Referrer::NoReferrer); self.request_builder.referrer_policy = metadata.referrer_policy; diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 525fca57f79..fc6f038a5f1 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +#![allow(clippy::too_many_arguments)] + use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::rc::Rc; @@ -291,7 +293,7 @@ impl Pipeline { layout_to_constellation_chan: state.layout_to_constellation_chan, script_chan: script_chan.clone(), load_data: state.load_data.clone(), - script_port: script_port, + script_port, opts: (*opts::get()).clone(), prefs: prefs::pref_map().iter().collect(), pipeline_namespace_id: state.pipeline_namespace_id, @@ -311,7 +313,7 @@ impl Pipeline { let (bhm_control_chan, bhm_control_port) = ipc::channel().expect("Sampler chan"); unprivileged_pipeline_content.bhm_control_port = Some(bhm_control_port); - let _ = unprivileged_pipeline_content.spawn_multiprocess()?; + unprivileged_pipeline_content.spawn_multiprocess()?; Some(bhm_control_chan) } else { // Should not be None in single-process mode. @@ -358,16 +360,16 @@ impl Pipeline { load_data: LoadData, ) -> Pipeline { let pipeline = Pipeline { - id: id, - browsing_context_id: browsing_context_id, - top_level_browsing_context_id: top_level_browsing_context_id, - opener: opener, - event_loop: event_loop, - compositor_proxy: compositor_proxy, + id, + browsing_context_id, + top_level_browsing_context_id, + opener, + event_loop, + compositor_proxy, url: load_data.url.clone(), children: vec![], animation_state: AnimationState::NoAnimationsPresent, - load_data: load_data, + load_data, history_state_id: None, history_states: HashSet::new(), completely_loaded: false, @@ -426,8 +428,8 @@ impl Pipeline { /// The compositor's view of a pipeline. pub fn to_sendable(&self) -> CompositionPipeline { CompositionPipeline { - id: self.id.clone(), - top_level_browsing_context_id: self.top_level_browsing_context_id.clone(), + id: self.id, + top_level_browsing_context_id: self.top_level_browsing_context_id, script_chan: self.event_loop.sender(), } } @@ -445,13 +447,15 @@ impl Pipeline { .position(|id| *id == browsing_context_id) { None => { - return warn!( + warn!( "Pipeline remove child already removed ({:?}).", browsing_context_id - ); + ) }, - Some(index) => self.children.remove(index), - }; + Some(index) => { + self.children.remove(index); + }, + } } /// Notify the script thread that this pipeline is visible. @@ -539,13 +543,13 @@ impl UnprivilegedPipelineContent { devtools_chan: self.devtools_ipc_sender, window_size: self.window_size, pipeline_namespace_id: self.pipeline_namespace_id, - content_process_shutdown_chan: content_process_shutdown_chan, + content_process_shutdown_chan, webgl_chan: self.webgl_chan, webxr_registry: self.webxr_registry, webrender_document: self.webrender_document, webrender_api_sender: self.webrender_api_sender.clone(), player_context: self.player_context.clone(), - inherited_secure_context: self.load_data.inherited_secure_context.clone(), + inherited_secure_context: self.load_data.inherited_secure_context, }, layout_factory, self.font_cache_thread.clone(), diff --git a/components/constellation/session_history.rs b/components/constellation/session_history.rs index b29d8635be7..9e6f765ee15 100644 --- a/components/constellation/session_history.rs +++ b/components/constellation/session_history.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::cmp::PartialEq; -use std::{fmt, mem}; +use std::fmt; use euclid::Size2D; use log::debug; @@ -44,7 +44,7 @@ impl JointSessionHistory { pub fn push_diff(&mut self, diff: SessionHistoryDiff) -> Vec { debug!("pushing a past entry; removing future"); self.past.push(diff); - mem::replace(&mut self.future, vec![]) + std::mem::take(&mut self.future) } pub fn replace_reloader(&mut self, old_reloader: NeedsToReload, new_reloader: NeedsToReload) { @@ -59,12 +59,12 @@ impl JointSessionHistory { history_state_id: HistoryStateId, url: ServoUrl, ) { - if let Some(SessionHistoryDiff::PipelineDiff { + if let Some(SessionHistoryDiff::Pipeline { ref mut new_history_state_id, ref mut new_url, .. }) = self.past.iter_mut().find(|diff| match diff { - SessionHistoryDiff::PipelineDiff { + SessionHistoryDiff::Pipeline { pipeline_reloader: NeedsToReload::No(id), .. } => pipeline_id == *id, @@ -74,12 +74,12 @@ impl JointSessionHistory { *new_url = url.clone(); } - if let Some(SessionHistoryDiff::PipelineDiff { + if let Some(SessionHistoryDiff::Pipeline { ref mut old_history_state_id, ref mut old_url, .. }) = self.future.iter_mut().find(|diff| match diff { - SessionHistoryDiff::PipelineDiff { + SessionHistoryDiff::Pipeline { pipeline_reloader: NeedsToReload::No(id), .. } => pipeline_id == *id, @@ -93,14 +93,14 @@ impl JointSessionHistory { pub fn remove_entries_for_browsing_context(&mut self, context_id: BrowsingContextId) { debug!("{}: Removing entries for browsing context", context_id); self.past.retain(|diff| match diff { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { browsing_context_id, .. } => *browsing_context_id != context_id, _ => true, }); self.future.retain(|diff| match diff { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { browsing_context_id, .. } => *browsing_context_id != context_id, @@ -180,7 +180,7 @@ impl PartialEq for NeedsToReload { #[derive(Debug)] pub enum SessionHistoryDiff { /// Represents a diff where the active pipeline of an entry changed. - BrowsingContextDiff { + BrowsingContext { /// The browsing context whose pipeline changed browsing_context_id: BrowsingContextId, /// The previous pipeline (used when traversing into the past) @@ -189,7 +189,7 @@ pub enum SessionHistoryDiff { new_reloader: NeedsToReload, }, /// Represents a diff where the active state of a pipeline changed. - PipelineDiff { + Pipeline { /// The pipeline whose history state changed. pipeline_reloader: NeedsToReload, /// The old history state id. @@ -201,7 +201,7 @@ pub enum SessionHistoryDiff { /// The new url new_url: ServoUrl, }, - HashDiff { + Hash { pipeline_reloader: NeedsToReload, old_url: ServoUrl, new_url: ServoUrl, @@ -212,7 +212,7 @@ impl SessionHistoryDiff { /// Returns the old pipeline id if that pipeline is still alive, otherwise returns `None` pub fn alive_old_pipeline(&self) -> Option { match *self { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { ref old_reloader, .. } => match *old_reloader { NeedsToReload::No(pipeline_id) => Some(pipeline_id), @@ -225,7 +225,7 @@ impl SessionHistoryDiff { /// Returns the new pipeline id if that pipeline is still alive, otherwise returns `None` pub fn alive_new_pipeline(&self) -> Option { match *self { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { ref new_reloader, .. } => match *new_reloader { NeedsToReload::No(pipeline_id) => Some(pipeline_id), @@ -242,7 +242,7 @@ impl SessionHistoryDiff { reloader: &NeedsToReload, ) { match *self { - SessionHistoryDiff::BrowsingContextDiff { + SessionHistoryDiff::BrowsingContext { ref mut old_reloader, ref mut new_reloader, .. @@ -254,7 +254,7 @@ impl SessionHistoryDiff { *new_reloader = reloader.clone(); } }, - SessionHistoryDiff::PipelineDiff { + SessionHistoryDiff::Pipeline { ref mut pipeline_reloader, .. } => { @@ -262,7 +262,7 @@ impl SessionHistoryDiff { *pipeline_reloader = reloader.clone(); } }, - SessionHistoryDiff::HashDiff { + SessionHistoryDiff::Hash { ref mut pipeline_reloader, .. } => { diff --git a/components/constellation/timer_scheduler.rs b/components/constellation/timer_scheduler.rs index f56808b56f1..5e6071c8301 100644 --- a/components/constellation/timer_scheduler.rs +++ b/components/constellation/timer_scheduler.rs @@ -30,7 +30,7 @@ impl PartialOrd for ScheduledEvent { impl Eq for ScheduledEvent {} impl PartialEq for ScheduledEvent { fn eq(&self, other: &ScheduledEvent) -> bool { - self as *const ScheduledEvent == other as *const ScheduledEvent + std::ptr::eq(self, other) } }