Make test-tidy check that braces have spaces before or after them

This commit is contained in:
wilmoz 2015-08-31 12:30:55 -05:00
parent aee011a524
commit 64ac4f175f
10 changed files with 31 additions and 21 deletions

View file

@ -576,13 +576,13 @@ extern fn glyph_h_advance_func(_: *mut hb_font_t,
fn glyph_space_advance(font: *mut Font) -> f64 { fn glyph_space_advance(font: *mut Font) -> f64 {
let space_unicode = ' '; let space_unicode = ' ';
let space_glyph: hb_codepoint_t; let space_glyph: hb_codepoint_t;
match unsafe {(*font).glyph_index(space_unicode)} { match unsafe { (*font).glyph_index(space_unicode) } {
Some(g) => { Some(g) => {
space_glyph = g as hb_codepoint_t; space_glyph = g as hb_codepoint_t;
} }
None => panic!("No space info") None => panic!("No space info")
} }
let space_advance = unsafe {(*font).glyph_h_advance(space_glyph as GlyphId)}; let space_advance = unsafe { (*font).glyph_h_advance(space_glyph as GlyphId) };
space_advance space_advance
} }

View file

@ -17,14 +17,14 @@ use syntax::ptr::P;
/// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes) /// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes)
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> { pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
match ty.node { match ty.node {
TyPath(_, Path {segments: ref seg, ..}) => { TyPath(_, Path { segments: ref seg, .. }) => {
// So ast::Path isn't the full path, just the tokens that were provided. // So ast::Path isn't the full path, just the tokens that were provided.
// I could muck around with the maps and find the full path // I could muck around with the maps and find the full path
// however the more efficient way is to simply reverse the iterators and zip them // however the more efficient way is to simply reverse the iterators and zip them
// which will compare them in reverse until one of them runs out of segments // which will compare them in reverse until one of them runs out of segments
if seg.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.identifier.name.as_str() == *b) { if seg.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.identifier.name.as_str() == *b) {
match seg.last() { match seg.last() {
Some(&PathSegment {parameters: AngleBracketedParameters(ref a), ..}) => { Some(&PathSegment { parameters: AngleBracketedParameters(ref a), .. }) => {
Some(&a.types) Some(&a.types)
} }
_ => None _ => None

View file

@ -1867,10 +1867,10 @@ impl Element {
} }
} }
// Step 6 // Step 6
None => {event.fire(target);} None => { event.fire(target); }
}, },
// Step 6 // Step 6
None => {event.fire(target);} None => { event.fire(target); }
} }
// Step 7 // Step 7
self.set_click_in_progress(false); self.set_click_in_progress(false);

View file

@ -64,7 +64,7 @@ impl HTMLCollection {
} }
} }
} }
let filter = AllElementFilter {namespace_filter: namespace_filter}; let filter = AllElementFilter { namespace_filter: namespace_filter };
HTMLCollection::create(window, root, box filter) HTMLCollection::create(window, root, box filter)
} }

View file

@ -52,9 +52,9 @@ impl ProgressEvent {
type_: DOMString, type_: DOMString,
init: &ProgressEventBinding::ProgressEventInit) init: &ProgressEventBinding::ProgressEventInit)
-> Fallible<Root<ProgressEvent>> { -> Fallible<Root<ProgressEvent>> {
let bubbles = if init.parent.bubbles {EventBubbles::Bubbles} else {EventBubbles::DoesNotBubble}; let bubbles = if init.parent.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
let cancelable = if init.parent.cancelable {EventCancelable::Cancelable} let cancelable = if init.parent.cancelable { EventCancelable::Cancelable }
else {EventCancelable::NotCancelable}; else { EventCancelable::NotCancelable };
let ev = ProgressEvent::new(global, type_, bubbles, cancelable, let ev = ProgressEvent::new(global, type_, bubbles, cancelable,
init.lengthComputable, init.loaded, init.total); init.lengthComputable, init.loaded, init.total);
Ok(ev) Ok(ev)

View file

@ -15,20 +15,20 @@ pub struct TestBindingProxy {
} }
impl TestBindingProxyMethods for TestBindingProxy { impl TestBindingProxyMethods for TestBindingProxy {
fn Length(&self) -> u32 {0} fn Length(&self) -> u32 { 0 }
fn SupportedPropertyNames(&self) -> Vec<DOMString> {vec![]} fn SupportedPropertyNames(&self) -> Vec<DOMString> { vec![] }
fn GetNamedItem(&self, _: DOMString) -> DOMString {"".to_owned()} fn GetNamedItem(&self, _: DOMString) -> DOMString { "".to_owned() }
fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {} fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {}
fn GetItem(&self, _: u32) -> DOMString {"".to_owned()} fn GetItem(&self, _: u32) -> DOMString { "".to_owned() }
fn SetItem(&self, _: u32, _: DOMString) -> () {} fn SetItem(&self, _: u32, _: DOMString) -> () {}
fn RemoveItem(&self, _: DOMString) -> () {} fn RemoveItem(&self, _: DOMString) -> () {}
fn Stringifier(&self) -> DOMString {"".to_owned()} fn Stringifier(&self) -> DOMString { "".to_owned() }
fn NamedCreator(&self, _: DOMString, _: DOMString) -> () {} fn NamedCreator(&self, _: DOMString, _: DOMString) -> () {}
fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString {"".to_owned()} fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { "".to_owned() }
fn NamedDeleter(&self, _: DOMString) -> () {} fn NamedDeleter(&self, _: DOMString) -> () {}
fn IndexedSetter(&self, _: u32, _: DOMString) -> () {} fn IndexedSetter(&self, _: u32, _: DOMString) -> () {}
fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {} fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {}
fn IndexedCreator(&self, _: u32, _: DOMString) -> () {} fn IndexedCreator(&self, _: u32, _: DOMString) -> () {}
fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString {"".to_owned()} fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { "".to_owned() }
} }

View file

@ -959,7 +959,7 @@ impl XMLHttpRequest {
fn dispatch_response_progress_event(&self, type_: DOMString) { fn dispatch_response_progress_event(&self, type_: DOMString) {
let len = self.response.borrow().len() as u64; let len = self.response.borrow().len() as u64;
let total = self.response_headers.borrow().get::<ContentLength>().map(|x| {**x as u64}); let total = self.response_headers.borrow().get::<ContentLength>().map(|x| { **x as u64 });
self.dispatch_progress_event(false, type_, len, total); self.dispatch_progress_event(false, type_, len, total);
} }
fn set_timeout(&self, duration_ms: u32) { fn set_timeout(&self, duration_ms: u32) {

View file

@ -183,7 +183,7 @@ impl TimerManager {
if is_interval == IsInterval::NonInterval { if is_interval == IsInterval::NonInterval {
break; break;
} }
} else if id == control_handle.id() {; } else if id == control_handle.id() {
match control_port.recv().unwrap() { match control_port.recv().unwrap() {
TimerControlMsg::Suspend => { TimerControlMsg::Suspend => {
let msg = control_port.recv().unwrap(); let msg = control_port.recv().unwrap();
@ -194,7 +194,7 @@ impl TimerManager {
break; break;
}, },
} }
}, },
TimerControlMsg::Resume => panic!("Nothing to resume!"), TimerControlMsg::Resume => panic!("Nothing to resume!"),
TimerControlMsg::Cancel => { TimerControlMsg::Cancel => {
break; break;

View file

@ -243,6 +243,16 @@ def check_rust(file_name, contents):
if match: if match:
yield (idx + 1, "missing space before {") yield (idx + 1, "missing space before {")
# ignored cases like {} and }}
match = re.search(r"[^\s{}]}", line)
if match and not (line.startswith("use") or line.startswith("pub use")):
yield (idx + 1, "missing space before }")
# ignored cases like {} and {{
match = re.search(r"{[^\s{}]", line)
if match and not (line.startswith("use") or line.startswith("pub use")):
yield (idx + 1, "missing space after {")
# imports must be in the same line and alphabetically sorted # imports must be in the same line and alphabetically sorted
if line.startswith("use "): if line.startswith("use "):
use = line[4:] use = line[4:]

View file

@ -199,7 +199,7 @@ impl AssertMustHaveBodyRequest {
impl HttpRequest for AssertMustHaveBodyRequest { impl HttpRequest for AssertMustHaveBodyRequest {
type R = MockResponse; type R = MockResponse;
fn headers_mut(&mut self) -> &mut Headers { &mut self.headers} fn headers_mut(&mut self) -> &mut Headers { &mut self.headers }
fn send(self, body: &Option<Vec<u8>>) -> Result<MockResponse, LoadError> { fn send(self, body: &Option<Vec<u8>>) -> Result<MockResponse, LoadError> {
assert_eq!(self.expected_body, *body); assert_eq!(self.expected_body, *body);