Skip to content

Commit c639fe3

Browse files
committed
internal: improve compilation critical path a bit
1 parent 0dabcf0 commit c639fe3

File tree

7 files changed

+12
-34
lines changed

7 files changed

+12
-34
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/paths/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ edition = "2018"
99
doctest = false
1010

1111
[dependencies]
12-
serde = "1"
12+
# Adding this dep sadly puts a lot of rust-analyzer crates after the
13+
# serde-derive crate. Even though we don't activate the derive feature here,
14+
# someone else in the crate graph certainly does!
15+
# serde = "1"

crates/paths/src/lib.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,6 @@ impl PartialEq<AbsPath> for AbsPathBuf {
6666
}
6767
}
6868

69-
impl serde::Serialize for AbsPathBuf {
70-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
71-
where
72-
S: serde::Serializer,
73-
{
74-
self.0.serialize(serializer)
75-
}
76-
}
77-
78-
impl<'de> serde::Deserialize<'de> for AbsPathBuf {
79-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
80-
where
81-
D: serde::Deserializer<'de>,
82-
{
83-
let path = PathBuf::deserialize(deserializer)?;
84-
AbsPathBuf::try_from(path).map_err(|path| {
85-
serde::de::Error::custom(format!("expected absolute path, got {}", path.display()))
86-
})
87-
}
88-
}
89-
9069
impl AbsPathBuf {
9170
/// Wrap the given absolute path in `AbsPathBuf`
9271
///

crates/proc_macro_api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl ProcMacroProcessExpander {
6363
macro_body: FlatTree::new(subtree),
6464
macro_name: self.name.to_string(),
6565
attributes: attr.map(FlatTree::new),
66-
lib: self.dylib_path.to_path_buf(),
66+
lib: self.dylib_path.to_path_buf().into(),
6767
env,
6868
};
6969

crates/proc_macro_api/src/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl ProcMacroProcessSrv {
3939
&mut self,
4040
dylib_path: &AbsPath,
4141
) -> Result<Vec<(String, ProcMacroKind)>, tt::ExpansionError> {
42-
let task = ListMacrosTask { lib: dylib_path.to_path_buf() };
42+
let task = ListMacrosTask { lib: dylib_path.to_path_buf().into() };
4343

4444
let result: ListMacrosResult = self.send_task(Request::ListMacro(task))?;
4545
Ok(result.macros)

crates/proc_macro_api/src/rpc.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
//! for separation of code responsibility.
88
pub(crate) mod flat;
99

10-
use paths::AbsPathBuf;
10+
use std::path::PathBuf;
11+
1112
use serde::{Deserialize, Serialize};
1213

1314
use crate::rpc::flat::FlatTree;
1415

1516
#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
1617
pub struct ListMacrosTask {
17-
pub lib: AbsPathBuf,
18+
pub lib: PathBuf,
1819
}
1920

2021
#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
@@ -46,7 +47,7 @@ pub struct ExpansionTask {
4647
/// Possible attributes for the attribute-like macros.
4748
pub attributes: Option<FlatTree>,
4849

49-
pub lib: AbsPathBuf,
50+
pub lib: PathBuf,
5051

5152
/// Environment variables to set during macro expansion.
5253
pub env: Vec<(String, String)>,
@@ -93,7 +94,7 @@ mod tests {
9394
macro_body: FlatTree::new(&tt),
9495
macro_name: Default::default(),
9596
attributes: None,
96-
lib: AbsPathBuf::assert(std::env::current_dir().unwrap()),
97+
lib: std::env::current_dir().unwrap(),
9798
env: Default::default(),
9899
};
99100

crates/proc_macro_srv/src/tests/utils.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::dylib;
44
use crate::ProcMacroSrv;
55
use expect_test::Expect;
6-
use paths::AbsPathBuf;
76
use proc_macro_api::ListMacrosTask;
87
use std::str::FromStr;
98

@@ -42,8 +41,7 @@ fn assert_expand_impl(macro_name: &str, input: &str, attr: Option<&str>, expect:
4241
}
4342

4443
pub fn list() -> Vec<String> {
45-
let path = AbsPathBuf::assert(fixtures::proc_macro_test_dylib_path());
46-
let task = ListMacrosTask { lib: path };
44+
let task = ListMacrosTask { lib: fixtures::proc_macro_test_dylib_path() };
4745
let mut srv = ProcMacroSrv::default();
4846
let res = srv.list_macros(&task).unwrap();
4947
res.macros.into_iter().map(|(name, kind)| format!("{} [{:?}]", name, kind)).collect()

0 commit comments

Comments
 (0)