Merge pull request #2732 from detrumi/cargo-toml-not-found-message-toggle

Flag to hide cargo.toml not found error
This commit is contained in:
Aleksey Kladov 2020-01-09 15:16:39 +01:00 committed by GitHub
commit cf5bdf464c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 19 deletions

View file

@ -23,9 +23,19 @@ pub use crate::{
sysroot::Sysroot,
};
// FIXME use proper error enum
pub type Result<T> = ::std::result::Result<T, Box<dyn Error + Send + Sync>>;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct CargoTomlNotFoundError(pub PathBuf);
impl std::fmt::Display for CargoTomlNotFoundError {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(fmt, "can't find Cargo.toml at {}", self.0.display())
}
}
impl Error for CargoTomlNotFoundError {}
#[derive(Debug, Clone)]
pub enum ProjectWorkspace {
/// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`.
@ -362,7 +372,7 @@ fn find_cargo_toml(path: &Path) -> Result<PathBuf> {
}
curr = path.parent();
}
Err(format!("can't find Cargo.toml at {}", path.display()))?
Err(CargoTomlNotFoundError(path.to_path_buf()))?
}
pub fn get_rustc_cfg_options() -> CfgOptions {