Skip to content

Commit

Permalink
remove execution_root and output_base CLI args
Browse files Browse the repository at this point in the history
  • Loading branch information
bobozaur committed Jan 21, 2025
1 parent 5cfeac9 commit 13b3921
Showing 1 changed file with 3 additions and 36 deletions.
39 changes: 3 additions & 36 deletions tools/rust_analyzer/bin/discover_rust_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,41 +147,16 @@ impl Config {
pub fn parse() -> anyhow::Result<Self> {
let ConfigParser {
workspace,
execution_root,
output_base,
bazel,
bazelrc,
rust_analyzer_argument,
} = ConfigParser::parse();

// Implemented this way instead of a classic `if let` to satisfy the
// borrow checker.
// See: <https://github.com/rust-lang/rust/issues/54663>
#[allow(clippy::unnecessary_unwrap)]
if workspace.is_some() && execution_root.is_some() && output_base.is_some() {
return Ok(Config {
workspace: workspace.unwrap(),
execution_root: execution_root.unwrap(),
output_base: output_base.unwrap(),
bazel,
bazelrc,
rust_analyzer_argument,
});
}

// We need some info from `bazel info`. Fetch it now.
let mut info_map = get_bazel_info(
&bazel,
workspace.as_deref(),
output_base.as_deref(),
bazelrc.as_deref(),
)?;
let mut info_map = get_bazel_info(&bazel, Some(&workspace), None, None)?;

let config = Config {
workspace: info_map
.remove("workspace")
.expect("'workspace' must exist in bazel info")
.into(),
workspace,
execution_root: info_map
.remove("execution_root")
.expect("'execution_root' must exist in bazel info")
Expand All @@ -203,15 +178,7 @@ impl Config {
struct ConfigParser {
/// The path to the Bazel workspace directory. If not specified, uses the result of `bazel info workspace`.
#[clap(long, env = "BUILD_WORKSPACE_DIRECTORY")]
workspace: Option<Utf8PathBuf>,

/// The path to the Bazel execution root. If not specified, uses the result of `bazel info execution_root`.
#[clap(long)]
execution_root: Option<Utf8PathBuf>,

/// The path to the Bazel output user root. If not specified, uses the result of `bazel info output_base`.
#[clap(long, env = "OUTPUT_BASE")]
output_base: Option<Utf8PathBuf>,
workspace: Utf8PathBuf,

/// The path to a Bazel binary.
#[clap(long, default_value = "bazel")]
Expand Down

0 comments on commit 13b3921

Please sign in to comment.