aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy/tidy.py
diff options
context:
space:
mode:
authorClément DAVID <c.david86@gmail.com>2017-08-21 22:56:05 +0200
committerClément DAVID <c.david86@gmail.com>2017-08-23 21:04:14 +0200
commitab73f3d61d895289898821272f6af2665c9c645c (patch)
tree7344ed312ff00f28afc9d97a29f44139bc5de655 /python/tidy/servo_tidy/tidy.py
parent16c1446137317b7e974d65119d2187b81f0d2394 (diff)
downloadservo-ab73f3d61d895289898821272f6af2665c9c645c.tar.gz
servo-ab73f3d61d895289898821272f6af2665c9c645c.zip
Automatically verify that derive() lists are alphabetically ordered
Diffstat (limited to 'python/tidy/servo_tidy/tidy.py')
-rw-r--r--python/tidy/servo_tidy/tidy.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 3bf6176de44..2c2a6275524 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -691,6 +691,19 @@ def check_rust(file_name, lines):
# we now erase previous entries
prev_mod = {}
+ # derivable traits should be alphabetically ordered
+ if is_attribute:
+ # match the derivable traits filtering out macro expansions
+ match = re.search(r"#\[derive\(([a-zA-Z, ]*)", line)
+ if match:
+ derives = map(lambda w: w.strip(), match.group(1).split(','))
+ # sort, compare and report
+ sorted_derives = sorted(derives)
+ if sorted_derives != derives:
+ yield(idx + 1, decl_message.format("derivable traits list")
+ + decl_expected.format(", ".join(sorted_derives))
+ + decl_found.format(", ".join(derives)))
+
# Avoid flagging <Item=Foo> constructs
def is_associated_type(match, line):