diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-25 10:46:21 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-25 10:46:21 +0100 |
commit | 59c77ff062e2b1668fcfa885a8438c333b4f0875 (patch) | |
tree | 5f3b512a53bd2dd6ec1215fcbb16a678c4fbd5f6 /crates/project_model | |
parent | ed51f5b424161d9b37508bd9dbafc2f310ae8eb2 (diff) | |
parent | 3a72afed8cca3288fb955e66521f62f57aceace2 (diff) |
Merge #5866
5866: Improve logging
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/project_model')
-rw-r--r-- | crates/project_model/src/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index 84d1303db..b601d7dc3 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs | |||
@@ -6,6 +6,7 @@ mod sysroot; | |||
6 | mod cfg_flag; | 6 | mod cfg_flag; |
7 | 7 | ||
8 | use std::{ | 8 | use std::{ |
9 | fmt, | ||
9 | fs::{self, read_dir, ReadDir}, | 10 | fs::{self, read_dir, ReadDir}, |
10 | io, | 11 | io, |
11 | process::Command, | 12 | process::Command, |
@@ -27,7 +28,7 @@ pub use crate::{ | |||
27 | 28 | ||
28 | pub use proc_macro_api::ProcMacroClient; | 29 | pub use proc_macro_api::ProcMacroClient; |
29 | 30 | ||
30 | #[derive(Debug, Clone, Eq, PartialEq)] | 31 | #[derive(Clone, Eq, PartialEq)] |
31 | pub enum ProjectWorkspace { | 32 | pub enum ProjectWorkspace { |
32 | /// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`. | 33 | /// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`. |
33 | Cargo { cargo: CargoWorkspace, sysroot: Sysroot }, | 34 | Cargo { cargo: CargoWorkspace, sysroot: Sysroot }, |
@@ -35,6 +36,19 @@ pub enum ProjectWorkspace { | |||
35 | Json { project: ProjectJson }, | 36 | Json { project: ProjectJson }, |
36 | } | 37 | } |
37 | 38 | ||
39 | impl fmt::Debug for ProjectWorkspace { | ||
40 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
41 | match self { | ||
42 | ProjectWorkspace::Cargo { cargo, .. } => { | ||
43 | f.debug_struct("Cargo").field("n_packages", &cargo.packages().len()).finish() | ||
44 | } | ||
45 | ProjectWorkspace::Json { project } => { | ||
46 | f.debug_struct("Json").field("n_crates", &project.crates.len()).finish() | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | |||
38 | /// `PackageRoot` describes a package root folder. | 52 | /// `PackageRoot` describes a package root folder. |
39 | /// Which may be an external dependency, or a member of | 53 | /// Which may be an external dependency, or a member of |
40 | /// the current workspace. | 54 | /// the current workspace. |