This commit is contained in:
Laurențiu Nicola 2021-10-23 15:07:11 +03:00
parent fe7c516084
commit 8457ae34bd
37 changed files with 38 additions and 37 deletions

View file

@ -7,9 +7,6 @@ use xshell::{cmd, pushd};
use crate::flags;
// Latest stable, feel free to send a PR if this lags behind.
const REQUIRED_RUST_VERSION: u32 = 56;
impl flags::Install {
pub(crate) fn run(self) -> Result<()> {
if cfg!(target_os = "macos") {
@ -137,19 +134,6 @@ fn install_client(client_opt: ClientOpt) -> Result<()> {
}
fn install_server(opts: ServerOpt) -> Result<()> {
let mut old_rust = false;
if let Ok(stdout) = cmd!("cargo --version").read() {
if !check_version(&stdout, REQUIRED_RUST_VERSION) {
old_rust = true;
}
}
if old_rust {
eprintln!(
"\nWARNING: at least rust 1.{}.0 is required to compile rust-analyzer\n",
REQUIRED_RUST_VERSION,
);
}
let features = match opts.malloc {
Malloc::System => &[][..],
Malloc::Mimalloc => &["--features", "mimalloc"],
@ -157,25 +141,6 @@ fn install_server(opts: ServerOpt) -> Result<()> {
};
let cmd = cmd!("cargo install --path crates/rust-analyzer --locked --force --features force-always-assert {features...}");
let res = cmd.run();
if res.is_err() && old_rust {
eprintln!(
"\nWARNING: at least rust 1.{}.0 is required to compile rust-analyzer\n",
REQUIRED_RUST_VERSION,
);
}
res?;
cmd.run()?;
Ok(())
}
fn check_version(version_output: &str, min_minor_version: u32) -> bool {
// Parse second the number out of
// cargo 1.39.0-beta (1c6ec66d5 2019-09-30)
let minor: Option<u32> = version_output.split('.').nth(1).and_then(|it| it.parse().ok());
match minor {
None => true,
Some(minor) => minor >= min_minor_version,
}
}