Checks for string literals that are absolute paths into the user's home directory, e.g.,
env!("CARGO_MANIFEST_DIR").
The path might not exist when the code is used in production.
The lint does not apply inside macro arguments. So false negatives could result.
This lint doesn't warn in build scripts (build.rs) or test contexts, as they often need to reference absolute paths.
fn main() {
let path = option_env!("CARGO");
println!("{:?}", path);
}Use instead:
fn main() {
let path = std::env::var("CARGO");
println!("{:?}", path);
}