mirror of https://github.com/rust-lang/rust.git
Speedup fmt
This commit is contained in:
parent
8f1a83b4cb
commit
fabb804f30
|
@ -1,9 +1,4 @@
|
||||||
use std::marker::PhantomData;
|
use ra_syntax::{File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange};
|
||||||
|
|
||||||
use ra_syntax::{
|
|
||||||
ast::{self, AstNode},
|
|
||||||
File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::db::SyntaxDatabase;
|
use crate::db::SyntaxDatabase;
|
||||||
use crate::FileId;
|
use crate::FileId;
|
||||||
|
|
|
@ -4,7 +4,7 @@ extern crate teraron;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::{Command, Stdio},
|
||||||
};
|
};
|
||||||
|
|
||||||
use failure::bail;
|
use failure::bail;
|
||||||
|
@ -92,14 +92,16 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||||
run(&format!("rustup install {}", TOOLCHAIN), ".")?;
|
match Command::new("rustup")
|
||||||
run(
|
.args(&["run", TOOLCHAIN, "--", "cargo", "fmt", "--version"])
|
||||||
&format!(
|
.stderr(Stdio::null())
|
||||||
"rustup component add rustfmt-preview --toolchain {}",
|
.stdout(Stdio::null())
|
||||||
TOOLCHAIN
|
.status()
|
||||||
),
|
{
|
||||||
".",
|
Ok(status) if status.success() => (),
|
||||||
)?;
|
_ => install_rustfmt()?,
|
||||||
|
};
|
||||||
|
|
||||||
if mode == Verify {
|
if mode == Verify {
|
||||||
run(
|
run(
|
||||||
&format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN),
|
&format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN),
|
||||||
|
@ -110,3 +112,14 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn install_rustfmt() -> Result<()> {
|
||||||
|
run(&format!("rustup install {}", TOOLCHAIN), ".")?;
|
||||||
|
run(
|
||||||
|
&format!(
|
||||||
|
"rustup component add rustfmt-preview --toolchain {}",
|
||||||
|
TOOLCHAIN
|
||||||
|
),
|
||||||
|
".",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue