`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
parallel_compiler
For more information about how rustc works, see the rustc dev guide.