Skip to content

[Traits] Correctly diagnose unused dependency with traits #7702

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

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

FranzBusch
Copy link
Member

Motivation

We are currently diagnosing unused dependencies by looking at the list of products used by the final modules and check if for every root dependency we are using at least one product of that package. This incorrectly diagnosis unused dependencies if the usage of the dependency is either:

  • Just declared to enable a trait if down the graph another package is depending on it
  • Used as an optional dependency and the trait is disabled

Modification

This PR adds two more checks to the diagnostic pass to find unused dependencies. We first create a set of dependency products that are guarded by a trait. When checking each dependency we then check if we enabled any trait on the dependency since this means it is used for setting a trait. We also check if any product of the dependency is guarded by a trait to identify if it was an optional dependency.

Result

No more incorrect unused dependency warnings.

@FranzBusch
Copy link
Member Author

@swift-ci please test

@FranzBusch
Copy link
Member Author

@swift-ci test windows

@FranzBusch FranzBusch enabled auto-merge (squash) June 24, 2024 13:41
# Motivation

We are currently diagnosing unused dependencies by looking at the list of products used by the final modules and check if for every root dependency we are using at least one product of that package. This incorrectly diagnosis unused dependencies if the usage of the dependency is either:
- Just declared to enable a trait if down the graph another package is depending on it
- Used as an optional dependency and the trait is disabled

# Modification

This PR adds two more checks to the diagnostic pass to find unused dependencies. We first create a set of dependency products that are guarded by a trait. When checking each dependency we then check if we enabled any trait on the dependency since this means it is used for setting a trait. We also check if any product of the dependency is guarded by a trait to identify if it was an optional dependency.

# Result
No more incorrect unused dependency warnings.
@FranzBusch FranzBusch force-pushed the fb-trait-dep-diagnostic branch from 9fa51c0 to 8f0b4c4 Compare June 24, 2024 14:45
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@FranzBusch FranzBusch merged commit 5ea5824 into swiftlang:main Jun 24, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants