aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/bin/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rust-analyzer/src/bin/main.rs')
-rw-r--r--crates/rust-analyzer/src/bin/main.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs
index ff8234495..fc7f8b01d 100644
--- a/crates/rust-analyzer/src/bin/main.rs
+++ b/crates/rust-analyzer/src/bin/main.rs
@@ -3,7 +3,7 @@
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
4mod args; 4mod args;
5 5
6use std::convert::TryFrom; 6use std::{convert::TryFrom, process};
7 7
8use lsp_server::Connection; 8use lsp_server::Connection;
9use ra_project_model::ProjectManifest; 9use ra_project_model::ProjectManifest;
@@ -14,18 +14,20 @@ use rust_analyzer::{
14}; 14};
15use vfs::AbsPathBuf; 15use vfs::AbsPathBuf;
16 16
17use crate::args::HelpPrinted;
18
19#[cfg(all(feature = "mimalloc"))] 17#[cfg(all(feature = "mimalloc"))]
20#[global_allocator] 18#[global_allocator]
21static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; 19static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
22 20
23fn main() -> Result<()> { 21fn main() {
22 if let Err(err) = try_main() {
23 eprintln!("{}", err);
24 process::exit(101);
25 }
26}
27
28fn try_main() -> Result<()> {
24 setup_logging()?; 29 setup_logging()?;
25 let args = match args::Args::parse()? { 30 let args = args::Args::parse()?;
26 Ok(it) => it,
27 Err(HelpPrinted) => return Ok(()),
28 };
29 match args.command { 31 match args.command {
30 args::Command::RunServer => run_server()?, 32 args::Command::RunServer => run_server()?,
31 args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?, 33 args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?,
@@ -45,6 +47,7 @@ fn main() -> Result<()> {
45 cli::search_for_patterns(patterns, debug_snippet)?; 47 cli::search_for_patterns(patterns, debug_snippet)?;
46 } 48 }
47 args::Command::Version => println!("rust-analyzer {}", env!("REV")), 49 args::Command::Version => println!("rust-analyzer {}", env!("REV")),
50 args::Command::Help => {}
48 } 51 }
49 Ok(()) 52 Ok(())
50} 53}