mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Fix issues found by rust-clippy
This commit is contained in:
parent
6303126e0c
commit
20beaf5af3
23 changed files with 106 additions and 121 deletions
|
@ -76,7 +76,7 @@ impl<K: Clone + PartialEq, V: Clone> LRUCache<K, V> {
|
|||
self.entries[last_index].1.clone()
|
||||
}
|
||||
|
||||
pub fn iter<'a>(&'a self) -> Iter<'a, (K, V)> {
|
||||
pub fn iter(&self) -> Iter<(K, V)> {
|
||||
self.entries.iter()
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ macro_rules! define_cursor {
|
|||
|
||||
impl ToCss for Cursor {
|
||||
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
||||
match self {
|
||||
$( &Cursor::$variant => dest.write_str($css) ),+
|
||||
match *self {
|
||||
$( Cursor::$variant => dest.write_str($css) ),+
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ impl<T: Send + 'static> Worker<T> {
|
|||
/// Gets access to the buffer pool that this worker is attached to. This can
|
||||
/// be used to create more deques which share the same buffer pool as this
|
||||
/// deque.
|
||||
pub fn pool<'a>(&'a self) -> &'a BufferPool<T> {
|
||||
pub fn pool(&self) -> &BufferPool<T> {
|
||||
&self.deque.pool
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ impl<T: Send + 'static> Stealer<T> {
|
|||
/// Gets access to the buffer pool that this stealer is attached to. This
|
||||
/// can be used to create more deques which share the same buffer pool as
|
||||
/// this deque.
|
||||
pub fn pool<'a>(&'a self) -> &'a BufferPool<T> {
|
||||
pub fn pool(&self) -> &BufferPool<T> {
|
||||
&self.deque.pool
|
||||
}
|
||||
}
|
||||
|
@ -270,11 +270,11 @@ impl<T: Send + 'static> Deque<T> {
|
|||
}
|
||||
if self.top.compare_and_swap(t, t + 1, SeqCst) == t {
|
||||
self.bottom.store(t + 1, SeqCst);
|
||||
return Some(data);
|
||||
Some(data)
|
||||
} else {
|
||||
self.bottom.store(t + 1, SeqCst);
|
||||
forget(data); // someone else stole this value
|
||||
return None;
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ impl<T: Send + 'static> Deque<T> {
|
|||
self.bottom.store(b, SeqCst);
|
||||
}
|
||||
self.pool.free(transmute(old));
|
||||
return newbuf;
|
||||
newbuf
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ impl<T> Buffer<T> {
|
|||
for i in t..b {
|
||||
buf.put(i, self.get(i));
|
||||
}
|
||||
return buf;
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ impl HeapSizeOf for url::Url {
|
|||
|
||||
impl HeapSizeOf for url::SchemeData {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&url::SchemeData::Relative(ref data) => data.heap_size_of_children(),
|
||||
&url::SchemeData::NonRelative(ref str) => str.heap_size_of_children()
|
||||
match *self {
|
||||
url::SchemeData::Relative(ref data) => data.heap_size_of_children(),
|
||||
url::SchemeData::NonRelative(ref str) => str.heap_size_of_children()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ impl HeapSizeOf for url::RelativeSchemeData {
|
|||
|
||||
impl HeapSizeOf for url::Host {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&url::Host::Domain(ref str) => str.heap_size_of_children(),
|
||||
&url::Host::Ipv6(_) => 0
|
||||
match *self {
|
||||
url::Host::Domain(ref str) => str.heap_size_of_children(),
|
||||
url::Host::Ipv6(_) => 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -302,8 +302,8 @@ impl<T: Copy + GCMethods<T>> HeapSizeOf for Heap<T> {
|
|||
|
||||
impl HeapSizeOf for Method {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&Method::Extension(ref str) => str.heap_size_of_children(),
|
||||
match *self {
|
||||
Method::Extension(ref str) => str.heap_size_of_children(),
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
|
@ -311,9 +311,9 @@ impl HeapSizeOf for Method {
|
|||
|
||||
impl<T: HeapSizeOf, U: HeapSizeOf> HeapSizeOf for Result<T, U> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&Result::Ok(ref ok) => ok.heap_size_of_children(),
|
||||
&Result::Err(ref err) => err.heap_size_of_children()
|
||||
match *self {
|
||||
Result::Ok(ref ok) => ok.heap_size_of_children(),
|
||||
Result::Err(ref err) => err.heap_size_of_children()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,13 +341,13 @@ impl HeapSizeOf for CompoundSelector {
|
|||
|
||||
impl HeapSizeOf for SimpleSelector {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(),
|
||||
&SimpleSelector::AttrIncludes(_, ref str) | &SimpleSelector::AttrPrefixMatch(_, ref str) |
|
||||
&SimpleSelector::AttrSubstringMatch(_, ref str) | &SimpleSelector::AttrSuffixMatch(_, ref str)
|
||||
match *self {
|
||||
SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(),
|
||||
SimpleSelector::AttrIncludes(_, ref str) | SimpleSelector::AttrPrefixMatch(_, ref str) |
|
||||
SimpleSelector::AttrSubstringMatch(_, ref str) | SimpleSelector::AttrSuffixMatch(_, ref str)
|
||||
=> str.heap_size_of_children(),
|
||||
&SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(),
|
||||
&SimpleSelector::AttrDashMatch(_, ref first, ref second) => first.heap_size_of_children()
|
||||
SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(),
|
||||
SimpleSelector::AttrDashMatch(_, ref first, ref second) => first.heap_size_of_children()
|
||||
+ second.heap_size_of_children(),
|
||||
// All other types come down to Atom, enum or i32, all 0
|
||||
_ => 0
|
||||
|
@ -372,8 +372,8 @@ impl HeapSizeOf for Mime {
|
|||
|
||||
impl HeapSizeOf for TopLevel {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&TopLevel::Ext(ref str) => str.heap_size_of_children(),
|
||||
match *self {
|
||||
TopLevel::Ext(ref str) => str.heap_size_of_children(),
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
|
@ -381,8 +381,8 @@ impl HeapSizeOf for TopLevel {
|
|||
|
||||
impl HeapSizeOf for SubLevel {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&SubLevel::Ext(ref str) => str.heap_size_of_children(),
|
||||
match *self {
|
||||
SubLevel::Ext(ref str) => str.heap_size_of_children(),
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
|
@ -390,8 +390,8 @@ impl HeapSizeOf for SubLevel {
|
|||
|
||||
impl HeapSizeOf for Attr {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&Attr::Ext(ref str) => str.heap_size_of_children(),
|
||||
match *self {
|
||||
Attr::Ext(ref str) => str.heap_size_of_children(),
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
|
@ -399,8 +399,8 @@ impl HeapSizeOf for Attr {
|
|||
|
||||
impl HeapSizeOf for Value {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
match self {
|
||||
&Value::Ext(ref str) => str.heap_size_of_children(),
|
||||
match *self {
|
||||
Value::Ext(ref str) => str.heap_size_of_children(),
|
||||
_ => 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ pub struct DebugOptions {
|
|||
|
||||
|
||||
impl DebugOptions {
|
||||
pub fn new<'a>(debug_string: &'a str) -> Result<DebugOptions, &'a str> {
|
||||
pub fn new(debug_string: &str) -> Result<DebugOptions, &str> {
|
||||
let mut debug_options = DebugOptions::default();
|
||||
|
||||
for option in debug_string.split(',') {
|
||||
|
|
|
@ -49,7 +49,7 @@ impl<T> PersistentList<T> where T: Send + Sync {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn iter<'a>(&'a self) -> PersistentListIterator<'a, T> {
|
||||
pub fn iter(&self) -> PersistentListIterator<T> {
|
||||
// This could clone (and would not need the lifetime if it did), but then it would incur
|
||||
// atomic operations on every call to `.next()`. Bad.
|
||||
PersistentListIterator {
|
||||
|
@ -90,4 +90,3 @@ impl<'a, T> Iterator for PersistentListIterator<'a, T> where T: Send + Sync + 's
|
|||
Some(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ impl PrefValue {
|
|||
}
|
||||
|
||||
pub fn as_boolean(&self) -> Option<bool> {
|
||||
match self {
|
||||
&PrefValue::Boolean(value) => {
|
||||
match *self {
|
||||
PrefValue::Boolean(value) => {
|
||||
Some(value)
|
||||
},
|
||||
_ => None
|
||||
|
@ -87,12 +87,12 @@ impl Pref {
|
|||
}
|
||||
|
||||
pub fn value(&self) -> &Arc<PrefValue> {
|
||||
match self {
|
||||
&Pref::NoDefault(ref x) => x,
|
||||
&Pref::WithDefault(ref default, ref override_value) => {
|
||||
match override_value {
|
||||
&Some(ref x) => x,
|
||||
&None => default
|
||||
match *self {
|
||||
Pref::NoDefault(ref x) => x,
|
||||
Pref::WithDefault(ref default, ref override_value) => {
|
||||
match *override_value {
|
||||
Some(ref x) => x,
|
||||
None => default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,11 +101,11 @@ impl Pref {
|
|||
fn set(&mut self, value: PrefValue) {
|
||||
// TODO - this should error if we try to override a pref of one type
|
||||
// with a value of a different type
|
||||
match self {
|
||||
&mut Pref::NoDefault(ref mut pref_value) => {
|
||||
match *self {
|
||||
Pref::NoDefault(ref mut pref_value) => {
|
||||
*pref_value = Arc::new(value)
|
||||
},
|
||||
&mut Pref::WithDefault(_, ref mut override_value) => {
|
||||
Pref::WithDefault(_, ref mut override_value) => {
|
||||
*override_value = Some(Arc::new(value))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ fn do_parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i64> {
|
|||
|
||||
let value = read_numbers(input);
|
||||
|
||||
return value.and_then(|value| value.checked_mul(sign));
|
||||
value.and_then(|value| value.checked_mul(sign))
|
||||
}
|
||||
|
||||
/// Parse an integer according to
|
||||
|
@ -244,9 +244,8 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
|||
}
|
||||
|
||||
// Step 5.
|
||||
match cssparser::parse_color_keyword(input) {
|
||||
Ok(Color::RGBA(rgba)) => return Ok(rgba),
|
||||
_ => {}
|
||||
if let Ok(Color::RGBA(rgba)) = cssparser::parse_color_keyword(input) {
|
||||
return Ok(rgba);
|
||||
}
|
||||
|
||||
// Step 6.
|
||||
|
|
|
@ -52,7 +52,7 @@ impl<T> FullBinarySearchMethods<T> for [T] {
|
|||
Ordering::Equal => return Some(mid),
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,13 +259,13 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
|||
}
|
||||
|
||||
// Connect workers to one another.
|
||||
for i in 0..thread_count {
|
||||
for j in 0..thread_count {
|
||||
for (i, mut thread) in threads.iter_mut().enumerate() {
|
||||
for (j, info) in infos.iter().enumerate() {
|
||||
if i != j {
|
||||
threads[i].other_deques.push(infos[j].thief.clone())
|
||||
thread.other_deques.push(info.thief.clone())
|
||||
}
|
||||
}
|
||||
assert!(threads[i].other_deques.len() == thread_count - 1)
|
||||
assert!(thread.other_deques.len() == thread_count - 1)
|
||||
}
|
||||
|
||||
// Spawn threads.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue