From 8d34262956059aca7e6fded351a9299b3581a5cf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:52:28 +0200 Subject: [PATCH] Rename ra_toolchain -> toolchain --- Cargo.lock | 22 +++++++++---------- crates/flycheck/Cargo.toml | 2 +- crates/flycheck/src/lib.rs | 2 +- crates/ra_proc_macro_srv/Cargo.toml | 2 +- crates/ra_proc_macro_srv/src/tests/utils.rs | 2 +- crates/ra_project_model/Cargo.toml | 2 +- .../ra_project_model/src/cargo_workspace.rs | 4 ++-- crates/ra_project_model/src/lib.rs | 2 +- crates/ra_project_model/src/sysroot.rs | 4 ++-- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/handlers.rs | 2 +- crates/{ra_toolchain => toolchain}/Cargo.toml | 8 +++---- crates/{ra_toolchain => toolchain}/src/lib.rs | 4 +--- editors/code/src/toolchain.ts | 4 ++-- 14 files changed, 30 insertions(+), 32 deletions(-) rename crates/{ra_toolchain => toolchain}/Cargo.toml (78%) rename crates/{ra_toolchain => toolchain}/src/lib.rs (93%) diff --git a/Cargo.lock b/Cargo.lock index 598b739c7e..c48c6a5977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,8 +358,8 @@ dependencies = [ "crossbeam-channel", "jod-thread", "log", - "ra_toolchain", "serde_json", + "toolchain", ] [[package]] @@ -1143,9 +1143,9 @@ dependencies = [ "memmap", "ra_mbe", "ra_proc_macro", - "ra_toolchain", "serde_derive", "test_utils", + "toolchain", "tt", ] @@ -1161,11 +1161,11 @@ dependencies = [ "ra_cfg", "ra_db", "ra_proc_macro", - "ra_toolchain", "rustc-hash", "serde", "serde_json", "stdx", + "toolchain", ] [[package]] @@ -1210,13 +1210,6 @@ dependencies = [ "text-size", ] -[[package]] -name = "ra_toolchain" -version = "0.1.0" -dependencies = [ - "home", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1320,7 +1313,6 @@ dependencies = [ "ra_ssr", "ra_syntax", "ra_text_edit", - "ra_toolchain", "rayon", "rustc-hash", "serde", @@ -1328,6 +1320,7 @@ dependencies = [ "stdx", "test_utils", "threadpool", + "toolchain", "tt", "vfs", "vfs-notify", @@ -1612,6 +1605,13 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +[[package]] +name = "toolchain" +version = "0.0.0" +dependencies = [ + "home", +] + [[package]] name = "tracing" version = "0.1.18" diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index ff8a1e5689..acc72bc59c 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml @@ -14,4 +14,4 @@ log = "0.4.8" cargo_metadata = "0.11.1" serde_json = "1.0.48" jod-thread = "0.1.1" -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 31e14246de..16078d1043 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -193,7 +193,7 @@ impl FlycheckActor { extra_args, features, } => { - let mut cmd = Command::new(ra_toolchain::cargo()); + let mut cmd = Command::new(toolchain::cargo()); cmd.arg(command); cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) .arg(self.workspace_root.join("Cargo.toml")); diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index a690cc0443..1c25e72296 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml @@ -23,4 +23,4 @@ cargo_metadata = "0.11.1" difference = "2.0.0" # used as proc macro test target serde_derive = "1.0.106" -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/ra_proc_macro_srv/src/tests/utils.rs index dcb00671ff..1b6a0b6fb7 100644 --- a/crates/ra_proc_macro_srv/src/tests/utils.rs +++ b/crates/ra_proc_macro_srv/src/tests/utils.rs @@ -12,7 +12,7 @@ mod fixtures { // Use current project metadata to get the proc-macro dylib path pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { - let command = Command::new(ra_toolchain::cargo()) + let command = Command::new(toolchain::cargo()) .args(&["check", "--message-format", "json"]) .output() .unwrap() diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 27b1f5d33f..171fe86264 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml @@ -17,7 +17,7 @@ cargo_metadata = "0.11.1" arena = { path = "../arena" } ra_cfg = { path = "../ra_cfg" } ra_db = { path = "../ra_db" } -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } ra_proc_macro = { path = "../ra_proc_macro" } paths = { path = "../paths" } stdx = { path = "../stdx" } diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index a526d743d4..abf8dca964 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -140,7 +140,7 @@ impl CargoWorkspace { cargo_features: &CargoConfig, ) -> Result { let mut meta = MetadataCommand::new(); - meta.cargo_path(ra_toolchain::cargo()); + meta.cargo_path(toolchain::cargo()); meta.manifest_path(cargo_toml.to_path_buf()); if cargo_features.all_features { meta.features(CargoOpt::AllFeatures); @@ -288,7 +288,7 @@ pub fn load_extern_resources( cargo_toml: &Path, cargo_features: &CargoConfig, ) -> Result { - let mut cmd = Command::new(ra_toolchain::cargo()); + let mut cmd = Command::new(toolchain::cargo()); cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); if cargo_features.all_features { cmd.arg("--all-features"); diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 300e751355..46f44910c0 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -513,7 +513,7 @@ fn get_rustc_cfg_options(target: Option<&str>) -> Vec { } let rustc_cfgs = { - let mut cmd = Command::new(ra_toolchain::rustc()); + let mut cmd = Command::new(toolchain::rustc()); cmd.args(&["--print", "cfg", "-O"]); if let Some(target) = target { cmd.args(&["--target", target]); diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index 6ef001769c..8239797b6b 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs @@ -101,13 +101,13 @@ fn get_or_install_rust_src(cargo_toml: &AbsPath) -> Result { return Ok(path); } let current_dir = cargo_toml.parent().unwrap(); - let mut rustc = Command::new(ra_toolchain::rustc()); + let mut rustc = Command::new(toolchain::rustc()); rustc.current_dir(current_dir).args(&["--print", "sysroot"]); let stdout = utf8_stdout(rustc)?; let sysroot_path = AbsPath::assert(Path::new(stdout.trim())); let mut src = get_rust_src(sysroot_path); if src.is_none() { - let mut rustup = Command::new(ra_toolchain::rustup()); + let mut rustup = Command::new(toolchain::rustup()); rustup.current_dir(current_dir).args(&["component", "add", "rust-src"]); utf8_stdout(rustup)?; src = get_rust_src(sysroot_path); diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 9bc5cc6314..3f70510fd7 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -43,7 +43,7 @@ ra_text_edit = { path = "../ra_text_edit" } vfs = { path = "../vfs" } vfs-notify = { path = "../vfs-notify" } ra_cfg = { path = "../ra_cfg" } -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } # This should only be used in CLI ra_db = { path = "../ra_db" } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index d9b75eed45..07f4af3d3b 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -692,7 +692,7 @@ pub(crate) fn handle_formatting( let mut rustfmt = match &snap.config.rustfmt { RustfmtConfig::Rustfmt { extra_args } => { - let mut cmd = process::Command::new(ra_toolchain::rustfmt()); + let mut cmd = process::Command::new(toolchain::rustfmt()); cmd.args(extra_args); if let Some(&crate_id) = crate_ids.first() { // Assume all crates are in the same edition diff --git a/crates/ra_toolchain/Cargo.toml b/crates/toolchain/Cargo.toml similarity index 78% rename from crates/ra_toolchain/Cargo.toml rename to crates/toolchain/Cargo.toml index 84b748c0a4..4856668f84 100644 --- a/crates/ra_toolchain/Cargo.toml +++ b/crates/toolchain/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_toolchain" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "toolchain" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_toolchain/src/lib.rs b/crates/toolchain/src/lib.rs similarity index 93% rename from crates/ra_toolchain/src/lib.rs rename to crates/toolchain/src/lib.rs index 9916e52c48..3b6886f5b5 100644 --- a/crates/ra_toolchain/src/lib.rs +++ b/crates/toolchain/src/lib.rs @@ -1,6 +1,4 @@ -//! This crate contains a single public function -//! [`get_path_for_executable`](fn.get_path_for_executable.html). -//! See docs there for more information. +//! Discovery of `cargo` & `rustc` executables. use std::{env, iter, path::PathBuf}; pub fn cargo() -> PathBuf { diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 80a7915e90..a5dc3cf0cc 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts @@ -121,12 +121,12 @@ export class Cargo { } } -/** Mirrors `ra_toolchain::cargo()` implementation */ +/** Mirrors `toolchain::cargo()` implementation */ export function cargoPath(): string { return getPathForExecutable("cargo"); } -/** Mirrors `ra_toolchain::get_path_for_executable()` implementation */ +/** Mirrors `toolchain::get_path_for_executable()` implementation */ export const getPathForExecutable = memoize( // We apply caching to decrease file-system interactions (executableName: "cargo" | "rustc" | "rustup"): string => {