aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/syntax_ptr.rs7
-rw-r--r--crates/tools/src/lib.rs31
2 files changed, 23 insertions, 15 deletions
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs
index e23bda4d5..71e51e702 100644
--- a/crates/ra_analysis/src/syntax_ptr.rs
+++ b/crates/ra_analysis/src/syntax_ptr.rs
@@ -1,9 +1,4 @@
1use std::marker::PhantomData; 1use ra_syntax::{File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange};
2
3use ra_syntax::{
4 ast::{self, AstNode},
5 File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange,
6};
7 2
8use crate::db::SyntaxDatabase; 3use crate::db::SyntaxDatabase;
9use crate::FileId; 4use crate::FileId;
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs
index 3387d0620..8b8e9974e 100644
--- a/crates/tools/src/lib.rs
+++ b/crates/tools/src/lib.rs
@@ -4,7 +4,7 @@ extern crate teraron;
4 4
5use std::{ 5use std::{
6 path::{Path, PathBuf}, 6 path::{Path, PathBuf},
7 process::Command, 7 process::{Command, Stdio},
8}; 8};
9 9
10use failure::bail; 10use failure::bail;
@@ -92,14 +92,16 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> {
92} 92}
93 93
94pub fn run_rustfmt(mode: Mode) -> Result<()> { 94pub fn run_rustfmt(mode: Mode) -> Result<()> {
95 run(&format!("rustup install {}", TOOLCHAIN), ".")?; 95 match Command::new("rustup")
96 run( 96 .args(&["run", TOOLCHAIN, "--", "cargo", "fmt", "--version"])
97 &format!( 97 .stderr(Stdio::null())
98 "rustup component add rustfmt-preview --toolchain {}", 98 .stdout(Stdio::null())
99 TOOLCHAIN 99 .status()
100 ), 100 {
101 ".", 101 Ok(status) if status.success() => (),
102 )?; 102 _ => install_rustfmt()?,
103 };
104
103 if mode == Verify { 105 if mode == Verify {
104 run( 106 run(
105 &format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN), 107 &format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN),
@@ -110,3 +112,14 @@ pub fn run_rustfmt(mode: Mode) -> Result<()> {
110 } 112 }
111 Ok(()) 113 Ok(())
112} 114}
115
116fn install_rustfmt() -> Result<()> {
117 run(&format!("rustup install {}", TOOLCHAIN), ".")?;
118 run(
119 &format!(
120 "rustup component add rustfmt-preview --toolchain {}",
121 TOOLCHAIN
122 ),
123 ".",
124 )
125}