rustc_lint::unqualified_local_imports

Static UNQUALIFIED_LOCAL_IMPORTS

Source
pub static UNQUALIFIED_LOCAL_IMPORTS: &Lint
Expand description

The unqualified_local_imports lint checks for use items that import a local item using a path that does not start with self::, super::, or crate::.

§Example

#![warn(unqualified_local_imports)]

mod localmod {
    pub struct S;
}

use localmod::S;

{{produces}}

§Explanation

This lint is meant to be used with the (unstable) rustfmt setting group_imports = "StdExternalCrate". That setting makes rustfmt group self::, super::, and crate:: imports separately from those refering to other crates. However, rustfmt cannot know whether use c::S; refers to a local module c or an external crate c, so it always gets categorized as an import from another crate. To ensure consistent grouping of imports from the local crate, all local imports must start with self::, super::, or crate::. This lint can be used to enforce that style.