Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Use &Path where possible, add docs to ManifestAwareError
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic committed Oct 16, 2018
1 parent 5bb6264 commit cd208fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/build/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn run_cargo(

enable_nightly_features();
let ws = Workspace::new(&manifest_path, &config)
.map_err(|err| ManifestAwareError::new(err, manifest_path.clone(), None))?;
.map_err(|err| ManifestAwareError::new(err, &manifest_path, None))?;

run_cargo_ws(
compilation_cx,
Expand All @@ -168,7 +168,7 @@ fn run_cargo(
&manifest_path,
&config,
&ws
).map_err(|err| ManifestAwareError::new(err, manifest_path, Some(&ws)).into())
).map_err(|err| ManifestAwareError::new(err, &manifest_path, Some(&ws)).into())
}

fn run_cargo_ws(
Expand Down Expand Up @@ -753,6 +753,7 @@ fn dedup_flags(flag_str: &str) -> String {
result
}

/// Error wrapper that tries to figure out which manifest the cause best relates to in the project
#[derive(Debug)]
pub struct ManifestAwareError {
cause: failure::Error,
Expand All @@ -762,9 +763,9 @@ pub struct ManifestAwareError {
}

impl ManifestAwareError {
fn new(cause: failure::Error, root_manifest: PathBuf, _ws: Option<&Workspace<'_>>) -> Self {
fn new(cause: failure::Error, root_manifest: &Path, _ws: Option<&Workspace<'_>>) -> Self {
let project_dir = root_manifest.parent().unwrap();
let mut err_path = root_manifest.as_path();
let mut err_path = root_manifest;
// cover whole manifest if we haven't any better idea.
let mut err_range = Range {
start: Position::new(0, 0),
Expand Down

0 comments on commit cd208fe

Please sign in to comment.