diff options
author | Aleksey Kladov <[email protected]> | 2020-01-09 14:16:39 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-09 14:16:39 +0000 |
commit | cf5bdf464cad7ceb9a67e07985a3f4d3799ec0b6 (patch) | |
tree | ba52dfcf74bc4a70ff63354614f42e24c3786758 /crates/ra_project_model/src | |
parent | 3263c7076613bf8c3c32bb2bd5be29f10eb0284c (diff) | |
parent | 11caebe6cea4d0ec51a1b886280f8c53548eda8e (diff) |
Merge pull request #2732 from detrumi/cargo-toml-not-found-message-toggle
Flag to hide cargo.toml not found error
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 { |