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