servo: Merge #13988 - test-tidy: Check for space between function name and ( (from dsprenkels:tidy-fncalls); r=Wafflespeanut
<!-- Please describe your changes on the following line: --> Disallow an extraneous space in a function call between the function name and the opening parenthesis in Rust code, while ignoring macro declarations. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy --all` does not report any errors - [x] `./mach test-tidy --self` does not report any errors - [x] These changes fix #13980 <!-- Either: --> - [x] There are tests for these changes, these are written in - `python/tidy/servo_tidy_tests/rust_tidy.rs` - `python/tidy/servo_tidy_tests/test_tidy.py` - [ ] These changes do not require tests <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: ccefef5be43b6d174933196fd7552cbbfbdf53d6
This commit is contained in:
@@ -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 =",
|
||||
|
||||
Reference in New Issue
Block a user