@@ -3,7 +3,7 @@ use base_db::Env;
3
3
use rustc_hash:: FxHashMap ;
4
4
use toolchain:: Tool ;
5
5
6
- use crate :: { utf8_stdout, ManifestPath , PackageData , Sysroot , TargetKind } ;
6
+ use crate :: { utf8_stdout, CargoWorkspace , ManifestPath , PackageData , Sysroot , TargetKind } ;
7
7
8
8
/// Recreates the compile-time environment variables that Cargo sets.
9
9
///
@@ -50,13 +50,23 @@ pub(crate) fn inject_cargo_env(env: &mut Env) {
50
50
env. set ( "CARGO" , Tool :: Cargo . path ( ) . to_string ( ) ) ;
51
51
}
52
52
53
- pub ( crate ) fn inject_rustc_tool_env ( env : & mut Env , cargo_name : & str , kind : TargetKind ) {
53
+ pub ( crate ) fn inject_rustc_tool_env (
54
+ env : & mut Env ,
55
+ cargo : & CargoWorkspace ,
56
+ cargo_name : & str ,
57
+ kind : TargetKind ,
58
+ ) {
54
59
_ = kind;
55
60
// FIXME
56
61
// if kind.is_executable() {
57
62
// env.set("CARGO_BIN_NAME", cargo_name);
58
63
// }
59
64
env. set ( "CARGO_CRATE_NAME" , cargo_name. replace ( '-' , "_" ) ) ;
65
+ // NOTE: Technically we should set this for all crates, but that will worsen the deduplication
66
+ // logic so for now just keeping it proc-macros ought to be fine.
67
+ if kind. is_proc_macro ( ) {
68
+ env. set ( "CARGO_RUSTC_CURRENT_DIR" , cargo. manifest_path ( ) . to_string ( ) ) ;
69
+ }
60
70
}
61
71
62
72
pub ( crate ) fn cargo_config_env (
0 commit comments