From 3a72afed8cca3288fb955e66521f62f57aceace2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 25 Aug 2020 11:27:22 +0200 Subject: Improve logging --- crates/project_model/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/project_model/src') 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; mod cfg_flag; use std::{ + fmt, fs::{self, read_dir, ReadDir}, io, process::Command, @@ -27,7 +28,7 @@ pub use crate::{ pub use proc_macro_api::ProcMacroClient; -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Eq, PartialEq)] pub enum ProjectWorkspace { /// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`. Cargo { cargo: CargoWorkspace, sysroot: Sysroot }, @@ -35,6 +36,19 @@ pub enum ProjectWorkspace { Json { project: ProjectJson }, } +impl fmt::Debug for ProjectWorkspace { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ProjectWorkspace::Cargo { cargo, .. } => { + f.debug_struct("Cargo").field("n_packages", &cargo.packages().len()).finish() + } + ProjectWorkspace::Json { project } => { + f.debug_struct("Json").field("n_crates", &project.crates.len()).finish() + } + } + } +} + /// `PackageRoot` describes a package root folder. /// Which may be an external dependency, or a member of /// the current workspace. -- cgit v1.2.3