Fixed the .clone() warnings. (#31819)

This commit is contained in:
Aarya Khandelwal 2024-03-22 11:11:17 +05:30 committed by GitHub
parent 95e69fe4ff
commit 9b26dca141
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 76 additions and 93 deletions

View file

@ -1537,7 +1537,7 @@ impl GlobalScope {
// If this is a newly-created port, let the constellation immediately know.
let port_impl = MessagePortImpl::new(dom_port.message_port_id().clone());
message_ports.insert(
dom_port.message_port_id().clone(),
*dom_port.message_port_id(),
ManagedMessagePort {
port_impl: Some(port_impl),
dom_port: Dom::from_ref(dom_port),
@ -1548,8 +1548,8 @@ impl GlobalScope {
let _ = self
.script_to_constellation_chan()
.send(ScriptMsg::NewMessagePort(
router_id.clone(),
dom_port.message_port_id().clone(),
*router_id,
*dom_port.message_port_id(),
));
};
} else {
@ -1674,9 +1674,7 @@ impl GlobalScope {
.get(blob_id)
.expect("get_blob_bytes for an unknown blob.");
match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => {
Some((parent.clone(), rel_pos.clone()))
},
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
_ => None,
}
} else {
@ -1739,9 +1737,7 @@ impl GlobalScope {
.get(blob_id)
.expect("get_blob_bytes_or_file_id for an unknown blob.");
match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => {
Some((parent.clone(), rel_pos.clone()))
},
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
_ => None,
}
} else {
@ -1811,9 +1807,7 @@ impl GlobalScope {
.get(blob_id)
.expect("get_blob_size called for a unknown blob.");
match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => {
Some((parent.clone(), rel_pos.clone()))
},
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
_ => None,
}
};
@ -1857,9 +1851,7 @@ impl GlobalScope {
blob_info.has_url = true;
match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => {
Some((parent.clone(), rel_pos.clone()))
},
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
_ => None,
}
};
@ -1904,7 +1896,7 @@ impl GlobalScope {
let (tx, rx) = profile_ipc::channel(self.time_profiler_chan().clone()).unwrap();
let msg = FileManagerThreadMsg::AddSlicedURLEntry(
parent_file_id.clone(),
*parent_file_id,
rel_pos.clone(),
tx,
origin.clone(),
@ -1913,7 +1905,7 @@ impl GlobalScope {
match rx.recv().expect("File manager thread is down.") {
Ok(new_id) => {
*blob_info.blob_impl.blob_data_mut() = BlobData::File(FileBlob::new(
new_id.clone(),
new_id,
None,
None,
rel_pos.to_abs_range(parent_len as usize).len() as u64,
@ -1977,7 +1969,7 @@ impl GlobalScope {
self.send_to_file_manager(msg);
*blob_info.blob_impl.blob_data_mut() = BlobData::File(FileBlob::new(
id.clone(),
id,
None,
Some(bytes.to_vec()),
bytes.len() as u64,
@ -2295,7 +2287,7 @@ impl GlobalScope {
pub fn issue_page_warning(&self, warning: &str) {
if let Some(ref chan) = self.devtools_chan {
let _ = chan.send(ScriptToDevtoolsControlMsg::ReportPageError(
self.pipeline_id.clone(),
self.pipeline_id,
PageError {
type_: "PageError".to_string(),
errorMessage: warning.to_string(),
@ -2483,7 +2475,7 @@ impl GlobalScope {
} else if self.is::<Window>() {
if let Some(ref chan) = self.devtools_chan {
let _ = chan.send(ScriptToDevtoolsControlMsg::ReportPageError(
self.pipeline_id.clone(),
self.pipeline_id,
PageError {
type_: "PageError".to_string(),
errorMessage: error_info.message.clone(),

View file

@ -41,10 +41,10 @@ pub struct WebGPUContextId(pub u64);
impl Clone for GPUCanvasConfiguration {
fn clone(&self) -> Self {
Self {
alphaMode: self.alphaMode.clone(),
alphaMode: self.alphaMode,
device: self.device.clone(),
format: self.format.clone(),
usage: self.usage.clone(),
format: self.format,
usage: self.usage,
viewFormats: self.viewFormats.clone(),
}
}

View file

@ -1698,7 +1698,7 @@ impl VirtualMethods for HTMLFormElement {
.borrow()
.iter()
.filter(|c| !c.is_in_same_home_subtree(self))
.map(|c| c.clone()),
.cloned(),
);
for control in to_reset.iter() {

View file

@ -1411,7 +1411,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
}
fn image_density(self) -> Option<f64> {
self.current_request().current_pixel_density.clone()
self.current_request().current_pixel_density
}
fn get_width(self) -> LengthOrPercentageOrAuto {

View file

@ -1357,7 +1357,7 @@ impl HTMLMediaElement {
HTMLMediaElementTypeId::HTMLVideoElement => Some(self.video_renderer.clone()),
};
let audio_renderer = self.audio_renderer.borrow().as_ref().map(|r| r.clone());
let audio_renderer = self.audio_renderer.borrow().as_ref().cloned();
let pipeline_id = window.pipeline_id();
let client_context_id =
@ -2470,7 +2470,7 @@ impl LayoutHTMLMediaElementHelpers for LayoutDom<'_, HTMLMediaElement> {
fn data(self) -> HTMLMediaData {
let media = unsafe { &*self.unsafe_get() };
HTMLMediaData {
current_frame: media.video_renderer.lock().unwrap().current_frame.clone(),
current_frame: media.video_renderer.lock().unwrap().current_frame,
}
}
}

View file

@ -105,7 +105,7 @@ unsafe extern "C" fn off_thread_compilation_callback(
let url = context.url.clone();
let final_url = context.final_url.clone();
let script_element = context.script_element.clone();
let script_kind = context.script_kind.clone();
let script_kind = context.script_kind;
let script = replace(&mut context.script_text, String::new());
let fetch_options = context.fetch_options.clone();
@ -211,7 +211,7 @@ impl HTMLScriptElement {
}
pub fn get_script_id(&self) -> ScriptId {
self.id.clone()
self.id
}
}
@ -402,7 +402,7 @@ impl FetchResponseListener for ClassicContext {
// Step 6, response is an error.
finish_fetching_a_classic_script(
&*self.elem.root(),
self.kind.clone(),
self.kind,
self.url.clone(),
Err(NoTrace(err.clone())),
);
@ -438,7 +438,7 @@ impl FetchResponseListener for ClassicContext {
let context = Box::new(OffThreadCompilationContext {
script_element: self.elem.clone(),
script_kind: self.kind.clone(),
script_kind: self.kind,
final_url,
url: self.url.clone(),
task_source: global.dom_manipulation_task_source(),
@ -464,7 +464,7 @@ impl FetchResponseListener for ClassicContext {
self.fetch_options.clone(),
ScriptType::Classic,
);
finish_fetching_a_classic_script(&*elem, self.kind.clone(), self.url.clone(), Ok(load));
finish_fetching_a_classic_script(&*elem, self.kind, self.url.clone(), Ok(load));
}
}
@ -816,7 +816,7 @@ impl HTMLScriptElement {
Rc::clone(&text_rc),
base_url.clone(),
options.clone(),
script_type.clone(),
script_type,
));
// Step 27-2.
@ -850,7 +850,7 @@ impl HTMLScriptElement {
ModuleOwner::Window(Trusted::new(self)),
text_rc,
base_url.clone(),
self.id.clone(),
self.id,
options,
);
},

View file

@ -40,10 +40,7 @@ impl MessageChannel {
incumbent.track_message_port(&*port2, None);
// Step 3
incumbent.entangle_ports(
port1.message_port_id().clone(),
port2.message_port_id().clone(),
);
incumbent.entangle_ports(*port1.message_port_id(), *port2.message_port_id());
// Steps 4-6
reflect_dom_object_with_proto(

View file

@ -151,7 +151,7 @@ impl MessagePort {
// Have the global proxy this call to the corresponding MessagePortImpl.
self.global()
.post_messageport_msg(self.message_port_id().clone(), task);
.post_messageport_msg(*self.message_port_id(), task);
Ok(())
}
}
@ -176,15 +176,15 @@ impl Transferable for MessagePort {
// 2. Store the transferred object at a given key.
if let Some(ports) = port_impls.as_mut() {
ports.insert(id.clone(), transferred_port);
ports.insert(*id, transferred_port);
} else {
let mut ports = HashMap::new();
ports.insert(id.clone(), transferred_port);
ports.insert(*id, transferred_port);
*port_impls = Some(ports);
}
let PipelineNamespaceId(name_space) = id.clone().namespace_id;
let MessagePortIndex(index) = id.clone().index;
let PipelineNamespaceId(name_space) = (*id).namespace_id;
let MessagePortIndex(index) = (*id).index;
let index = index.get();
let mut big: [u8; 8] = [0; 8];
@ -251,7 +251,7 @@ impl Transferable for MessagePort {
};
let transferred_port =
MessagePort::new_transferred(&*owner, id.clone(), port_impl.entangled_port_id());
MessagePort::new_transferred(&*owner, id, port_impl.entangled_port_id());
owner.track_message_port(&transferred_port, Some(port_impl));
return_object.set(transferred_port.reflector().rootable().get());

View file

@ -80,7 +80,7 @@ impl PerformanceEntryList {
.as_ref()
.map_or(true, |type_| *e.entry_type() == *type_)
})
.map(|e| e.clone())
.cloned()
.collect::<Vec<DomRoot<PerformanceEntry>>>();
res.sort_by(|a, b| {
a.start_time()

View file

@ -109,7 +109,7 @@ impl PerformanceNavigationTimingMethods for PerformanceNavigationTiming {
// https://w3c.github.io/navigation-timing/#dom-performancenavigationtiming-type
fn Type(&self) -> NavigationType {
self.nav_type.clone()
self.nav_type
}
// https://w3c.github.io/navigation-timing/#dom-performancenavigationtiming-redirectcount

View file

@ -186,7 +186,7 @@ impl PerformanceObserverMethods for PerformanceObserver {
let entry_types = entry_types
.iter()
.filter(|e| VALID_ENTRY_TYPES.contains(&e.as_ref()))
.map(|e| e.clone())
.cloned()
.collect::<Vec<DOMString>>();
// Step 6.3

View file

@ -310,7 +310,7 @@ pub fn get_descriptor_permission_state(
.borrow()
.get(&permission_name.to_string())
{
return prev_result.clone();
return *prev_result;
}
// Store the invocation result

View file

@ -208,16 +208,12 @@ impl Request {
// Step 15
if let Some(init_referrerpolicy) = init.referrerPolicy.as_ref() {
let init_referrer_policy = init_referrerpolicy.clone().into();
let init_referrer_policy = (*init_referrerpolicy).into();
request.referrer_policy = Some(init_referrer_policy);
}
// Step 16
let mode = init
.mode
.as_ref()
.map(|m| m.clone().into())
.or(fallback_mode);
let mode = init.mode.as_ref().map(|m| (*m).into()).or(fallback_mode);
// Step 17
if let Some(NetTraitsRequestMode::Navigate) = mode {
@ -231,13 +227,13 @@ impl Request {
// Step 19
if let Some(init_credentials) = init.credentials.as_ref() {
let credentials = init_credentials.clone().into();
let credentials = (*init_credentials).into();
request.credentials_mode = credentials;
}
// Step 20
if let Some(init_cache) = init.cache.as_ref() {
let cache = init_cache.clone().into();
let cache = (*init_cache).into();
request.cache_mode = cache;
}
@ -252,7 +248,7 @@ impl Request {
// Step 22
if let Some(init_redirect) = init.redirect.as_ref() {
let redirect = init_redirect.clone().into();
let redirect = (*init_redirect).into();
request.redirect_mode = redirect;
}

View file

@ -334,8 +334,8 @@ impl ResponseMethods for Response {
// https://fetch.spec.whatwg.org/#concept-response-clone
// Instead of storing a net_traits::Response internally, we
// only store the relevant fields, and only clone them here
*new_response.response_type.borrow_mut() = self.response_type.borrow().clone();
*new_response.status.borrow_mut() = self.status.borrow().clone();
*new_response.response_type.borrow_mut() = *self.response_type.borrow();
*new_response.status.borrow_mut() = *self.status.borrow();
*new_response.raw_status.borrow_mut() = self.raw_status.borrow().clone();
*new_response.url.borrow_mut() = self.url.borrow().clone();
*new_response.url_list.borrow_mut() = self.url_list.borrow().clone();

View file

@ -112,7 +112,7 @@ impl RTCIceCandidateMethods for RTCIceCandidate {
/// <https://w3c.github.io/webrtc-pc/#dom-rtcicecandidate-sdpmlineindex>
fn GetSdpMLineIndex(&self) -> Option<u16> {
self.sdp_m_line_index.clone()
self.sdp_m_line_index
}
/// <https://w3c.github.io/webrtc-pc/#dom-rtcicecandidate-usernamefragment>
@ -125,7 +125,7 @@ impl RTCIceCandidateMethods for RTCIceCandidate {
RTCIceCandidateInit {
candidate: self.candidate.clone(),
sdpMid: self.sdp_m_id.clone(),
sdpMLineIndex: self.sdp_m_line_index.clone(),
sdpMLineIndex: self.sdp_m_line_index,
usernameFragment: self.username_fragment.clone(),
}
}

View file

@ -1000,7 +1000,7 @@ impl TestBindingMethods for TestBinding {
resolve.map(SimpleHandler::new),
reject.map(SimpleHandler::new),
);
let p = Promise::new_in_current_realm(comp.clone());
let p = Promise::new_in_current_realm(comp);
p.append_native_handler(&handler, comp);
return p;

View file

@ -29,13 +29,13 @@ impl Iterable for TestBindingPairIterable {
self.map.borrow().len() as u32
}
fn get_value_at_index(&self, index: u32) -> u32 {
self.map
*self
.map
.borrow()
.iter()
.nth(index as usize)
.map(|a| &a.1)
.unwrap()
.clone()
}
fn get_key_at_index(&self, index: u32) -> DOMString {
self.map

View file

@ -33,7 +33,7 @@ impl TransitionEvent {
TransitionEvent {
event: Event::new_inherited(),
property_name: Atom::from(init.propertyName.clone()),
elapsed_time: init.elapsedTime.clone(),
elapsed_time: init.elapsedTime,
pseudo_element: init.pseudoElement.clone(),
}
}
@ -88,7 +88,7 @@ impl TransitionEventMethods for TransitionEvent {
// https://drafts.csswg.org/css-transitions/#Events-TransitionEvent-elapsedTime
fn ElapsedTime(&self) -> Finite<f32> {
self.elapsed_time.clone()
self.elapsed_time
}
// https://drafts.csswg.org/css-transitions/#Events-TransitionEvent-pseudoElement

View file

@ -235,7 +235,7 @@ impl WebGLRenderbuffer {
),
);
let samples = receiver.recv().unwrap();
if sample_count < 0 || sample_count > samples.get(0).cloned().unwrap_or(0) {
if sample_count < 0 || sample_count > samples.first().cloned().unwrap_or(0) {
return Err(WebGLError::InvalidOperation);
}
}

View file

@ -2329,7 +2329,7 @@ impl Window {
}
pub fn set_page_clip_rect_with_new_viewport(&self, viewport: UntypedRect<f32>) -> bool {
let rect = f32_rect_to_au_rect(viewport.clone());
let rect = f32_rect_to_au_rect(viewport);
self.current_viewport.set(rect);
// We use a clipping rectangle that is five times the size of the of the viewport,
// so that we don't collect display list items for areas too far outside the viewport,

View file

@ -220,7 +220,7 @@ impl WorkerGlobalScope {
}
pub fn get_worker_id(&self) -> WorkerId {
self.worker_id.clone()
self.worker_id
}
pub fn task_canceller(&self) -> TaskCanceller {

View file

@ -153,7 +153,7 @@ impl WorkletMethods for Worklet {
self.window.origin().immutable().clone(),
global.api_base_url(),
module_url_record,
options.credentials.clone(),
options.credentials,
pending_tasks_struct,
&promise,
);

View file

@ -720,7 +720,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
.credentials_mode(credentials_mode)
.use_url_credentials(use_url_credentials)
.origin(self.global().origin().immutable().clone())
.referrer_policy(self.referrer_policy.clone())
.referrer_policy(self.referrer_policy)
.pipeline_id(Some(self.global().pipeline_id()));
// step 4 (second half)