Skip to content

Commit b1518b2

Browse files
committed
Simplify
1 parent 58286cc commit b1518b2

File tree

7 files changed

+17
-19
lines changed

7 files changed

+17
-19
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,6 @@ dependencies = [
13371337
"stdx",
13381338
"text-size",
13391339
"tracing",
1340-
"triomphe",
13411340
"tt",
13421341
]
13431342

src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ doctest = false
1515
serde.workspace = true
1616
serde_json = { workspace = true, features = ["unbounded_depth"] }
1717
tracing.workspace = true
18-
triomphe.workspace = true
1918
rustc-hash.workspace = true
2019
indexmap.workspace = true
2120

src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ pub mod msg;
99
mod process;
1010

1111
use base_db::Env;
12-
use indexmap::IndexSet;
1312
use paths::{AbsPath, AbsPathBuf};
14-
use rustc_hash::FxHashMap;
1513
use span::Span;
1614
use std::{fmt, io, sync::Arc};
1715
use tt::SmolStr;
@@ -21,7 +19,8 @@ use serde::{Deserialize, Serialize};
2119
use crate::{
2220
msg::{
2321
deserialize_span_data_index_map, flat::serialize_span_data_index_map, ExpandMacro,
24-
ExpnGlobals, FlatTree, PanicMessage, HAS_GLOBAL_SPANS, RUST_ANALYZER_SPAN_SUPPORT,
22+
ExpnGlobals, FlatTree, PanicMessage, SpanDataIndexMap, HAS_GLOBAL_SPANS,
23+
RUST_ANALYZER_SPAN_SUPPORT,
2524
},
2625
process::ProcMacroProcessSrv,
2726
};
@@ -101,7 +100,8 @@ impl ProcMacroServer {
101100
/// Spawns an external process as the proc macro server and returns a client connected to it.
102101
pub fn spawn(
103102
process_path: &AbsPath,
104-
env: &FxHashMap<String, String>,
103+
env: impl IntoIterator<Item = (impl AsRef<std::ffi::OsStr>, impl AsRef<std::ffi::OsStr>)>
104+
+ Clone,
105105
) -> io::Result<ProcMacroServer> {
106106
let process = ProcMacroProcessSrv::run(process_path, env)?;
107107
Ok(ProcMacroServer { process: Arc::new(process), path: process_path.to_owned() })
@@ -151,7 +151,7 @@ impl ProcMacro {
151151
let version = self.process.version();
152152
let current_dir = env.get("CARGO_MANIFEST_DIR");
153153

154-
let mut span_data_table = IndexSet::default();
154+
let mut span_data_table = SpanDataIndexMap::default();
155155
let def_site = span_data_table.insert_full(def_site).0;
156156
let call_site = span_data_table.insert_full(call_site).0;
157157
let mixed_site = span_data_table.insert_full(mixed_site).0;

src/tools/rust-analyzer/crates/proc-macro-api/src/msg/flat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
3838
use std::collections::VecDeque;
3939

40-
use indexmap::IndexSet;
4140
use la_arena::RawIdx;
4241
use rustc_hash::FxHashMap;
4342
use serde::{Deserialize, Serialize};
@@ -46,7 +45,8 @@ use text_size::TextRange;
4645

4746
use crate::msg::ENCODE_CLOSE_SPAN_VERSION;
4847

49-
pub type SpanDataIndexMap = IndexSet<Span>;
48+
pub type SpanDataIndexMap =
49+
indexmap::IndexSet<Span, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
5050

5151
pub fn serialize_span_data_index_map(map: &SpanDataIndexMap) -> Vec<u32> {
5252
map.iter()
@@ -328,7 +328,7 @@ impl InternableSpan for TokenId {
328328
}
329329
}
330330
impl InternableSpan for Span {
331-
type Table = IndexSet<Span>;
331+
type Table = SpanDataIndexMap;
332332
fn token_id_of(table: &mut Self::Table, span: Self) -> TokenId {
333333
TokenId(table.insert_full(span).0 as u32)
334334
}

src/tools/rust-analyzer/crates/proc-macro-api/src/process.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{
77
};
88

99
use paths::AbsPath;
10-
use rustc_hash::FxHashMap;
1110
use stdx::JodChild;
1211

1312
use crate::{
@@ -36,10 +35,11 @@ struct ProcessSrvState {
3635
impl ProcMacroProcessSrv {
3736
pub(crate) fn run(
3837
process_path: &AbsPath,
39-
env: &FxHashMap<String, String>,
38+
env: impl IntoIterator<Item = (impl AsRef<std::ffi::OsStr>, impl AsRef<std::ffi::OsStr>)>
39+
+ Clone,
4040
) -> io::Result<ProcMacroProcessSrv> {
4141
let create_srv = |null_stderr| {
42-
let mut process = Process::run(process_path, env, null_stderr)?;
42+
let mut process = Process::run(process_path, env.clone(), null_stderr)?;
4343
let (stdin, stdout) = process.stdio().expect("couldn't access child stdio");
4444

4545
io::Result::Ok(ProcMacroProcessSrv {
@@ -158,7 +158,7 @@ struct Process {
158158
impl Process {
159159
fn run(
160160
path: &AbsPath,
161-
env: &FxHashMap<String, String>,
161+
env: impl IntoIterator<Item = (impl AsRef<std::ffi::OsStr>, impl AsRef<std::ffi::OsStr>)>,
162162
null_stderr: bool,
163163
) -> io::Result<Process> {
164164
let child = JodChild(mk_child(path, env, null_stderr)?);
@@ -176,7 +176,7 @@ impl Process {
176176

177177
fn mk_child(
178178
path: &AbsPath,
179-
env: &FxHashMap<String, String>,
179+
env: impl IntoIterator<Item = (impl AsRef<std::ffi::OsStr>, impl AsRef<std::ffi::OsStr>)>,
180180
null_stderr: bool,
181181
) -> io::Result<Child> {
182182
let mut cmd = Command::new(path);

src/tools/rust-analyzer/crates/proc-macro-srv-cli/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ extern crate rustc_driver as _;
88

99
use std::io;
1010

11-
use proc_macro_api::msg::ServerConfig;
12-
1311
fn main() -> std::io::Result<()> {
1412
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
1513
match v.as_deref() {
@@ -48,7 +46,9 @@ fn run() -> io::Result<()> {
4846
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
4947
}
5048
msg::Request::SetConfig(_) => {
51-
msg::Response::SetConfig(ServerConfig { span_mode: msg::SpanMode::Id })
49+
msg::Response::SetConfig(proc_macro_api::msg::ServerConfig {
50+
span_mode: msg::SpanMode::Id,
51+
})
5252
}
5353
};
5454
write_response(res)?

src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl GlobalState {
529529
None => ws.find_sysroot_proc_macro_srv()?,
530530
};
531531

532-
let env = match &ws.kind {
532+
let env: FxHashMap<_, _> = match &ws.kind {
533533
ProjectWorkspaceKind::Cargo { cargo_config_extra_env, .. }
534534
| ProjectWorkspaceKind::DetachedFile {
535535
cargo: Some(_),

0 commit comments

Comments
 (0)