Skip to content

Force absolute path for some items #14520

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

Open
TheElectronWill opened this issue Apr 2, 2025 · 0 comments
Open

Force absolute path for some items #14520

TheElectronWill opened this issue Apr 2, 2025 · 0 comments
Labels
A-lint Area: New lints

Comments

@TheElectronWill
Copy link

What it does

Lint absolute_paths (#10568) warns about items that use an absolute path instead of a use.
Clippy misses the opposite lint: warn about unqualified paths that are imported where they should not.

Advantage

An example is the log crate, which is often used as log::info! or log::error!. Unfortunately, newcomers may be tempted to import the macros from the log crate.

For consistency, it would be good to have an option to enforce the use of the full path with clippy.

Drawbacks

No response

Example

use log::error;

fn f() {
    error!("fatal error in f");
}

Could be written as:

fn f() {
    log::error!("fatal error in f");
}
@TheElectronWill TheElectronWill added the A-lint Area: New lints label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

1 participant