diff options
Diffstat (limited to 'python/tidy')
-rw-r--r-- | python/tidy/servo_tidy/tidy.py | 13 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/rust_tidy.rs | 1 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/test_tidy.py | 1 |
3 files changed, 15 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): diff --git a/python/tidy/servo_tidy_tests/rust_tidy.rs b/python/tidy/servo_tidy_tests/rust_tidy.rs index bed4664a279..c1be1695156 100644 --- a/python/tidy/servo_tidy_tests/rust_tidy.rs +++ b/python/tidy/servo_tidy_tests/rust_tidy.rs @@ -21,6 +21,7 @@ extern crate webrender_api; extern crate style_traits; #[foo = "bar,baz"] +#[derive(Copy,Debug, ComputeSquaredDistance)] impl test { fn test_fun(y:f32)->f32{ diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index df8bf316cd0..73a37cd4612 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -107,6 +107,7 @@ class CheckTidiness(unittest.TestCase): self.assertTrue('mod declaration is not in alphabetical order' in errors.next()[2]) self.assertEqual('mod declaration spans multiple lines', errors.next()[2]) self.assertTrue('extern crate declaration is not in alphabetical order' in errors.next()[2]) + self.assertTrue('derivable traits list is not in alphabetical order' in errors.next()[2]) self.assertEqual('found an empty line following a {', errors.next()[2]) self.assertEqual('missing space before ->', errors.next()[2]) self.assertEqual('missing space after ->', errors.next()[2]) |