mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
clippy: Fix warnings in components/constellation
(#31610)
* clippy: fix warnings in components/constellation * fix: review comments
This commit is contained in:
parent
11c16adcd1
commit
7f1ef4c7fe
7 changed files with 114 additions and 112 deletions
|
@ -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<SessionHistoryDiff> {
|
||||
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<PipelineId> {
|
||||
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<PipelineId> {
|
||||
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,
|
||||
..
|
||||
} => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue