mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Auto merge of #18179 - davidcl:master, r=jdm
Automatically verify that derive() lists are alphabetically ordered #… <!-- Please describe your changes on the following line: --> Automatically verify that derive() lists are alphabetically ordered #18172 --- <!-- 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` does not report any errors - [X] These changes fix #18172 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18179) <!-- Reviewable:end -->
This commit is contained in:
commit
4743696189
197 changed files with 568 additions and 552 deletions
|
@ -692,6 +692,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):
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue