From ab73f3d61d895289898821272f6af2665c9c645c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DAVID?= Date: Mon, 21 Aug 2017 22:56:05 +0200 Subject: Automatically verify that derive() lists are alphabetically ordered --- python/tidy/servo_tidy/tidy.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python/tidy/servo_tidy/tidy.py') 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 constructs def is_associated_type(match, line): -- cgit v1.2.3