mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
clippy: Fix clone-on-copy warnings (#31877)
This commit is contained in:
parent
5f7baf31c2
commit
b55d0a2053
9 changed files with 41 additions and 47 deletions
|
@ -397,7 +397,7 @@ impl Animations {
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
event_type,
|
event_type,
|
||||||
node: key.node,
|
node: key.node,
|
||||||
pseudo_element: key.pseudo_element.clone(),
|
pseudo_element: key.pseudo_element,
|
||||||
property_or_animation_name: transition
|
property_or_animation_name: transition
|
||||||
.property_animation
|
.property_animation
|
||||||
.property_id()
|
.property_id()
|
||||||
|
@ -450,7 +450,7 @@ impl Animations {
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
event_type,
|
event_type,
|
||||||
node: key.node,
|
node: key.node,
|
||||||
pseudo_element: key.pseudo_element.clone(),
|
pseudo_element: key.pseudo_element,
|
||||||
property_or_animation_name: animation.name.to_string(),
|
property_or_animation_name: animation.name.to_string(),
|
||||||
elapsed_time,
|
elapsed_time,
|
||||||
});
|
});
|
||||||
|
|
|
@ -287,7 +287,7 @@ struct TransmitBodyPromiseHandler {
|
||||||
impl Callback for TransmitBodyPromiseHandler {
|
impl Callback for TransmitBodyPromiseHandler {
|
||||||
/// Step 5 of <https://fetch.spec.whatwg.org/#concept-request-transmit-body>
|
/// Step 5 of <https://fetch.spec.whatwg.org/#concept-request-transmit-body>
|
||||||
fn callback(&self, cx: JSContext, v: HandleValue, _realm: InRealm) {
|
fn callback(&self, cx: JSContext, v: HandleValue, _realm: InRealm) {
|
||||||
let is_done = match get_read_promise_done(cx.clone(), &v) {
|
let is_done = match get_read_promise_done(cx, &v) {
|
||||||
Ok(is_done) => is_done,
|
Ok(is_done) => is_done,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Step 5.5, the "otherwise" steps.
|
// Step 5.5, the "otherwise" steps.
|
||||||
|
@ -304,7 +304,7 @@ impl Callback for TransmitBodyPromiseHandler {
|
||||||
return self.stream.stop_reading();
|
return self.stream.stop_reading();
|
||||||
}
|
}
|
||||||
|
|
||||||
let chunk = match get_read_promise_bytes(cx.clone(), &v) {
|
let chunk = match get_read_promise_bytes(cx, &v) {
|
||||||
Ok(chunk) => chunk,
|
Ok(chunk) => chunk,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Step 5.5, the "otherwise" steps.
|
// Step 5.5, the "otherwise" steps.
|
||||||
|
@ -656,7 +656,7 @@ impl Callback for ConsumeBodyPromiseHandler {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("ConsumeBodyPromiseHandler has no stream in callback.");
|
.expect("ConsumeBodyPromiseHandler has no stream in callback.");
|
||||||
|
|
||||||
let is_done = match get_read_promise_done(cx.clone(), &v) {
|
let is_done = match get_read_promise_done(cx, &v) {
|
||||||
Ok(is_done) => is_done,
|
Ok(is_done) => is_done,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
stream.stop_reading();
|
stream.stop_reading();
|
||||||
|
@ -667,9 +667,9 @@ impl Callback for ConsumeBodyPromiseHandler {
|
||||||
|
|
||||||
if is_done {
|
if is_done {
|
||||||
// When read is fulfilled with an object whose done property is true.
|
// When read is fulfilled with an object whose done property is true.
|
||||||
self.resolve_result_promise(cx.clone());
|
self.resolve_result_promise(cx);
|
||||||
} else {
|
} else {
|
||||||
let chunk = match get_read_promise_bytes(cx.clone(), &v) {
|
let chunk = match get_read_promise_bytes(cx, &v) {
|
||||||
Ok(chunk) => chunk,
|
Ok(chunk) => chunk,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
stream.stop_reading();
|
stream.stop_reading();
|
||||||
|
|
|
@ -509,9 +509,7 @@ impl<T> Clone for Dom<T> {
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
assert_in_script();
|
assert_in_script();
|
||||||
Dom {
|
Dom { ptr: self.ptr }
|
||||||
ptr: self.ptr.clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ unsafe fn read_blob(
|
||||||
&mut index as *mut u32
|
&mut index as *mut u32
|
||||||
));
|
));
|
||||||
let storage_key = StorageKey { index, name_space };
|
let storage_key = StorageKey { index, name_space };
|
||||||
if <Blob as Serializable>::deserialize(owner, sc_holder, storage_key.clone()).is_ok() {
|
if <Blob as Serializable>::deserialize(owner, sc_holder, storage_key).is_ok() {
|
||||||
let blobs = match sc_holder {
|
let blobs = match sc_holder {
|
||||||
StructuredDataHolder::Read { blobs, .. } => blobs,
|
StructuredDataHolder::Read { blobs, .. } => blobs,
|
||||||
_ => panic!("Unexpected variant of StructuredDataHolder"),
|
_ => panic!("Unexpected variant of StructuredDataHolder"),
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl Serializable for Blob {
|
||||||
_ => panic!("Unexpected variant of StructuredDataHolder"),
|
_ => panic!("Unexpected variant of StructuredDataHolder"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let blob_id = self.blob_id.clone();
|
let blob_id = self.blob_id;
|
||||||
|
|
||||||
// 1. Get a clone of the blob impl.
|
// 1. Get a clone of the blob impl.
|
||||||
let blob_impl = self.global().serialize_blob(&blob_id);
|
let blob_impl = self.global().serialize_blob(&blob_id);
|
||||||
|
@ -126,7 +126,7 @@ impl Serializable for Blob {
|
||||||
|
|
||||||
// 2. Store the object at a given key.
|
// 2. Store the object at a given key.
|
||||||
let blobs = blob_impls.get_or_insert_with(|| HashMap::new());
|
let blobs = blob_impls.get_or_insert_with(|| HashMap::new());
|
||||||
blobs.insert(new_blob_id.clone(), blob_impl);
|
blobs.insert(new_blob_id, blob_impl);
|
||||||
|
|
||||||
let PipelineNamespaceId(name_space) = new_blob_id.namespace_id;
|
let PipelineNamespaceId(name_space) = new_blob_id.namespace_id;
|
||||||
let BlobIndex(index) = new_blob_id.index;
|
let BlobIndex(index) = new_blob_id.index;
|
||||||
|
@ -152,10 +152,9 @@ impl Serializable for Blob {
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
// 1. Re-build the key for the storage location
|
// 1. Re-build the key for the storage location
|
||||||
// of the serialized object.
|
// of the serialized object.
|
||||||
let namespace_id = PipelineNamespaceId(storage_key.name_space.clone());
|
let namespace_id = PipelineNamespaceId(storage_key.name_space);
|
||||||
let index = BlobIndex(
|
let index =
|
||||||
NonZeroU32::new(storage_key.index.clone()).expect("Deserialized blob index is zero"),
|
BlobIndex(NonZeroU32::new(storage_key.index).expect("Deserialized blob index is zero"));
|
||||||
);
|
|
||||||
|
|
||||||
let id = BlobId {
|
let id = BlobId {
|
||||||
namespace_id,
|
namespace_id,
|
||||||
|
@ -245,7 +244,7 @@ impl BlobMethods for Blob {
|
||||||
let type_string =
|
let type_string =
|
||||||
normalize_type_string(&content_type.unwrap_or(DOMString::from("")).to_string());
|
normalize_type_string(&content_type.unwrap_or(DOMString::from("")).to_string());
|
||||||
let rel_pos = RelativePos::from_opts(start, end);
|
let rel_pos = RelativePos::from_opts(start, end);
|
||||||
let blob_impl = BlobImpl::new_sliced(rel_pos, self.blob_id.clone(), type_string);
|
let blob_impl = BlobImpl::new_sliced(rel_pos, self.blob_id, type_string);
|
||||||
Blob::new(&self.global(), blob_impl)
|
Blob::new(&self.global(), blob_impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ impl BluetoothAdvertisingEvent {
|
||||||
) -> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
) -> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
||||||
let global = window.upcast::<GlobalScope>();
|
let global = window.upcast::<GlobalScope>();
|
||||||
let name = init.name.clone();
|
let name = init.name.clone();
|
||||||
let appearance = init.appearance.clone();
|
let appearance = init.appearance;
|
||||||
let txPower = init.txPower.clone();
|
let txPower = init.txPower;
|
||||||
let rssi = init.rssi.clone();
|
let rssi = init.rssi;
|
||||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||||
Ok(BluetoothAdvertisingEvent::new(
|
Ok(BluetoothAdvertisingEvent::new(
|
||||||
|
|
|
@ -257,7 +257,7 @@ impl CSSStyleDeclaration {
|
||||||
return DOMString::new();
|
return DOMString::new();
|
||||||
}
|
}
|
||||||
let addr = node.to_trusted_node_address();
|
let addr = node.to_trusted_node_address();
|
||||||
window_from_node(node).resolved_style_query(addr, self.pseudo.clone(), property)
|
window_from_node(node).resolved_style_query(addr, self.pseudo, property)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> {
|
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> {
|
||||||
Self::new(global, ro.is2D(), ro.matrix().clone())
|
Self::new(global, ro.is2D(), *ro.matrix())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-fromfloat32array
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-fromfloat32array
|
||||||
|
|
|
@ -556,7 +556,7 @@ impl MessageListener {
|
||||||
|
|
||||||
for (id, buffer) in ports.into_iter() {
|
for (id, buffer) in ports.into_iter() {
|
||||||
if global.is_managing_port(&id) {
|
if global.is_managing_port(&id) {
|
||||||
succeeded.push(id.clone());
|
succeeded.push(id);
|
||||||
global.complete_port_transfer(id, buffer);
|
global.complete_port_transfer(id, buffer);
|
||||||
} else {
|
} else {
|
||||||
failed.insert(id, buffer);
|
failed.insert(id, buffer);
|
||||||
|
@ -804,7 +804,7 @@ impl GlobalScope {
|
||||||
/// The message-port router Id of the global, if any
|
/// The message-port router Id of the global, if any
|
||||||
fn port_router_id(&self) -> Option<MessagePortRouterId> {
|
fn port_router_id(&self) -> Option<MessagePortRouterId> {
|
||||||
if let MessagePortState::Managed(id, _message_ports) = &*self.message_port_state.borrow() {
|
if let MessagePortState::Managed(id, _message_ports) = &*self.message_port_state.borrow() {
|
||||||
Some(id.clone())
|
Some(*id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -869,8 +869,7 @@ impl GlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.1 -> 2.5
|
// Step 2.1 -> 2.5
|
||||||
let new_registration =
|
let new_registration = ServiceWorkerRegistration::new(self, scope.clone(), registration_id);
|
||||||
ServiceWorkerRegistration::new(self, scope.clone(), registration_id.clone());
|
|
||||||
|
|
||||||
// Step 2.6
|
// Step 2.6
|
||||||
if let Some(worker_id) = installing_worker {
|
if let Some(worker_id) = installing_worker {
|
||||||
|
@ -905,8 +904,7 @@ impl GlobalScope {
|
||||||
} else {
|
} else {
|
||||||
// Step 2.1
|
// Step 2.1
|
||||||
// TODO: step 2.2, worker state.
|
// TODO: step 2.2, worker state.
|
||||||
let new_worker =
|
let new_worker = ServiceWorker::new(self, script_url.clone(), scope.clone(), worker_id);
|
||||||
ServiceWorker::new(self, script_url.clone(), scope.clone(), worker_id.clone());
|
|
||||||
|
|
||||||
// Step 2.3
|
// Step 2.3
|
||||||
workers.insert(worker_id, Dom::from_ref(&*new_worker));
|
workers.insert(worker_id, Dom::from_ref(&*new_worker));
|
||||||
|
@ -975,7 +973,7 @@ impl GlobalScope {
|
||||||
{
|
{
|
||||||
let _ = self
|
let _ = self
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::RemoveMessagePortRouter(router_id.clone()));
|
.send(ScriptMsg::RemoveMessagePortRouter(*router_id));
|
||||||
}
|
}
|
||||||
*self.message_port_state.borrow_mut() = MessagePortState::UnManaged;
|
*self.message_port_state.borrow_mut() = MessagePortState::UnManaged;
|
||||||
}
|
}
|
||||||
|
@ -989,7 +987,7 @@ impl GlobalScope {
|
||||||
let _ =
|
let _ =
|
||||||
self.script_to_constellation_chan()
|
self.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::RemoveBroadcastChannelRouter(
|
.send(ScriptMsg::RemoveBroadcastChannelRouter(
|
||||||
router_id.clone(),
|
*router_id,
|
||||||
self.origin().immutable().clone(),
|
self.origin().immutable().clone(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1008,8 +1006,8 @@ impl GlobalScope {
|
||||||
},
|
},
|
||||||
Some(managed_port) => {
|
Some(managed_port) => {
|
||||||
if let Some(port_impl) = managed_port.port_impl.as_mut() {
|
if let Some(port_impl) = managed_port.port_impl.as_mut() {
|
||||||
managed_port.dom_port.entangle(entangled_id.clone());
|
managed_port.dom_port.entangle(*entangled_id);
|
||||||
port_impl.entangle(entangled_id.clone());
|
port_impl.entangle(*entangled_id);
|
||||||
} else {
|
} else {
|
||||||
panic!("managed-port has no port-impl.");
|
panic!("managed-port has no port-impl.");
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1052,7 @@ impl GlobalScope {
|
||||||
port_impl.set_has_been_shipped();
|
port_impl.set_has_been_shipped();
|
||||||
let _ = self
|
let _ = self
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::MessagePortShipped(port_id.clone()));
|
.send(ScriptMsg::MessagePortShipped(*port_id));
|
||||||
port_impl
|
port_impl
|
||||||
} else {
|
} else {
|
||||||
panic!("mark_port_as_transferred called on a global not managing any ports.");
|
panic!("mark_port_as_transferred called on a global not managing any ports.");
|
||||||
|
@ -1078,7 +1076,7 @@ impl GlobalScope {
|
||||||
};
|
};
|
||||||
if let Some(message_buffer) = message_buffer {
|
if let Some(message_buffer) = message_buffer {
|
||||||
for task in message_buffer {
|
for task in message_buffer {
|
||||||
let port_id = port_id.clone();
|
let port_id = *port_id;
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let _ = self.port_message_queue().queue(
|
let _ = self.port_message_queue().queue(
|
||||||
task!(process_pending_port_messages: move || {
|
task!(process_pending_port_messages: move || {
|
||||||
|
@ -1172,7 +1170,7 @@ impl GlobalScope {
|
||||||
// we could skip the hop to the constellation.
|
// we could skip the hop to the constellation.
|
||||||
let _ = self
|
let _ = self
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::ScheduleBroadcast(router_id.clone(), msg));
|
.send(ScriptMsg::ScheduleBroadcast(*router_id, msg));
|
||||||
} else {
|
} else {
|
||||||
panic!("Attemps to broadcast a message via global not managing any channels.");
|
panic!("Attemps to broadcast a message via global not managing any channels.");
|
||||||
}
|
}
|
||||||
|
@ -1324,7 +1322,7 @@ impl GlobalScope {
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(id, managed_port)| {
|
.filter_map(|(id, managed_port)| {
|
||||||
if managed_port.pending {
|
if managed_port.pending {
|
||||||
Some(id.clone())
|
Some(*id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1342,7 +1340,7 @@ impl GlobalScope {
|
||||||
let _ =
|
let _ =
|
||||||
self.script_to_constellation_chan()
|
self.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::CompleteMessagePortTransfer(
|
.send(ScriptMsg::CompleteMessagePortTransfer(
|
||||||
router_id.clone(),
|
*router_id,
|
||||||
to_be_added,
|
to_be_added,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1363,8 +1361,8 @@ impl GlobalScope {
|
||||||
// and to forward this message to the script-process where the entangled is found.
|
// and to forward this message to the script-process where the entangled is found.
|
||||||
let _ = self
|
let _ = self
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::RemoveMessagePort(id.clone()));
|
.send(ScriptMsg::RemoveMessagePort(*id));
|
||||||
Some(id.clone())
|
Some(*id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1394,7 +1392,7 @@ impl GlobalScope {
|
||||||
if channels.is_empty() {
|
if channels.is_empty() {
|
||||||
let _ = self.script_to_constellation_chan().send(
|
let _ = self.script_to_constellation_chan().send(
|
||||||
ScriptMsg::RemoveBroadcastChannelNameInRouter(
|
ScriptMsg::RemoveBroadcastChannelNameInRouter(
|
||||||
router_id.clone(),
|
*router_id,
|
||||||
name.to_string(),
|
name.to_string(),
|
||||||
self.origin().immutable().clone(),
|
self.origin().immutable().clone(),
|
||||||
),
|
),
|
||||||
|
@ -1442,7 +1440,7 @@ impl GlobalScope {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let router_id = BroadcastChannelRouterId::new();
|
let router_id = BroadcastChannelRouterId::new();
|
||||||
*current_state = BroadcastChannelState::Managed(router_id.clone(), HashMap::new());
|
*current_state = BroadcastChannelState::Managed(router_id, HashMap::new());
|
||||||
let _ = self
|
let _ = self
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::NewBroadcastChannelRouter(
|
.send(ScriptMsg::NewBroadcastChannelRouter(
|
||||||
|
@ -1456,7 +1454,7 @@ impl GlobalScope {
|
||||||
let entry = channels.entry(dom_channel.Name()).or_insert_with(|| {
|
let entry = channels.entry(dom_channel.Name()).or_insert_with(|| {
|
||||||
let _ = self.script_to_constellation_chan().send(
|
let _ = self.script_to_constellation_chan().send(
|
||||||
ScriptMsg::NewBroadcastChannelNameInRouter(
|
ScriptMsg::NewBroadcastChannelNameInRouter(
|
||||||
router_id.clone(),
|
*router_id,
|
||||||
dom_channel.Name().to_string(),
|
dom_channel.Name().to_string(),
|
||||||
self.origin().immutable().clone(),
|
self.origin().immutable().clone(),
|
||||||
),
|
),
|
||||||
|
@ -1498,8 +1496,7 @@ impl GlobalScope {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let router_id = MessagePortRouterId::new();
|
let router_id = MessagePortRouterId::new();
|
||||||
*current_state =
|
*current_state = MessagePortState::Managed(router_id, HashMapTracedValues::new());
|
||||||
MessagePortState::Managed(router_id.clone(), HashMapTracedValues::new());
|
|
||||||
let _ = self
|
let _ = self
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::NewMessagePortRouter(
|
.send(ScriptMsg::NewMessagePortRouter(
|
||||||
|
@ -1514,7 +1511,7 @@ impl GlobalScope {
|
||||||
// and only ask the constellation to complete the transfer
|
// and only ask the constellation to complete the transfer
|
||||||
// if they're not re-shipped in the current task.
|
// if they're not re-shipped in the current task.
|
||||||
message_ports.insert(
|
message_ports.insert(
|
||||||
dom_port.message_port_id().clone(),
|
*dom_port.message_port_id(),
|
||||||
ManagedMessagePort {
|
ManagedMessagePort {
|
||||||
port_impl: Some(port_impl),
|
port_impl: Some(port_impl),
|
||||||
dom_port: Dom::from_ref(dom_port),
|
dom_port: Dom::from_ref(dom_port),
|
||||||
|
@ -1535,7 +1532,7 @@ impl GlobalScope {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// If this is a newly-created port, let the constellation immediately know.
|
// If this is a newly-created port, let the constellation immediately know.
|
||||||
let port_impl = MessagePortImpl::new(dom_port.message_port_id().clone());
|
let port_impl = MessagePortImpl::new(*dom_port.message_port_id());
|
||||||
message_ports.insert(
|
message_ports.insert(
|
||||||
*dom_port.message_port_id(),
|
*dom_port.message_port_id(),
|
||||||
ManagedMessagePort {
|
ManagedMessagePort {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue