macro

module_path! — Identify the current module path

Yield a static string naming the current module path, starting with the crate name. This is useful in diagnostics. Changing module or crate names can change the result, so do not use it as an immutable business identifier. Expression result: &'static str. Expected result (not executed): stdout: 'Report module: true\n'; no stderr. Common mistake: Assuming module_path! returns a filesystem path.

Formal Syntax & Structure

rust syntaxrust
module_path!()

Working Example

Example Snippetrust
mod reports {    pub fn location() -> &'static str { module_path!() }}fn main() { println!("Report module: {}", reports::location().ends_with("::reports")); }
Rust Reference