I don't think rustc sets any environment variables, instead it has a bunch of internal macros which will do roughly the same. For example there is line!(), column!(), file!(), and module_path!(). In particular you could use that last one to extract the name of the current crate.