1#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
13
14#[cfg(feature = "in-rust-tree")]
15extern crate rustc_driver as _;
16
17extern crate ra_ap_rustc_type_ir as rustc_type_ir;
18
19pub const MINIMUM_SUPPORTED_TOOLCHAIN_VERSION: semver::Version = semver::Version {
21 major: 1,
22 minor: 78,
23 patch: 0,
24 pre: semver::Prerelease::EMPTY,
25 build: semver::BuildMetadata::EMPTY,
26};
27
28pub mod cli;
29
30mod command;
31mod diagnostics;
32mod discover;
33mod flycheck;
34mod line_index;
35mod main_loop;
36mod mem_docs;
37mod op_queue;
38mod reload;
39mod target_spec;
40mod task_pool;
41mod test_runner;
42mod version;
43
44mod handlers {
45 pub(crate) mod dispatch;
46 pub(crate) mod notification;
47 pub(crate) mod request;
48}
49
50pub mod tracing {
51 pub mod config;
52 pub mod json;
53 pub use config::Config;
54 pub mod hprof;
55}
56
57pub mod config;
58mod global_state;
59pub mod lsp;
60use self::lsp::ext as lsp_ext;
61
62#[cfg(test)]
63mod integrated_benchmarks;
64
65use serde::de::DeserializeOwned;
66
67pub use crate::{
68 lsp::capabilities::server_capabilities, main_loop::main_loop, reload::ws_to_crate_graph,
69 version::version,
70};
71
72pub fn from_json<T: DeserializeOwned>(
73 what: &'static str,
74 json: &serde_json::Value,
75) -> anyhow::Result<T> {
76 serde_json::from_value(json.clone())
77 .map_err(|e| anyhow::format_err!("Failed to deserialize {what}: {e}; {json}"))
78}
79
80#[doc(hidden)]
81macro_rules! try_default_ {
82 ($it:expr $(,)?) => {
83 match $it {
84 Some(it) => it,
85 None => return Ok(Default::default()),
86 }
87 };
88}
89pub(crate) use try_default_ as try_default;
90
91#[cfg(feature = "dhat")]
92#[global_allocator]
93static ALLOC: dhat::Alloc = dhat::Alloc;
94
95#[cfg(feature = "dhat")]
96static DHAT_PROFILER: std::sync::Mutex<Option<dhat::Profiler>> = std::sync::Mutex::new(None);