macro_rules! file { () => { ... };}Expand description
Expands to the file name in which it was invoked.
Withline! andcolumn!, these macros provide debugging information fordevelopers about the location within the source.
The expanded expression has type&'static str, and the returned fileis not the invocation of thefile! macro itself, but rather thefirst macro invocation leading up to the invocation of thefile!macro.
The file name is derived from the crate root’s source path passed to the Rust compilerand the sequence the compiler takes to get from the crate root to themodule containingfile!, modified by any flags passed to the Rust compiler (e.g.--remap-path-prefix). If the crate’s source path is relative, the initial basedirectory will be the working directory of the Rust compiler. For example, if the sourcepath passed to the compiler is./src/lib.rs which has amod foo; with a source path ofsrc/foo/mod.rs, then callingfile! insidemod foo; will return./src/foo/mod.rs.
Future compiler options might make further changes to the behavior offile!,including potentially making it entirely empty. Code (e.g. test libraries)relying onfile! producing an openable file path would be incompatiblewith such options, and might wish to recommend not using those options.