Auto merge of #7976 - frewsxcv:clippy, r=jdm

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 -->
This commit is contained in:
bors-servo 2015-10-12 04:37:42 -06:00
commit ac1b595609
9 changed files with 271 additions and 284 deletions

View file

@ -161,6 +161,6 @@ impl Cookie {
return false;
}
return true;
true
}
}

View file

@ -108,18 +108,20 @@ 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,
@ -127,13 +129,7 @@ impl BasicCORSCache {
// 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))
}
}

View file

@ -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))

View file

@ -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)))
}
}
}

View file

@ -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)
}
}