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

Lint suggestion: Prefer use x::y; over use x::prelude::y; #96

Open
BenjaminBrienen opened this issue Sep 21, 2024 · 6 comments
Open

Lint suggestion: Prefer use x::y; over use x::prelude::y; #96

BenjaminBrienen opened this issue Sep 21, 2024 · 6 comments
Labels
A-Linter Related to the linter and custom lints C-Enhancement A general improvement

Comments

@BenjaminBrienen
Copy link

image

@BenjaminBrienen BenjaminBrienen changed the title Prefer use x::y; over use x::prelude::y; Lint suggestion: Prefer use x::y; over use x::prelude::y; Sep 21, 2024
@BenjaminBrienen
Copy link
Author

BenjaminBrienen commented Sep 21, 2024

If we don't want to treat "prelude" as a special symbol, then we could generalize it to prefer "sub-paths".

@BD103 BD103 added A-Linter Related to the linter and custom lints C-Enhancement A general improvement labels Sep 21, 2024
@janhohenheim
Copy link
Member

janhohenheim commented Sep 21, 2024

Is there anything particularly wrong with using the import from the prelude? Imo this is more of a style thing that would be better implemented in rustfmt or clippy in general.
This is a weak opinion, don't block the lint on this if others think it's useful.

@janhohenheim
Copy link
Member

@alice-i-cecile I see on Discord that you like this lint. Could you post some motivation?

@alice-i-cecile
Copy link
Member

This is a "stylistic consistency" lint. It's helpful to reduce visual clutter and merge conflicts on imports. I also think that the reverse (prefer prelude) should be included. Clippy has a number of these, see clippy's absolute_paths lint for an analog.

@BD103
Copy link
Member

BD103 commented Sep 21, 2024

I can definitely see the stylistic reasoning behind this, but I think for now it should be disabled by default.

  1. RA usually auto-imports from the prelude, and I'm not sure if it's possible to disable this. This would make the warnings frequent and annoying.
  2. This should probably be a feature of rustfmt, but I'm cool to implement it here for now.

@alice-i-cecile
Copy link
Member

Yep, fully agree on disabled-by-default: I think that the whole style category should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Related to the linter and custom lints C-Enhancement A general improvement
Projects
Status: Todo
Development

No branches or pull requests

4 participants