Auto merge of #9123 - karyon:clippy_cleanup, r=Manishearth

Fix a bunch of clippy lints

This fixes about 130 clippy lints. Let me know if i should split up the commit.

I wasn't sure about some of the changes, especially map_or instead of map(...).unwrap_or(...) and if let instead of single arm match were not always a strict improvement in my opinion, but i'll leave that decision to the reviewer :)

There are about 150 lints left which i thought were clippy bugs or i didn't know how to fix.

cc @Manishearth

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9123)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-01-03 09:16:34 +05:30
commit 9da739acef
58 changed files with 281 additions and 356 deletions

View file

@ -112,27 +112,27 @@ impl<'a, E> Element for ElementWrapper<'a, E> where E: Element {
state_pseudo_classes!(snapshot_state_accessors);
fn parent_element(&self) -> Option<Self> {
self.element.parent_element().map(|el| ElementWrapper::new(el))
self.element.parent_element().map(ElementWrapper::new)
}
fn first_child_element(&self) -> Option<Self> {
self.element.first_child_element().map(|el| ElementWrapper::new(el))
self.element.first_child_element().map(ElementWrapper::new)
}
fn last_child_element(&self) -> Option<Self> {
self.element.last_child_element().map(|el| ElementWrapper::new(el))
self.element.last_child_element().map(ElementWrapper::new)
}
fn prev_sibling_element(&self) -> Option<Self> {
self.element.prev_sibling_element().map(|el| ElementWrapper::new(el))
self.element.prev_sibling_element().map(ElementWrapper::new)
}
fn next_sibling_element(&self) -> Option<Self> {
self.element.next_sibling_element().map(|el| ElementWrapper::new(el))
self.element.next_sibling_element().map(ElementWrapper::new)
}
fn is_html_element_in_html_document(&self) -> bool {
self.element.is_html_element_in_html_document()
}
fn get_local_name<'b>(&'b self) -> &'b Atom {
fn get_local_name(&self) -> &Atom {
self.element.get_local_name()
}
fn get_namespace<'b>(&'b self) -> &'b Namespace {
fn get_namespace<'b>(&self) -> &Namespace {
self.element.get_namespace()
}
fn get_id(&self) -> Option<Atom> {

View file

@ -47,7 +47,7 @@ impl ParseErrorReporter for StdoutErrorReporter {
}
fn pipeline(&self) -> PipelineId {
return PipelineId::fake_root_pipeline_id();
PipelineId::fake_root_pipeline_id()
}
}
@ -129,7 +129,7 @@ pub struct Stylist {
impl Stylist {
#[inline]
pub fn new(device: Device) -> Stylist {
let stylist = Stylist {
Stylist {
viewport_constraints: None,
device: device,
is_device_dirty: true,
@ -140,9 +140,8 @@ impl Stylist {
after_map: PerPseudoElementSelectorMap::new(),
rules_source_order: 0,
state_deps: DependencySet::new(),
};
}
// FIXME: Add iso-8859-9.css when the documents encoding is ISO-8859-8.
stylist
}
pub fn update(&mut self, doc_stylesheets: &[Arc<Stylesheet>],

View file

@ -201,19 +201,16 @@ impl<'a> Iterator for Rules<'a> {
let top = self.stack.len() - 1;
while let Some(rule) = self.stack[top].next() {
// handle conditional group rules
match rule {
&CSSRule::Media(ref rule) => {
if let Some(device) = self.device {
if rule.evaluate(device) {
self.stack.push(rule.rules.iter());
} else {
continue
}
} else {
if let &CSSRule::Media(ref rule) = rule {
if let Some(device) = self.device {
if rule.evaluate(device) {
self.stack.push(rule.rules.iter());
} else {
continue
}
} else {
self.stack.push(rule.rules.iter());
}
_ => {}
}
return Some(rule)