diff options
author | Aleksey Kladov <[email protected]> | 2019-08-06 09:54:51 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-06 09:57:16 +0100 |
commit | d751bd08bfa36bd8abdcbb4fa466022720094b7d (patch) | |
tree | f514f0f74b4da150dc6086438879731a13ef74e1 /crates | |
parent | 0e4a542cfb366898a4d53701c50ae4d1732d7c53 (diff) |
cleanup
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_arena/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 9 | ||||
-rw-r--r-- | crates/ra_project_model/src/sysroot.rs | 2 |
6 files changed, 10 insertions, 9 deletions
diff --git a/crates/ra_arena/src/lib.rs b/crates/ra_arena/src/lib.rs index 3b7cb77b1..3ec8d3b60 100644 --- a/crates/ra_arena/src/lib.rs +++ b/crates/ra_arena/src/lib.rs | |||
@@ -79,7 +79,7 @@ impl<ID: ArenaId, T> Arena<ID, T> { | |||
79 | self.data.push(value); | 79 | self.data.push(value); |
80 | ID::from_raw(id) | 80 | ID::from_raw(id) |
81 | } | 81 | } |
82 | pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> { | 82 | pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> + ExactSizeIterator { |
83 | self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value)) | 83 | self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value)) |
84 | } | 84 | } |
85 | } | 85 | } |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 8e830c8b8..9a38d43d2 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -269,7 +269,7 @@ fn main_loop_inner( | |||
269 | && pending_libraries.is_empty() | 269 | && pending_libraries.is_empty() |
270 | && in_flight_libraries == 0 | 270 | && in_flight_libraries == 0 |
271 | { | 271 | { |
272 | let n_packages: usize = state.workspaces.iter().map(|it| it.count()).sum(); | 272 | let n_packages: usize = state.workspaces.iter().map(|it| it.n_packages()).sum(); |
273 | if state.options.show_workspace_loaded { | 273 | if state.options.show_workspace_loaded { |
274 | let msg = format!("workspace loaded, {} rust packages", n_packages); | 274 | let msg = format!("workspace loaded, {} rust packages", n_packages); |
275 | show_message(req::MessageType::Info, msg, msg_sender); | 275 | show_message(req::MessageType::Info, msg, msg_sender); |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 1d7755910..b57cdf925 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -211,7 +211,7 @@ impl WorldSnapshot { | |||
211 | } else { | 211 | } else { |
212 | res.push_str("workspaces:\n"); | 212 | res.push_str("workspaces:\n"); |
213 | for w in self.workspaces.iter() { | 213 | for w in self.workspaces.iter() { |
214 | res += &format!("{} packages loaded\n", w.count()); | 214 | res += &format!("{} packages loaded\n", w.n_packages()); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | res.push_str("\nanalysis:\n"); | 217 | res.push_str("\nanalysis:\n"); |
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 2b06e9e37..712d8818f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -167,7 +167,7 @@ impl CargoWorkspace { | |||
167 | Ok(CargoWorkspace { packages, targets, workspace_root: meta.workspace_root }) | 167 | Ok(CargoWorkspace { packages, targets, workspace_root: meta.workspace_root }) |
168 | } | 168 | } |
169 | 169 | ||
170 | pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + 'a { | 170 | pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + ExactSizeIterator + 'a { |
171 | self.packages.iter().map(|(id, _pkg)| id) | 171 | self.packages.iter().map(|(id, _pkg)| id) |
172 | } | 172 | } |
173 | 173 | ||
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 647a1f365..8e81396d4 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -112,8 +112,7 @@ impl ProjectWorkspace { | |||
112 | roots | 112 | roots |
113 | } | 113 | } |
114 | ProjectWorkspace::Cargo { cargo, sysroot } => { | 114 | ProjectWorkspace::Cargo { cargo, sysroot } => { |
115 | let mut roots = | 115 | let mut roots = Vec::with_capacity(cargo.packages().len() + sysroot.crates().len()); |
116 | Vec::with_capacity(cargo.packages().count() + sysroot.crates().count()); | ||
117 | for pkg in cargo.packages() { | 116 | for pkg in cargo.packages() { |
118 | let root = pkg.root(&cargo).to_path_buf(); | 117 | let root = pkg.root(&cargo).to_path_buf(); |
119 | let member = pkg.is_member(&cargo); | 118 | let member = pkg.is_member(&cargo); |
@@ -127,10 +126,12 @@ impl ProjectWorkspace { | |||
127 | } | 126 | } |
128 | } | 127 | } |
129 | 128 | ||
130 | pub fn count(&self) -> usize { | 129 | pub fn n_packages(&self) -> usize { |
131 | match self { | 130 | match self { |
132 | ProjectWorkspace::Json { project } => project.crates.len(), | 131 | ProjectWorkspace::Json { project } => project.crates.len(), |
133 | ProjectWorkspace::Cargo { cargo, .. } => cargo.packages().count(), | 132 | ProjectWorkspace::Cargo { cargo, sysroot } => { |
133 | cargo.packages().len() + sysroot.crates().len() | ||
134 | } | ||
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index 4f6e880dd..3f34d51cc 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs | |||
@@ -28,7 +28,7 @@ impl Sysroot { | |||
28 | self.by_name("std") | 28 | self.by_name("std") |
29 | } | 29 | } |
30 | 30 | ||
31 | pub fn crates<'a>(&'a self) -> impl Iterator<Item = SysrootCrate> + 'a { | 31 | pub fn crates<'a>(&'a self) -> impl Iterator<Item = SysrootCrate> + ExactSizeIterator + 'a { |
32 | self.crates.iter().map(|(id, _data)| id) | 32 | self.crates.iter().map(|(id, _data)| id) |
33 | } | 33 | } |
34 | 34 | ||