diff options
Diffstat (limited to 'crates/rust-analyzer/src/bin/main.rs')
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index a0b611bff..f0abb5b15 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs | |||
@@ -3,13 +3,14 @@ | |||
3 | //! Based on cli flags, either spawns an LSP server, or runs a batch analysis | 3 | //! Based on cli flags, either spawns an LSP server, or runs a batch analysis |
4 | mod flags; | 4 | mod flags; |
5 | mod logger; | 5 | mod logger; |
6 | mod rustc_wrapper; | ||
6 | 7 | ||
7 | use std::{convert::TryFrom, env, fs, path::Path, process}; | 8 | use std::{convert::TryFrom, env, fs, path::Path, process}; |
8 | 9 | ||
9 | use lsp_server::Connection; | 10 | use lsp_server::Connection; |
10 | use project_model::ProjectManifest; | 11 | use project_model::ProjectManifest; |
11 | use rust_analyzer::{ | 12 | use rust_analyzer::{ |
12 | cli::{self, AnalysisStatsCmd, BenchCmd}, | 13 | cli::{self, AnalysisStatsCmd}, |
13 | config::Config, | 14 | config::Config, |
14 | from_json, | 15 | from_json, |
15 | lsp_ext::supports_utf8, | 16 | lsp_ext::supports_utf8, |
@@ -26,6 +27,20 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | |||
26 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | 27 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; |
27 | 28 | ||
28 | fn main() { | 29 | fn main() { |
30 | if std::env::var("RA_RUSTC_WRAPPER").is_ok() { | ||
31 | let mut args = std::env::args_os(); | ||
32 | let _me = args.next().unwrap(); | ||
33 | let rustc = args.next().unwrap(); | ||
34 | let code = match rustc_wrapper::run_rustc_skipping_cargo_checking(rustc, args.collect()) { | ||
35 | Ok(rustc_wrapper::ExitCode(code)) => code.unwrap_or(102), | ||
36 | Err(err) => { | ||
37 | eprintln!("{}", err); | ||
38 | 101 | ||
39 | } | ||
40 | }; | ||
41 | process::exit(code); | ||
42 | } | ||
43 | |||
29 | if let Err(err) = try_main() { | 44 | if let Err(err) = try_main() { |
30 | log::error!("Unexpected error: {}", err); | 45 | log::error!("Unexpected error: {}", err); |
31 | eprintln!("{}", err); | 46 | eprintln!("{}", err); |
@@ -78,19 +93,9 @@ fn try_main() -> Result<()> { | |||
78 | path: cmd.path, | 93 | path: cmd.path, |
79 | load_output_dirs: cmd.load_output_dirs, | 94 | load_output_dirs: cmd.load_output_dirs, |
80 | with_proc_macro: cmd.with_proc_macro, | 95 | with_proc_macro: cmd.with_proc_macro, |
96 | skip_inference: cmd.skip_inference, | ||
81 | } | 97 | } |
82 | .run(verbosity)?, | 98 | .run(verbosity)?, |
83 | flags::RustAnalyzerCmd::AnalysisBench(cmd) => { | ||
84 | let what = cmd.what(); | ||
85 | BenchCmd { | ||
86 | memory_usage: cmd.memory_usage, | ||
87 | path: cmd.path, | ||
88 | load_output_dirs: cmd.load_output_dirs, | ||
89 | with_proc_macro: cmd.with_proc_macro, | ||
90 | what, | ||
91 | } | ||
92 | .run(verbosity)? | ||
93 | } | ||
94 | 99 | ||
95 | flags::RustAnalyzerCmd::Diagnostics(cmd) => { | 100 | flags::RustAnalyzerCmd::Diagnostics(cmd) => { |
96 | cli::diagnostics(&cmd.path, cmd.load_output_dirs, cmd.with_proc_macro)? | 101 | cli::diagnostics(&cmd.path, cmd.load_output_dirs, cmd.with_proc_macro)? |
@@ -144,7 +149,7 @@ mod tracing_setup { | |||
144 | } | 149 | } |
145 | 150 | ||
146 | fn run_server() -> Result<()> { | 151 | fn run_server() -> Result<()> { |
147 | log::info!("server will start"); | 152 | log::info!("server version {} will start", env!("REV")); |
148 | 153 | ||
149 | let (connection, io_threads) = Connection::stdio(); | 154 | let (connection, io_threads) = Connection::stdio(); |
150 | 155 | ||