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

Implement trait_newly_sealed new lint #876

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

dmatos2012
Copy link
Contributor

@dmatos2012 dmatos2012 commented Aug 20, 2024

Should contribute to #870 by adding trait becoming newly sealed lint. Welcome any feedback as I am by no means a rust expert and first time contributor here.

Edit: Not sure if there is a standard for the reference_link, as sealed traits didnt have a specific section. Also not sure if i am missing any cursed sealed impls, but welcome any newer ones that should be added.

Thanks!

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work — merging right away 🚀

Thank you for contributing 🙌

description: "A public trait became sealed, so users of this trait can not implement it anymore",
required_update: Major,
lint_level: Deny,
reference_link: Some("https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great reference link!

src/lints/trait_newly_sealed.ron Outdated Show resolved Hide resolved
@obi1kenobi obi1kenobi enabled auto-merge (squash) August 20, 2024 22:45
@obi1kenobi obi1kenobi merged commit 3fd4e5a into obi1kenobi:main Aug 20, 2024
32 checks passed
@obi1kenobi
Copy link
Owner

obi1kenobi commented Aug 20, 2024

Also not sure if i am missing any cursed sealed impls, but welcome any newer ones that should be added.

The current test cases are great. The lint tests cases are ones where we want to catch situations where the query in the lint itself might have a typo or a bug. If the engine running the query has misclassified a trait as sealed when it isn't (or vice versa), that's an upstream bug not a bug in the lint itself. We already have a large test suite of cursed sealed and "can't believe it's not sealed" trait patterns specifically to ensure our analysis of whether a trait is sealed remains accurate.

This is one of the advantages of using Trustfall for a linter: you don't have to be an expert in "what are all the ways to seal a trait" in order to lint for sealed traits! We've already plugged in that knowledge into the query graph, and now it's accessible at the low low cost of writing a query 😁

@dmatos2012
Copy link
Contributor Author

Excellent work — merging right away 🚀

Thank you for contributing 🙌

Thanks so much for the encouragement on 'X', and the awesome code. Hope I can contribute further either here or TrustFall if there are issues which are not at "expert" levels. :D Looking foward !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants