diff options
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index d71b7031a..b7f6a9b57 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -23,9 +23,19 @@ pub use crate::{ | |||
23 | sysroot::Sysroot, | 23 | sysroot::Sysroot, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | // FIXME use proper error enum | ||
27 | pub type Result<T> = ::std::result::Result<T, Box<dyn Error + Send + Sync>>; | 26 | pub type Result<T> = ::std::result::Result<T, Box<dyn Error + Send + Sync>>; |
28 | 27 | ||
28 | #[derive(Clone, PartialEq, Eq, Hash, Debug)] | ||
29 | pub struct CargoTomlNotFoundError(pub PathBuf); | ||
30 | |||
31 | impl std::fmt::Display for CargoTomlNotFoundError { | ||
32 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
33 | write!(fmt, "can't find Cargo.toml at {}", self.0.display()) | ||
34 | } | ||
35 | } | ||
36 | |||
37 | impl Error for CargoTomlNotFoundError {} | ||
38 | |||
29 | #[derive(Debug, Clone)] | 39 | #[derive(Debug, Clone)] |
30 | pub enum ProjectWorkspace { | 40 | pub enum ProjectWorkspace { |
31 | /// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`. | 41 | /// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`. |
@@ -362,7 +372,7 @@ fn find_cargo_toml(path: &Path) -> Result<PathBuf> { | |||
362 | } | 372 | } |
363 | curr = path.parent(); | 373 | curr = path.parent(); |
364 | } | 374 | } |
365 | Err(format!("can't find Cargo.toml at {}", path.display()))? | 375 | Err(CargoTomlNotFoundError(path.to_path_buf()))? |
366 | } | 376 | } |
367 | 377 | ||
368 | pub fn get_rustc_cfg_options() -> CfgOptions { | 378 | pub fn get_rustc_cfg_options() -> CfgOptions { |