servo: Merge #9055 - Issue #9042: Report incorrect number of spaces around => in the style checker (from simartin:issue_9042); r=Wafflespeanut

Fixes https://github.com/servo/servo/issues/9042

Source-Repo: https://github.com/servo/servo
Source-Revision: f77c7928868469ef4f326a269147ae2aee6151ee
This commit is contained in:
Simon Martin 2015-12-24 10:26:48 +05:01
parent 2d152878a2
commit 6f8d33fe11
7 changed files with 48 additions and 38 deletions

View File

@ -359,7 +359,7 @@ impl NetworkEventActor {
let mut mString = "".to_owned(); let mut mString = "".to_owned();
if let Some(ref headers) = self.response.headers { if let Some(ref headers) = self.response.headers {
mString = match headers.get() { mString = match headers.get() {
Some(&ContentType(ref mime)) => mime.to_string(), Some(&ContentType(ref mime)) => mime.to_string(),
None => "".to_owned() None => "".to_owned()
}; };
} }
@ -377,7 +377,7 @@ impl NetworkEventActor {
let mut cookies_size = 0; let mut cookies_size = 0;
if let Some(ref headers) = self.response.headers { if let Some(ref headers) = self.response.headers {
cookies_size = match headers.get() { cookies_size = match headers.get() {
Some(&Cookie(ref cookie)) => cookie.len(), Some(&Cookie(ref cookie)) => cookie.len(),
None => 0 None => 0
}; };
} }
@ -408,7 +408,7 @@ impl NetworkEventActor {
let mut cookies_size = 0; let mut cookies_size = 0;
if let Some(ref headers) = self.response.headers { if let Some(ref headers) = self.response.headers {
cookies_size = match headers.get() { cookies_size = match headers.get() {
Some(&Cookie(ref cookie)) => cookie.len(), Some(&Cookie(ref cookie)) => cookie.len(),
None => 0 None => 0
}; };
} }

View File

@ -1251,9 +1251,9 @@ impl<'a> PaintContext<'a> {
0.5 * border.bottom, 0.5 * border.bottom,
0.5 * border.left); 0.5 * border.left);
let is_groove = match style { let is_groove = match style {
border_style::T::groove => true, border_style::T::groove => true,
border_style::T::ridge => false, border_style::T::ridge => false,
_ => panic!("invalid border style") _ => panic!("invalid border style")
}; };
let lighter_color; let lighter_color;

View File

@ -1137,7 +1137,7 @@ impl FragmentDisplayListBuilding for Fragment {
if width > 0 && height > 0 { if width > 0 && height > 0 {
let layer_id = self.layer_id(); let layer_id = self.layer_id();
let canvas_data = match canvas_fragment_info.ipc_renderer { let canvas_data = match canvas_fragment_info.ipc_renderer {
Some(ref ipc_renderer) => { Some(ref ipc_renderer) => {
let ipc_renderer = ipc_renderer.lock().unwrap(); let ipc_renderer = ipc_renderer.lock().unwrap();
let (sender, receiver) = ipc::channel().unwrap(); let (sender, receiver) = ipc::channel().unwrap();
ipc_renderer.send(CanvasMsg::FromLayout( ipc_renderer.send(CanvasMsg::FromLayout(

View File

@ -381,32 +381,32 @@ impl Document {
pub fn set_encoding_name(&self, name: DOMString) { pub fn set_encoding_name(&self, name: DOMString) {
*self.encoding_name.borrow_mut() = DOMString::from( *self.encoding_name.borrow_mut() = DOMString::from(
match name.as_ref() { match name.as_ref() {
"utf-8" => "UTF-8", "utf-8" => "UTF-8",
"ibm866" => "IBM866", "ibm866" => "IBM866",
"iso-8859-2" => "ISO-8859-2", "iso-8859-2" => "ISO-8859-2",
"iso-8859-3" => "ISO-8859-3", "iso-8859-3" => "ISO-8859-3",
"iso-8859-4" => "ISO-8859-4", "iso-8859-4" => "ISO-8859-4",
"iso-8859-5" => "ISO-8859-5", "iso-8859-5" => "ISO-8859-5",
"iso-8859-6" => "ISO-8859-6", "iso-8859-6" => "ISO-8859-6",
"iso-8859-7" => "ISO-8859-7", "iso-8859-7" => "ISO-8859-7",
"iso-8859-8" => "ISO-8859-8", "iso-8859-8" => "ISO-8859-8",
"iso-8859-8-i" => "ISO-8859-8-I", "iso-8859-8-i" => "ISO-8859-8-I",
"iso-8859-10" => "ISO-8859-10", "iso-8859-10" => "ISO-8859-10",
"iso-8859-13" => "ISO-8859-13", "iso-8859-13" => "ISO-8859-13",
"iso-8859-14" => "ISO-8859-14", "iso-8859-14" => "ISO-8859-14",
"iso-8859-15" => "ISO-8859-15", "iso-8859-15" => "ISO-8859-15",
"iso-8859-16" => "ISO-8859-16", "iso-8859-16" => "ISO-8859-16",
"koi8-r" => "KOI8-R", "koi8-r" => "KOI8-R",
"koi8-u" => "KOI8-U", "koi8-u" => "KOI8-U",
"gbk" => "GBK", "gbk" => "GBK",
"big5" => "Big5", "big5" => "Big5",
"euc-jp" => "EUC-JP", "euc-jp" => "EUC-JP",
"iso-2022-jp" => "ISO-2022-JP", "iso-2022-jp" => "ISO-2022-JP",
"shift_jis" => "Shift_JIS", "shift_jis" => "Shift_JIS",
"euc-kr" => "EUC-KR", "euc-kr" => "EUC-KR",
"utf-16be" => "UTF-16BE", "utf-16be" => "UTF-16BE",
"utf-16le" => "UTF-16LE", "utf-16le" => "UTF-16LE",
_ => &*name _ => &*name
}); });
} }

View File

@ -464,7 +464,7 @@ pub enum FormSubmittableElement {
impl FormSubmittableElement { impl FormSubmittableElement {
fn as_event_target(&self) -> &EventTarget { fn as_event_target(&self) -> &EventTarget {
match *self { match *self {
FormSubmittableElement::ButtonElement(ref button) => button.r().upcast(), FormSubmittableElement::ButtonElement(ref button) => button.r().upcast(),
FormSubmittableElement::InputElement(ref input) => input.r().upcast(), FormSubmittableElement::InputElement(ref input) => input.r().upcast(),
FormSubmittableElement::ObjectElement(ref object) => object.r().upcast(), FormSubmittableElement::ObjectElement(ref object) => object.r().upcast(),
FormSubmittableElement::SelectElement(ref select) => select.r().upcast(), FormSubmittableElement::SelectElement(ref select) => select.r().upcast(),

View File

@ -15,7 +15,7 @@ fn hexdump_slice(buf: &[u8]) {
stderr.write_all(output.as_bytes()).unwrap(); stderr.write_all(output.as_bytes()).unwrap();
match i % 16 { match i % 16 {
15 => { stderr.write_all(b"\n ").unwrap(); }, 15 => { stderr.write_all(b"\n ").unwrap(); },
7 => { stderr.write_all(b" ").unwrap(); }, 7 => { stderr.write_all(b" ").unwrap(); },
_ => () _ => ()
} }
stderr.flush().unwrap(); stderr.flush().unwrap();

View File

@ -314,6 +314,16 @@ def check_rust(file_name, contents):
if match: if match:
yield (idx + 1, "missing space after ->") yield (idx + 1, "missing space after ->")
line_len = len(line)
arrow_pos = line.find("=>")
if arrow_pos != -1:
if arrow_pos and line[arrow_pos - 1] != ' ':
yield (idx + 1, "missing space before =>")
if arrow_pos + 2 < line_len and line[arrow_pos + 2] != ' ':
yield (idx + 1, "missing space after =>")
elif arrow_pos + 3 < line_len and line[arrow_pos + 3] == ' ':
yield (idx + 1, "extra space after =>")
# Avoid flagging ::crate::mod and `trait Foo : Bar` # Avoid flagging ::crate::mod and `trait Foo : Bar`
match = line.find(" :") match = line.find(" :")
if match != -1: if match != -1:
@ -344,7 +354,7 @@ def check_rust(file_name, contents):
# check extern crates # check extern crates
if line.startswith("extern crate "): if line.startswith("extern crate "):
crate_name = line[len("extern crate "):-1] crate_name = line[len("extern crate "):-1]
indent = len(original_line) - len(line) indent = len(original_line) - line_len
if indent not in prev_crate: if indent not in prev_crate:
prev_crate[indent] = "" prev_crate[indent] = ""
if prev_crate[indent] > crate_name: if prev_crate[indent] > crate_name:
@ -358,7 +368,7 @@ def check_rust(file_name, contents):
elif line.startswith("use "): elif line.startswith("use "):
import_block = True import_block = True
use = line[4:] use = line[4:]
indent = len(original_line) - len(line) indent = len(original_line) - line_len
if not use.endswith(";"): if not use.endswith(";"):
yield (idx + 1, "use statement spans multiple lines") yield (idx + 1, "use statement spans multiple lines")
current_use = use[:len(use) - 1] current_use = use[:len(use) - 1]
@ -378,7 +388,7 @@ def check_rust(file_name, contents):
# modules must be in the same line and alphabetically sorted # modules must be in the same line and alphabetically sorted
if line.startswith("mod ") or line.startswith("pub mod "): if line.startswith("mod ") or line.startswith("pub mod "):
indent = len(original_line) - len(line) indent = len(original_line) - line_len
mod = line[4:] if line.startswith("mod ") else line[8:] mod = line[4:] if line.startswith("mod ") else line[8:]
if idx < 0 or "#[macro_use]" not in contents[idx - 1]: if idx < 0 or "#[macro_use]" not in contents[idx - 1]: