.unwrap_or_default()
.collect::<Vec<_>>();
+ 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") {
} 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)?
};
root,
krates,
&source,
+ from_cwd,
version,
&compile_opts,
args.is_present("force"),
precise: Option<String>,
/// Name of the registry source for alternative registries
name: Option<String>,
- from_cwd: bool,
}
/// The possible kinds of code source. Along with SourceIdInner this fully defines the
url,
precise: None,
name: None,
- from_cwd: false,
}),
};
Ok(source_id)
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<SourceId> {
- 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
url,
precise: None,
name: Some(key.to_string()),
- from_cwd: false,
}),
})
}
}
}
- /// 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<Box<super::Source + 'a>> {
trace!("loading SourceId; {}", self);
root: Option<&str>,
krates: Vec<&str>,
source_id: &SourceId,
+ from_cwd: bool,
vers: Option<&str>,
opts: &ops::CompileOptions,
force: bool,
&map,
krates.into_iter().next(),
source_id,
+ from_cwd,
vers,
opts,
force,
&map,
Some(krate),
source_id,
+ from_cwd,
vers,
opts,
force,
map: &SourceConfigMap,
krate: Option<&str>,
source_id: &SourceId,
+ from_cwd: bool,
vers: Option<&str>,
opts: &ops::CompileOptions,
force: bool,
};
let pkg = ws.current()?;
- if source_id.is_from_cwd() {
+ if from_cwd {
match pkg.manifest().edition() {
Edition::Edition2015 => (),
Edition::Edition2018 => {