Skip to content

Commit

Permalink
Auto merge of #7976 - frewsxcv:clippy, r=jdm
Browse files Browse the repository at this point in the history
Cleanup code that was warned by rust-clippy

[whitespace agnostic diff](https://github.com/servo/servo/pull/7976/files?w=1)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7976)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 12, 2015
2 parents 8dff3be + e3aabd0 commit ac1b595
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 284 deletions.
17 changes: 6 additions & 11 deletions components/layout/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,17 +810,12 @@ impl TableLikeFlow for BlockFlow {
let mut candidate_block_size_iterator = CandidateBSizeIterator::new(
&self.fragment,
self.base.block_container_explicit_block_size);
loop {
match candidate_block_size_iterator.next() {
Some(candidate_block_size) => {
candidate_block_size_iterator.candidate_value =
match candidate_block_size {
MaybeAuto::Auto => block_size,
MaybeAuto::Specified(value) => value
}
}
None => break,
}
while let Some(candidate_block_size) = candidate_block_size_iterator.next() {
candidate_block_size_iterator.candidate_value =
match candidate_block_size {
MaybeAuto::Auto => block_size,
MaybeAuto::Specified(value) => value
};
}

// Adjust `current_block_offset` as necessary to account for the explicitly-specified
Expand Down
2 changes: 1 addition & 1 deletion components/net/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ impl Cookie {
return false;
}

return true;
true
}
}
24 changes: 10 additions & 14 deletions components/net/fetch/cors_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,28 @@ pub trait CORSCache {
#[derive(Clone)]
pub struct BasicCORSCache(Vec<CORSCacheEntry>);

fn match_headers(cors_cache: &CORSCacheEntry, cors_req: &CacheRequestDetails) -> bool {
cors_cache.origin.scheme == cors_req.origin.scheme &&
cors_cache.origin.host() == cors_req.origin.host() &&
cors_cache.origin.port() == cors_req.origin.port() &&
cors_cache.url == cors_req.destination &&
cors_cache.credentials == cors_req.credentials
}

impl BasicCORSCache {
fn find_entry_by_header<'a>(&'a mut self, request: &CacheRequestDetails,
header_name: &str) -> Option<&'a mut CORSCacheEntry> {
self.cleanup();
let BasicCORSCache(ref mut buf) = *self;
let entry = buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
e.origin.host() == request.origin.host() &&
e.origin.port() == request.origin.port() &&
e.url == request.destination &&
e.credentials == request.credentials &&
e.header_or_method.match_header(header_name));
entry
buf.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_header(header_name))
}

fn find_entry_by_method<'a>(&'a mut self, request: &CacheRequestDetails,
method: Method) -> Option<&'a mut CORSCacheEntry> {
// we can take the method from CORSRequest itself
self.cleanup();
let BasicCORSCache(ref mut buf) = *self;
let entry = buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
e.origin.host() == request.origin.host() &&
e.origin.port() == request.origin.port() &&
e.url == request.destination &&
e.credentials == request.credentials &&
e.header_or_method.match_method(&method));
entry
buf.iter_mut().find(|e| match_headers(e, request) && e.header_or_method.match_method(&method))
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/net/file_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum ReadStatus {
fn read_block(reader: &mut File) -> Result<ReadStatus, String> {
let mut buf = vec![0; READ_SIZE];
match reader.read(&mut buf) {
Ok(0) => return Ok(ReadStatus::EOF),
Ok(0) => Ok(ReadStatus::EOF),
Ok(n) => {
buf.truncate(n);
Ok(ReadStatus::Partial(buf))
Expand Down
8 changes: 4 additions & 4 deletions components/net/http_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,19 @@ impl<R: HttpResponse> StreamedResponse<R> {
let result = GzDecoder::new(response);
match result {
Ok(response_decoding) => {
return Ok(StreamedResponse::new(m, Decoder::Gzip(response_decoding)));
Ok(StreamedResponse::new(m, Decoder::Gzip(response_decoding)))
}
Err(err) => {
return Err(LoadError::Decoding(m.final_url, err.to_string()));
Err(LoadError::Decoding(m.final_url, err.to_string()))
}
}
}
Some(Encoding::Deflate) => {
let response_decoding = DeflateDecoder::new(response);
return Ok(StreamedResponse::new(m, Decoder::Deflate(response_decoding)));
Ok(StreamedResponse::new(m, Decoder::Deflate(response_decoding)))
}
_ => {
return Ok(StreamedResponse::new(m, Decoder::Plain(response)));
Ok(StreamedResponse::new(m, Decoder::Plain(response)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/net/resource_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
if let Some(ref headers) = metadata.headers {
if let Some(ref raw_content_type) = headers.get_raw("content-type") {
if raw_content_type.len() > 0 {
let ref last_raw_content_type = raw_content_type[raw_content_type.len() - 1];
let last_raw_content_type = &raw_content_type[raw_content_type.len() - 1];
check_for_apache_bug = apache_bug_predicate(last_raw_content_type)
}
}
Expand Down
66 changes: 33 additions & 33 deletions components/script/dom/virtualmethods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,137 +119,137 @@ pub trait VirtualMethods {
/// method call on the trait object will invoke the corresponding method on the
/// concrete type, propagating up the parent hierarchy unless otherwise
/// interrupted.
pub fn vtable_for<'a>(node: &'a Node) -> &'a (VirtualMethods + 'a) {
pub fn vtable_for(node: &Node) -> &VirtualMethods {
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => {
let element = HTMLAnchorElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAppletElement)) => {
HTMLAppletElementCast::to_ref(node).unwrap() as &'a (VirtualMethods + 'a)
HTMLAppletElementCast::to_ref(node).unwrap() as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => {
let element = HTMLAreaElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBaseElement)) => {
let element = HTMLBaseElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) => {
let element = HTMLBodyElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) => {
let element = HTMLButtonElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLCanvasElement)) => {
let element = HTMLCanvasElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFieldSetElement)) => {
let element = HTMLFieldSetElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFontElement)) => {
let element = HTMLFontElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFormElement)) => {
let element = HTMLFormElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHeadElement)) => {
let element = HTMLHeadElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLImageElement)) => {
let element = HTMLImageElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLIFrameElement)) => {
let element = HTMLIFrameElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
let element = HTMLInputElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => {
let element = HTMLLinkElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMetaElement)) => {
let element = HTMLMetaElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLObjectElement)) => {
let element = HTMLObjectElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptGroupElement)) => {
let element = HTMLOptGroupElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => {
let element = HTMLOptionElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLScriptElement)) => {
let element = HTMLScriptElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) => {
let element = HTMLSelectElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLStyleElement)) => {
let element = HTMLStyleElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableElement)) => {
let element =
HTMLTableElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableCellElement(_))) => {
let element =
HTMLTableCellElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)) => {
let element =
HTMLTableRowElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableSectionElement)) => {
let element =
HTMLTableSectionElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTemplateElement)) => {
HTMLTemplateElementCast::to_ref(node).unwrap() as &'a (VirtualMethods + 'a)
HTMLTemplateElementCast::to_ref(node).unwrap() as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => {
let element = HTMLTextAreaElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTitleElement)) => {
let element =
HTMLTitleElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(ElementTypeId::Element) => {
let element = ElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
NodeTypeId::Element(_) => {
let element = HTMLElementCast::to_ref(node).unwrap();
element as &'a (VirtualMethods + 'a)
element as &VirtualMethods
}
_ => {
node as &'a (VirtualMethods + 'a)
node as &VirtualMethods
}
}
}
Loading

0 comments on commit ac1b595

Please sign in to comment.