Skip to content

Commit

Permalink
Auto merge of #5882 - dima74:ra_setup-prevent-compile-rustc, r=Manish…
Browse files Browse the repository at this point in the history
…earth

Prevent compile parts of rustc when using `cargo dev ra-setup`

Currently after running `cargo dev ra-setup` the following lines are added to `Cargo.toml`:

```toml
[target]
rustc_data_structures = { path = ".../rust/src/librustc_data_structures" }
rustc_driver = { path = ".../rust/src/librustc_driver" }
rustc_errors = { path = ".../rust/src/librustc_errors" }
rustc_interface = { path = ".../rust/src/librustc_interface" }
rustc_middle = { path = ".../rust/src/librustc_middle" }
```

This pull request adds dependencies for `rustc` crates under `cfg(NOT_A_PLATFORM)`, thus preventing them from compiling together with clippy:

```toml
[target.'cfg(NOT_A_PLATFORM)'.dependencies]
rustc_data_structures = { path = ".../rust/src/librustc_data_structures" }
rustc_driver = { path = ".../rust/src/librustc_driver" }
rustc_errors = { path = ".../rust/src/librustc_errors" }
rustc_interface = { path = ".../rust/src/librustc_interface" }
rustc_middle = { path = ".../rust/src/librustc_middle" }
```

---

This approach was [originally proposed for IntelliJ Rust](intellij-rust/intellij-rust#1618 (comment)), and looks like it works for rust-analyzer too.

changelog: none
  • Loading branch information
bors committed Aug 9, 2020
2 parents 70c46de + 6af9693 commit 7228368
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_dev/src/ra_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ fn inject_deps_into_manifest(
});

// format a new [dependencies]-block with the new deps we need to inject
let mut all_deps = String::from("[dependencies]\n");
let mut all_deps = String::from("[target.'cfg(NOT_A_PLATFORM)'.dependencies]\n");
new_deps.for_each(|dep_line| {
all_deps.push_str(&dep_line);
});
all_deps.push_str("\n[dependencies]\n");

// replace "[dependencies]" with
// [dependencies]
Expand Down

0 comments on commit 7228368

Please sign in to comment.