Auto merge of #16257 - lnicola:rustc-check-cfg, r=Veykril

internal: Teach cargo about `cfg(rust_analyzer)`

r? `@Urgau` is this a good idea?, CC `@Veykril`
This commit is contained in:
bors 2024-04-18 12:13:06 +00:00
commit af1fd88c4d
4 changed files with 13 additions and 1 deletions

View file

@ -0,0 +1,5 @@
//! This teaches cargo about our cfg(rust_analyzer)
fn main() {
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
}

View file

@ -4,6 +4,8 @@
use std::{env, fs::File, io::Write, path::PathBuf, process::Command}; use std::{env, fs::File, io::Write, path::PathBuf, process::Command};
fn main() { fn main() {
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
path.push("rustc_version.rs"); path.push("rustc_version.rs");
let mut f = File::create(&path).unwrap(); let mut f = File::create(&path).unwrap();

View file

@ -53,7 +53,7 @@ fn main() {
println!("Creating {}", src_dir.display()); println!("Creating {}", src_dir.display());
std::fs::create_dir_all(src_dir).unwrap(); std::fs::create_dir_all(src_dir).unwrap();
for item_els in [&["Cargo.toml"][..], &["src", "lib.rs"]] { for item_els in [&["Cargo.toml"][..], &["build.rs"][..], &["src", "lib.rs"]] {
let mut src = imp_dir.clone(); let mut src = imp_dir.clone();
let mut dst = staging_dir.clone(); let mut dst = staging_dir.clone();
for el in item_els { for el in item_els {

View file

@ -0,0 +1,5 @@
//! This teaches cargo about our cfg(rust_analyzer)
fn main() {
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
}