From: Dale Wijnand Date: Tue, 10 Apr 2018 12:32:40 +0000 (+0100) Subject: re-implement by adding a few from_cwd args X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~81^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d6786057893706a0eec4654c589f1f034f21b3d5;p=cargo.git re-implement by adding a few from_cwd args --- diff --git a/src/bin/commands/install.rs b/src/bin/commands/install.rs index ae4e4bda2..0acdd0269 100644 --- a/src/bin/commands/install.rs +++ b/src/bin/commands/install.rs @@ -79,6 +79,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { .unwrap_or_default() .collect::>(); + let mut from_cwd = false; + let source = if let Some(url) = args.value_of("git") { let url = url.to_url()?; let gitref = if let Some(branch) = args.value_of("branch") { @@ -94,7 +96,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { } else if let Some(path) = args.value_of_path("path", config) { SourceId::for_path(&path)? } else if krates.is_empty() { - SourceId::from_cwd(config.cwd())? + from_cwd = true; + SourceId::for_path(config.cwd())? } else { SourceId::crates_io(config)? }; @@ -109,6 +112,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { root, krates, &source, + from_cwd, version, &compile_opts, args.is_present("force"), diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 784107c21..174a36531 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -34,7 +34,6 @@ struct SourceIdInner { precise: Option, /// Name of the registry source for alternative registries name: Option, - from_cwd: bool, } /// The possible kinds of code source. Along with SourceIdInner this fully defines the @@ -76,7 +75,6 @@ impl SourceId { url, precise: None, name: None, - from_cwd: false, }), }; Ok(source_id) @@ -167,21 +165,6 @@ impl SourceId { SourceId::new(Kind::Directory, url) } - /// Create a SourceId from the current working directory filesystem path. - /// - /// Pass absolute path - pub fn from_cwd(path: &Path) -> CargoResult { - let source_id = SourceId::for_path(path)?; - let source_id = Arc::try_unwrap(source_id.inner) - .map_err(|_| format_err!("failed to create SourceId from cwd `{}`", path.display()))?; - Ok(SourceId { - inner: Arc::new(SourceIdInner { - from_cwd: true, - ..source_id - }), - }) - } - /// Returns the `SourceId` corresponding to the main repository. /// /// This is the main cargo registry by default, but it can be overridden in @@ -217,7 +200,6 @@ impl SourceId { url, precise: None, name: Some(key.to_string()), - from_cwd: false, }), }) } @@ -257,11 +239,6 @@ impl SourceId { } } - /// Is this source from the current working directory - pub fn is_from_cwd(&self) -> bool { - self.inner.from_cwd - } - /// Creates an implementation of `Source` corresponding to this ID. pub fn load<'a>(&self, config: &'a Config) -> CargoResult> { trace!("loading SourceId; {}", self); diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 2cd7feb32..9984c3952 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -57,6 +57,7 @@ pub fn install( root: Option<&str>, krates: Vec<&str>, source_id: &SourceId, + from_cwd: bool, vers: Option<&str>, opts: &ops::CompileOptions, force: bool, @@ -70,6 +71,7 @@ pub fn install( &map, krates.into_iter().next(), source_id, + from_cwd, vers, opts, force, @@ -88,6 +90,7 @@ pub fn install( &map, Some(krate), source_id, + from_cwd, vers, opts, force, @@ -149,6 +152,7 @@ fn install_one( map: &SourceConfigMap, krate: Option<&str>, source_id: &SourceId, + from_cwd: bool, vers: Option<&str>, opts: &ops::CompileOptions, force: bool, @@ -229,7 +233,7 @@ fn install_one( }; let pkg = ws.current()?; - if source_id.is_from_cwd() { + if from_cwd { match pkg.manifest().edition() { Edition::Edition2015 => (), Edition::Edition2018 => {