How to make the import paths consistent?

I want to find a way to make sure that all the import paths in my project are consistent with each other.
For example, I want the import paths of A in b.rs and c.rs to be the same (either crate::A or crate::a::A is ok).
Is there a rustfmt rule or a clippy rule which can enforce that?

// lib.rs
pub use a::A;

pub(crate) mod a;
pub(crate) mod b;
pub(crate) mod c;

// a.rs
pub struct A;

// b.rs
// 1
use crate::A;
// 2
use crate::a::A;

struct B(A);

// c.rs
// 1
use crate::A;
// 2
use crate::a::A;

struct C(A);

As far as I know, not at this point in time. If there's not an open issue, you could open an issue for clippy (this isn't a rustfmt thing).

1 Like

I opened an issue Lint against inconsistent import paths · Issue #12878 · rust-lang/rust-clippy · GitHub

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.