RS.CLIPPY.DUPLICATE_MOD

File loaded as module multiple times

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: duplicate_mod. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for files that are included as modules multiple times.

Why is this bad?

Loading a file as a module more than once causes it to be compiled multiple times, taking longer and putting duplicate content into the module tree.

Example

// lib.rs
mod a;
mod b;
// a.rs
#[path = "./b.rs"]
mod b;

Use instead:

// lib.rs
mod a;
mod b;
// a.rs
use crate::b;