diff options
author | Daan Sprenkels <dsprenkels@gmail.com> | 2016-10-30 19:08:14 +0100 |
---|---|---|
committer | Daan Sprenkels <dsprenkels@gmail.com> | 2016-10-31 18:11:35 +0100 |
commit | 179e11ad8d834dbbc4fc14209ce0c9b169085df4 (patch) | |
tree | 1b7d814c2a5ddab14f9b3cf43fffe33dc1af59d9 /python/tidy | |
parent | 84055461aa84a730342af3c423ea394b170db076 (diff) | |
download | servo-179e11ad8d834dbbc4fc14209ce0c9b169085df4.tar.gz servo-179e11ad8d834dbbc4fc14209ce0c9b169085df4.zip |
test-tidy: Check for space between function name and `(`
Disallow an extraneous space in a function call between
the function name and the opening parenthesis in Rust
code, while ignoring macro declarations.
This commit fixes #13980.
Diffstat (limited to 'python/tidy')
-rw-r--r-- | python/tidy/servo_tidy/tidy.py | 7 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/rust_tidy.rs | 4 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/test_tidy.py | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 1dcbd4896d1..958a703c606 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -442,6 +442,13 @@ def check_rust(file_name, lines): regex_rules = [ (r",[^\s]", "missing space after ,", lambda match, line: '$' not in line and not is_attribute), + (r"([A-Za-z0-9_]+) (\()", "extra space after {0}", + lambda match, line: not ( + is_attribute or + re.match(r"\bmacro_rules!\s+", line[:match.start()]) or + re.search(r"[^']'[A-Za-z0-9_]+ \($", line[:match.end()]) or + match.group(1) in ['const', 'fn', 'for', 'if', 'in', + 'let', 'match', 'mut', 'return'])), (r"[A-Za-z0-9\"]=", "missing space before =", lambda match, line: is_attribute), (r"=[A-Za-z0-9\"]", "missing space after =", diff --git a/python/tidy/servo_tidy_tests/rust_tidy.rs b/python/tidy/servo_tidy_tests/rust_tidy.rs index 358fce3a082..79be0ff1580 100644 --- a/python/tidy/servo_tidy_tests/rust_tidy.rs +++ b/python/tidy/servo_tidy_tests/rust_tidy.rs @@ -52,7 +52,9 @@ impl test { type Text_Fun3 = fn( i32) -> i32; fn test_fun3<Text_Fun3>( y: Text_Fun3) { - test_fun( 1); + let (x, y) = (1, 2) // Should not trigger + test_fun( x); + test_fun (y); } // Should not be triggered diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index dca0c5765b1..7bec2c61718 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -124,6 +124,7 @@ class CheckTidiness(unittest.TestCase): self.assertEqual('extra space after (', errors.next()[2]) self.assertEqual('extra space after (', errors.next()[2]) self.assertEqual('extra space after (', errors.next()[2]) + self.assertEqual('extra space after test_fun', errors.next()[2]) self.assertNoMoreErrors(errors) def test_spec_link(self): |