diff options
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 14 | ||||
-rw-r--r-- | crates/ra_project_model/src/sysroot.rs | 5 |
2 files changed, 15 insertions, 4 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 { |
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index 10ca391b6..34d066b1e 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs | |||
@@ -53,9 +53,10 @@ impl Sysroot { | |||
53 | if !src.exists() { | 53 | if !src.exists() { |
54 | Err(format!( | 54 | Err(format!( |
55 | "can't load standard library from sysroot\n\ | 55 | "can't load standard library from sysroot\n\ |
56 | {:?}\n\ | 56 | {}\n\ |
57 | (discovered via `rustc --print sysroot`)\n\ | ||
57 | try running `rustup component add rust-src` or set `RUST_SRC_PATH`", | 58 | try running `rustup component add rust-src` or set `RUST_SRC_PATH`", |
58 | src, | 59 | src.display(), |
59 | ))?; | 60 | ))?; |
60 | } | 61 | } |
61 | 62 | ||