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

turn on clippy::wildcard_imports #692

Merged

Conversation

OmarTawfik
Copy link
Contributor

@OmarTawfik OmarTawfik commented Dec 3, 2023

cc @Xanewok for context: #680 (comment)

This works well on use foo::* and allows automatic fixing/replacing. But it doesn't work on pub use foo::*. I looked into doing that manually, but realized that for public re-exports, it is actually much more work to do/maintain than the readability benefits it offers, especially when items have different visibility, and there are generated items.

Taking non_terminals/mod.rs, I think the below list is a lot of noise, and requires manual work every time we add/remove something. I suggest allowing pub use foo::* for these reasons, and use it as appropriate.

pub use enum_::{EnumItem, EnumVariant};
pub use field::{Field, FieldDelimiters, FieldKind, FieldsErrorRecovery};
pub use precedence::{PrecedenceExpression, PrecedenceItem, PrecedenceOperator, PrimaryExpression};
pub use repeated::RepeatedItem;
pub use separated::SeparatedItem;
pub use struct_::StructItem;

pub(crate) use enum_::{SpannedEnumItem, SpannedEnumVariant};
pub(crate) use field::{
    SpannedField, SpannedFieldDelimiters, SpannedFieldKind, SpannedFieldsErrorRecovery,
};
pub(crate) use precedence::{
    SpannedPrecedenceExpression, SpannedPrecedenceItem, SpannedPrecedenceOperator,
    SpannedPrimaryExpression,
};
pub(crate) use repeated::SpannedRepeatedItem;
pub(crate) use separated::SpannedSeparatedItem;
pub(crate) use struct_::SpannedStructItem;

@OmarTawfik OmarTawfik requested a review from a team as a code owner December 3, 2023 15:18
@OmarTawfik OmarTawfik enabled auto-merge December 3, 2023 15:18
Copy link

changeset-bot bot commented Dec 3, 2023

⚠️ No Changeset found

Latest commit: 5cebd98

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@OmarTawfik OmarTawfik marked this pull request as draft December 3, 2023 15:25
auto-merge was automatically disabled December 3, 2023 15:25

Pull request was converted to draft

@OmarTawfik OmarTawfik force-pushed the clippy-wildcard_imports branch from 3b03f0a to 5cebd98 Compare December 3, 2023 15:38
@OmarTawfik OmarTawfik marked this pull request as ready for review December 3, 2023 15:38
@OmarTawfik OmarTawfik enabled auto-merge December 3, 2023 15:39
@Xanewok
Copy link
Contributor

Xanewok commented Dec 4, 2023

and there are generated items

Like I said at some point, pub-use-glob has use cases and the one with generated items is definitely fitting; however, there are many other places across the codebase where explicitly exporting items would be more fitting, instead.

Regardless of that, import globs are also not ideal, especially super::* (if not used in inline modules). It's great that we're now linting against that, thanks!

@OmarTawfik OmarTawfik added this pull request to the merge queue Dec 4, 2023
Merged via the queue into NomicFoundation:main with commit af6ca1e Dec 4, 2023
1 check passed
@OmarTawfik OmarTawfik deleted the clippy-wildcard_imports branch December 4, 2023 14:01
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