Skip to content

Commit 05c7789

Browse files
committed
Move proc-macro-srv RUSTC_VERSION fetching from include to env var
1 parent f4c2ac4 commit 05c7789

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

src/tools/rust-analyzer/crates/proc-macro-srv/build.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,12 @@
44
use std::{env, fs::File, io::Write, path::PathBuf, process::Command};
55

66
fn main() {
7-
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
8-
9-
let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
10-
path.push("rustc_version.rs");
11-
let mut f = File::create(&path).unwrap();
7+
println!("cargo::rustc-check-cfg=cfg(rust_analyzer)");
128

139
let rustc = env::var("RUSTC").expect("proc-macro-srv's build script expects RUSTC to be set");
1410
let output = Command::new(rustc).arg("--version").output().expect("rustc --version must run");
1511
let version_string = std::str::from_utf8(&output.stdout[..])
1612
.expect("rustc --version output must be UTF-8")
1713
.trim();
18-
19-
write!(
20-
f,
21-
"
22-
#[allow(dead_code)]
23-
pub(crate) const RUSTC_VERSION_STRING: &str = {version_string:?};
24-
"
25-
)
26-
.unwrap();
14+
println!("cargo::rustc-env=RUSTC_VERSION={}", version_string);
2715
}

src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ use span::Span;
4848

4949
use crate::server::TokenStream;
5050

51-
// see `build.rs`
52-
include!(concat!(env!("OUT_DIR"), "/rustc_version.rs"));
51+
pub const RUSTC_VERSION_STRING: &str = env!("RUSTC_VERSION");
5352

5453
trait ProcMacroSrvSpan: Copy {
5554
type Server: proc_macro::bridge::server::Server<TokenStream = TokenStream<Self>>;

0 commit comments

Comments
 (0)