From b1faaa15dcae2c0ba3bebd9d668ce9e3b231932c Mon Sep 17 00:00:00 2001 From: lucantrop Date: Mon, 13 Mar 2017 13:13:46 +0100 Subject: [PATCH] added tidy check for -> () --- python/tidy/servo_tidy/tidy.py | 2 ++ python/tidy/servo_tidy_tests/rust_tidy.rs | 2 +- python/tidy/servo_tidy_tests/test_tidy.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index c8b398ce8ca..fff707a736a 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -565,6 +565,8 @@ def check_rust(file_name, lines): # This particular pattern is not reentrant-safe in script_thread.rs (r"match self.documents.borrow", "use a separate variable for the match expression", lambda match, line: file_name.endswith('script_thread.rs')), + # -> () is unnecessary + (r"-> \(\)", "encountered function signature with -> ()", no_filter), ] for pattern, message, filter_func in regex_rules: diff --git a/python/tidy/servo_tidy_tests/rust_tidy.rs b/python/tidy/servo_tidy_tests/rust_tidy.rs index e7efa2c0cbb..7a65de0ffcc 100644 --- a/python/tidy/servo_tidy_tests/rust_tidy.rs +++ b/python/tidy/servo_tidy_tests/rust_tidy.rs @@ -38,7 +38,7 @@ impl test { } } - fn test_fun2(y : &String, z : &Vec, r: &Root) -> f32 { + fn test_fun2(y : &String, z : &Vec, r: &Root) -> () { let x = true; x && x; diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index fcc11cb673f..a50d92b241e 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -123,6 +123,7 @@ class CheckTidiness(unittest.TestCase): self.assertEqual('use &[T] instead of &Vec', errors.next()[2]) self.assertEqual('use &str instead of &String', errors.next()[2]) self.assertEqual('use &T instead of &Root', errors.next()[2]) + self.assertEqual('encountered function signature with -> ()', errors.next()[2]) self.assertEqual('operators should go at the end of the first line', errors.next()[2]) self.assertEqual('else braces should be on the same line', errors.next()[2]) self.assertEqual('extra space after (', errors.next()[2])