-
-
Notifications
You must be signed in to change notification settings - Fork 16k
exported_private_dependencies lint misses blanket implementations #162050
Copy link
Copy link
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-visibilityArea: Visibility / privacyArea: Visibility / privacyF-public_private_dependenciesfeature: public_private_dependenciesfeature: public_private_dependenciesL-exported_private_dependenciesLint: exported_private_dependenciesLint: exported_private_dependenciesneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-visibilityArea: Visibility / privacyArea: Visibility / privacyF-public_private_dependenciesfeature: public_private_dependenciesfeature: public_private_dependenciesL-exported_private_dependenciesLint: exported_private_dependenciesLint: exported_private_dependenciesneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Code
Current output
Desired output
Either lint the impl or decide that this is ok.
Rationale and extra context
This can be used to add implementations that leak private dependencies. If we update the private dependency, the implementation may disappear (and implementation for the new version may appear).
I cannot come up with a reasonable use-case for anyone to do this though. The only thing that comes to mind is some kind of merge of sealed trait and extension trait. Or a public extension trait for types that implement a private trait.
So maybe we don't need to worry about that, and just ignore this. But I'd like to flag it anyway and get someone else's opinion on that.
I'm not sure how complex the implementation for linting this could get as we might have to do some orphan-rule-like checks on what a given blanked impl could cover. But I haven't given that much thought.
Other versions
Similar cases which should not lint as they're valid and used in production code from my experience:
Extension traits:
As long as
Servicecomes from a public dependency, this should be ok. Any updates of our private dependencies do not change what types (from private dependencies or otherwise) are or are not implemented.Unrestricted blanket impl:
should always be allowed. That case cannot break anything as all types have an implementation regardless of version (updating private dependency never adds or removes any implementations in that case).
Rust Version
Anything else?
Tracking issue for the lint #44663
@rustbot label +F-public_private_dependencies +L-exported_private_dependencies +A-lints +A-visibility
Changes to this lint are currently reviewed in #160726 but it doesn't change this.