aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy.py
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-08-13 19:17:59 -0400
committerJosh Matthews <josh@joshmatthews.net>2015-08-16 10:31:36 -0400
commita147cbe0c14609faab9e3e64f3df823b0ae9973a (patch)
tree6a96a0cbdcc86ea3bd521b83cebaa6633a2b7b98 /python/tidy.py
parent8bb853f64354b2cc1b9f9e0ea416efdd79096418 (diff)
downloadservo-a147cbe0c14609faab9e3e64f3df823b0ae9973a.tar.gz
servo-a147cbe0c14609faab9e3e64f3df823b0ae9973a.zip
Tighten up checks for spaces around colons to deal with trait inheritance syntax.
Diffstat (limited to 'python/tidy.py')
-rw-r--r--python/tidy.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/python/tidy.py b/python/tidy.py
index 903715b472a..e2583ce87ba 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -232,9 +232,11 @@ def check_rust(file_name, contents):
if match:
yield (idx + 1, "missing space after ->")
- # Avoid flagging ::crate::mod
- if line.find(" :[^:]") != -1:
- yield (idx + 1, "extra space before :")
+ # Avoid flagging ::crate::mod and `trait Foo : Bar`
+ match = line.find(" :")
+ if match != -1:
+ if line[0:match].find('trait ') == -1 and line[match + 2] != ':':
+ yield (idx + 1, "extra space before :")
# Avoid flagging crate::mod
match = re.search(r"[^:]:[A-Za-z]", line)