Skip to content

internal: Teach cargo about cfg(rust_analyzer) #16257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/proc-macro-srv-cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! This teaches cargo about our cfg(rust_analyzer)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why I added these, but.. 😅.


fn main() {
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
}
2 changes: 2 additions & 0 deletions crates/proc-macro-srv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use std::{env, fs::File, io::Write, path::PathBuf, process::Command};

fn main() {
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");

let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
path.push("rustc_version.rs");
let mut f = File::create(&path).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/proc-macro-srv/proc-macro-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn main() {
println!("Creating {}", src_dir.display());
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 dst = staging_dir.clone();
for el in item_els {
Expand Down
5 changes: 5 additions & 0 deletions crates/proc-macro-srv/proc-macro-test/imp/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! This teaches cargo about our cfg(rust_analyzer)

fn main() {
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
}