Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint check for `&Dom<` and `&DomRoot<` #25342

Closed
jdm opened this issue Dec 19, 2019 · 7 comments
Closed

Add lint check for `&Dom<` and `&DomRoot<` #25342

jdm opened this issue Dec 19, 2019 · 7 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Dec 19, 2019

&Dom<T> and &DomRoot<T> are strictly less expressive than &T, so there's no reason to use them.

Code:

# No benefit to using &Root<T>
(r": &Root<", "use &T instead of &Root<T>", no_filter),

@highfive
Copy link

@highfive highfive commented Dec 19, 2019

@jdm jdm added the E-easy label Dec 19, 2019
@highfive
Copy link

@highfive highfive commented Dec 19, 2019

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@lberrymage
Copy link
Contributor

@lberrymage lberrymage commented Dec 20, 2019

@highfive: assign me

@highfive highfive added the C-assigned label Dec 20, 2019
@highfive
Copy link

@highfive highfive commented Dec 20, 2019

Hey @lberrymage! Thanks for your interest in working on this issue. It's now assigned to you!

@jdm
Copy link
Member Author

@jdm jdm commented Dec 20, 2019

After making the change, I expect ./mach test-tidy --all will report some existing uses that should be cleaned up.

@lberrymage
Copy link
Contributor

@lberrymage lberrymage commented Dec 20, 2019

Good to know, thanks. Would it be best to correct those uses first to ensure each commit passes tests individually?

@jdm
Copy link
Member Author

@jdm jdm commented Dec 20, 2019

Putting them in the same commit would be nice, but it also isn't a hard requirement.

@lberrymage lberrymage mentioned this issue Dec 20, 2019
2 of 4 tasks complete
bors-servo added a commit that referenced this issue Dec 21, 2019
Add &DomRoot<T> lint check

So far, the lint check code appears to work as intended. However, some trait implementations require modification to pass the lint check and I'm not sure how to fix these. Commit 92cf5d5 attempts to correct one of the implementations, but fails to compile with error:
```
  --> components/script/dom/servoparser/xml.rs:76:36
   |
76 |         tree_builder.trace_handles(&tracer);
   |                                    ^^^^^^^ expected struct `dom::bindings::root::Dom`, found struct `dom::node::Node`
   |
   = note: expected struct `dom::bindings::root::Dom<dom::node::Node>`
              found struct `dom::node::Node`
   = note: required for the cast to the object type `dyn html5ever::tree_builder::Tracer<Handle = dom::bindings::root::Dom<dom::node::Node>>`
```
I've tried to debug further but to no avail. I also don't want to mangle too much existing code unnecessarily. Any help is appreciated.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
`./mach test-tidy --all` does, and some are directly related to this PR
- [ ] These changes fix #25342
The fix is a WIP

<!-- Either: -->
- [X] There are tests for these changes

Note that I will clean up the commit history before the final PR.
<!-- 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. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.