mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix dereferencing a tuple pattern warnings (#31811)
This commit is contained in:
parent
b22281d94f
commit
694e86ecff
14 changed files with 29 additions and 37 deletions
|
@ -39,7 +39,7 @@ impl<T: Float> Deref for Finite<T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
let &Finite(ref value) = self;
|
let Finite(value) = self;
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ pub unsafe fn find_enum_value<'a, T>(
|
||||||
pairs
|
pairs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|&&(key, _)| search == *key)
|
.find(|&&(key, _)| search == *key)
|
||||||
.map(|&(_, ref ev)| ev),
|
.map(|(_, ev)| ev),
|
||||||
search,
|
search,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ impl Bluetooth {
|
||||||
// Step 2.2: There are no requiredServiceUUIDS, we scan for all devices.
|
// Step 2.2: There are no requiredServiceUUIDS, we scan for all devices.
|
||||||
let mut uuid_filters = vec![];
|
let mut uuid_filters = vec![];
|
||||||
|
|
||||||
if let &Some(ref filters) = filters {
|
if let Some(filters) = filters {
|
||||||
// Step 2.1.
|
// Step 2.1.
|
||||||
if filters.is_empty() {
|
if filters.is_empty() {
|
||||||
p.reject_error(Type(FILTER_EMPTY_ERROR.to_owned()));
|
p.reject_error(Type(FILTER_EMPTY_ERROR.to_owned()));
|
||||||
|
|
|
@ -627,7 +627,7 @@ impl BluetoothUUID {
|
||||||
impl Clone for StringOrUnsignedLong {
|
impl Clone for StringOrUnsignedLong {
|
||||||
fn clone(&self) -> StringOrUnsignedLong {
|
fn clone(&self) -> StringOrUnsignedLong {
|
||||||
match self {
|
match self {
|
||||||
&StringOrUnsignedLong::String(ref s) => StringOrUnsignedLong::String(s.clone()),
|
StringOrUnsignedLong::String(s) => StringOrUnsignedLong::String(s.clone()),
|
||||||
&StringOrUnsignedLong::UnsignedLong(ul) => StringOrUnsignedLong::UnsignedLong(ul),
|
&StringOrUnsignedLong::UnsignedLong(ul) => StringOrUnsignedLong::UnsignedLong(ul),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1762,8 +1762,8 @@ impl Document {
|
||||||
let body = self.GetBody();
|
let body = self.GetBody();
|
||||||
|
|
||||||
let target = match (&focused, &body) {
|
let target = match (&focused, &body) {
|
||||||
(&Some(ref focused), _) => focused.upcast(),
|
(Some(focused), _) => focused.upcast(),
|
||||||
(&None, &Some(ref body)) => body.upcast(),
|
(&None, Some(body)) => body.upcast(),
|
||||||
(&None, &None) => self.window.upcast(),
|
(&None, &None) => self.window.upcast(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4640,7 +4640,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
match (self.GetDocumentElement(), &old_body) {
|
match (self.GetDocumentElement(), &old_body) {
|
||||||
// Step 3.
|
// Step 3.
|
||||||
(Some(ref root), &Some(ref child)) => {
|
(Some(ref root), Some(child)) => {
|
||||||
let root = root.upcast::<Node>();
|
let root = root.upcast::<Node>();
|
||||||
root.ReplaceChild(new_body.upcast(), child.upcast())
|
root.ReplaceChild(new_body.upcast(), child.upcast())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -138,18 +138,12 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
||||||
fn data(self) -> HTMLCanvasData {
|
fn data(self) -> HTMLCanvasData {
|
||||||
let source = unsafe {
|
let source = unsafe {
|
||||||
match self.unsafe_get().context.borrow_for_layout().as_ref() {
|
match self.unsafe_get().context.borrow_for_layout().as_ref() {
|
||||||
Some(&CanvasContext::Context2d(ref context)) => {
|
Some(CanvasContext::Context2d(context)) => {
|
||||||
HTMLCanvasDataSource::Image(Some(context.to_layout().get_ipc_renderer()))
|
HTMLCanvasDataSource::Image(Some(context.to_layout().get_ipc_renderer()))
|
||||||
},
|
},
|
||||||
Some(&CanvasContext::WebGL(ref context)) => {
|
Some(CanvasContext::WebGL(context)) => context.to_layout().canvas_data_source(),
|
||||||
context.to_layout().canvas_data_source()
|
Some(CanvasContext::WebGL2(context)) => context.to_layout().canvas_data_source(),
|
||||||
},
|
Some(CanvasContext::WebGPU(context)) => context.to_layout().canvas_data_source(),
|
||||||
Some(&CanvasContext::WebGL2(ref context)) => {
|
|
||||||
context.to_layout().canvas_data_source()
|
|
||||||
},
|
|
||||||
Some(&CanvasContext::WebGPU(ref context)) => {
|
|
||||||
context.to_layout().canvas_data_source()
|
|
||||||
},
|
|
||||||
None => HTMLCanvasDataSource::Image(None),
|
None => HTMLCanvasDataSource::Image(None),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -318,7 +312,7 @@ impl HTMLCanvasElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = match self.context.borrow().as_ref() {
|
let data = match self.context.borrow().as_ref() {
|
||||||
Some(&CanvasContext::Context2d(ref context)) => {
|
Some(CanvasContext::Context2d(context)) => {
|
||||||
let (sender, receiver) =
|
let (sender, receiver) =
|
||||||
ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||||
let msg = CanvasMsg::FromScript(
|
let msg = CanvasMsg::FromScript(
|
||||||
|
|
|
@ -359,7 +359,7 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
|
||||||
fn SelectedIndex(&self) -> i32 {
|
fn SelectedIndex(&self) -> i32 {
|
||||||
self.list_of_options()
|
self.list_of_options()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|&(_, ref opt_elem)| opt_elem.Selected())
|
.filter(|(_, opt_elem)| opt_elem.Selected())
|
||||||
.map(|(i, _)| i as i32)
|
.map(|(i, _)| i as i32)
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or(-1)
|
.unwrap_or(-1)
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl MutationObserver {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
// Step 3.1.1
|
// Step 3.1.1
|
||||||
let idx = interested_observers.iter().position(|&(ref o, _)| {
|
let idx = interested_observers.iter().position(|(o, _)| {
|
||||||
&**o as *const _ == &*registered.observer as *const _
|
&**o as *const _ == &*registered.observer as *const _
|
||||||
});
|
});
|
||||||
if let Some(idx) = idx {
|
if let Some(idx) = idx {
|
||||||
|
@ -202,7 +202,7 @@ impl MutationObserver {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
// Step 3.1.1
|
// Step 3.1.1
|
||||||
let idx = interested_observers.iter().position(|&(ref o, _)| {
|
let idx = interested_observers.iter().position(|(o, _)| {
|
||||||
&**o as *const _ == &*registered.observer as *const _
|
&**o as *const _ == &*registered.observer as *const _
|
||||||
});
|
});
|
||||||
if let Some(idx) = idx {
|
if let Some(idx) = idx {
|
||||||
|
|
|
@ -2796,7 +2796,7 @@ impl NodeMethods for Node {
|
||||||
}
|
}
|
||||||
while children
|
while children
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |&(_, ref sibling)| sibling.is::<Text>())
|
.map_or(false, |(_, sibling)| sibling.is::<Text>())
|
||||||
{
|
{
|
||||||
let (index, sibling) = children.next().unwrap();
|
let (index, sibling) = children.next().unwrap();
|
||||||
sibling
|
sibling
|
||||||
|
@ -3431,7 +3431,7 @@ unsafe_no_jsmanaged_fields!(UniqueId);
|
||||||
impl MallocSizeOf for UniqueId {
|
impl MallocSizeOf for UniqueId {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||||
if let &Some(ref uuid) = unsafe { &*self.cell.get() } {
|
if let Some(uuid) = unsafe { &*self.cell.get() } {
|
||||||
unsafe { ops.malloc_size_of(&**uuid) }
|
unsafe { ops.malloc_size_of(&**uuid) }
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl OffscreenCanvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = match self.context.borrow().as_ref() {
|
let data = match self.context.borrow().as_ref() {
|
||||||
Some(&OffscreenCanvasContext::OffscreenContext2d(ref context)) => {
|
Some(OffscreenCanvasContext::OffscreenContext2d(context)) => {
|
||||||
let (sender, receiver) =
|
let (sender, receiver) =
|
||||||
ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||||
let msg = CanvasMsg::FromScript(
|
let msg = CanvasMsg::FromScript(
|
||||||
|
|
|
@ -858,10 +858,10 @@ impl Into<RequestRedirect> for NetTraitsRequestRedirect {
|
||||||
impl Clone for HeadersInit {
|
impl Clone for HeadersInit {
|
||||||
fn clone(&self) -> HeadersInit {
|
fn clone(&self) -> HeadersInit {
|
||||||
match self {
|
match self {
|
||||||
&HeadersInit::ByteStringSequenceSequence(ref b) => {
|
HeadersInit::ByteStringSequenceSequence(b) => {
|
||||||
HeadersInit::ByteStringSequenceSequence(b.clone())
|
HeadersInit::ByteStringSequenceSequence(b.clone())
|
||||||
},
|
},
|
||||||
&HeadersInit::ByteStringByteStringRecord(ref m) => {
|
HeadersInit::ByteStringByteStringRecord(m) => {
|
||||||
HeadersInit::ByteStringByteStringRecord(m.clone())
|
HeadersInit::ByteStringByteStringRecord(m.clone())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
|
||||||
// A: Step 4-5
|
// A: Step 4-5
|
||||||
let scope = match options.scope {
|
let scope = match options.scope {
|
||||||
Some(ref scope) => {
|
Some(ref scope) => {
|
||||||
let &USVString(ref inner_scope) = scope;
|
let USVString(inner_scope) = scope;
|
||||||
match api_base_url.join(inner_scope) {
|
match api_base_url.join(inner_scope) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn start_element<S: Serializer>(node: &Element, serializer: &mut S) -> io::Resul
|
||||||
(qname, value)
|
(qname, value)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let attr_refs = attrs.iter().map(|&(ref qname, ref value)| {
|
let attr_refs = attrs.iter().map(|(qname, value)| {
|
||||||
let ar: AttrRef = (&qname, &**value);
|
let ar: AttrRef = (&qname, &**value);
|
||||||
ar
|
ar
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,12 +118,10 @@ impl URLSearchParamsMethods for URLSearchParams {
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
|
||||||
fn Delete(&self, name: USVString, value: Option<USVString>) {
|
fn Delete(&self, name: USVString, value: Option<USVString>) {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.list
|
self.list.borrow_mut().retain(|(k, v)| match &value {
|
||||||
.borrow_mut()
|
Some(value) => !(k == &name.0 && v == &value.0),
|
||||||
.retain(|&(ref k, ref v)| match &value {
|
None => k != &name.0,
|
||||||
Some(value) => !(k == &name.0 && v == &value.0),
|
});
|
||||||
None => k != &name.0,
|
|
||||||
});
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
self.update_steps();
|
self.update_steps();
|
||||||
}
|
}
|
||||||
|
@ -140,7 +138,7 @@ impl URLSearchParamsMethods for URLSearchParams {
|
||||||
fn GetAll(&self, name: USVString) -> Vec<USVString> {
|
fn GetAll(&self, name: USVString) -> Vec<USVString> {
|
||||||
let list = self.list.borrow();
|
let list = self.list.borrow();
|
||||||
list.iter()
|
list.iter()
|
||||||
.filter_map(|&(ref k, ref v)| {
|
.filter_map(|(k, v)| {
|
||||||
if k == &name.0 {
|
if k == &name.0 {
|
||||||
Some(USVString(v.clone()))
|
Some(USVString(v.clone()))
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,7 +151,7 @@ impl URLSearchParamsMethods for URLSearchParams {
|
||||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
|
||||||
fn Has(&self, name: USVString, value: Option<USVString>) -> bool {
|
fn Has(&self, name: USVString, value: Option<USVString>) -> bool {
|
||||||
let list = self.list.borrow();
|
let list = self.list.borrow();
|
||||||
list.iter().any(|&(ref k, ref v)| match &value {
|
list.iter().any(|(k, v)| match &value {
|
||||||
Some(value) => k == &name.0 && v == &value.0,
|
Some(value) => k == &name.0 && v == &value.0,
|
||||||
None => k == &name.0,
|
None => k == &name.0,
|
||||||
})
|
})
|
||||||
|
@ -166,7 +164,7 @@ impl URLSearchParamsMethods for URLSearchParams {
|
||||||
let mut list = self.list.borrow_mut();
|
let mut list = self.list.borrow_mut();
|
||||||
let mut index = None;
|
let mut index = None;
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
list.retain(|&(ref k, _)| {
|
list.retain(|(k, _)| {
|
||||||
if index.is_none() {
|
if index.is_none() {
|
||||||
if k == &name.0 {
|
if k == &name.0 {
|
||||||
index = Some(i);
|
index = Some(i);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue