Skip to content

Commit

Permalink
refactor: Clarify direct-construction function for PackageId
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 1, 2023
1 parent 749f0e3 commit 52d1cfb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/cargo/core/package_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<'de> de::Deserialize<'de> for PackageId {
strip_parens(rest).ok_or_else(|| de::Error::custom("invalid serialized PackageId"))?;
let source_id = SourceId::from_url(url).map_err(de::Error::custom)?;

Ok(PackageId::pure(name, version, source_id))
Ok(PackageId::new(name, version, source_id))
}
}

Expand Down Expand Up @@ -129,10 +129,10 @@ impl PackageId {
sid: SourceId,
) -> CargoResult<PackageId> {
let v = version.parse()?;
Ok(PackageId::pure(name.into(), v, sid))
Ok(PackageId::new(name.into(), v, sid))
}

pub fn pure(name: InternedString, version: semver::Version, source_id: SourceId) -> PackageId {
pub fn new(name: InternedString, version: semver::Version, source_id: SourceId) -> PackageId {
let inner = PackageIdInner {
name,
version,
Expand Down Expand Up @@ -161,7 +161,7 @@ impl PackageId {
}

pub fn with_source_id(self, source: SourceId) -> PackageId {
PackageId::pure(self.inner.name, self.inner.version.clone(), source)
PackageId::new(self.inner.name, self.inner.version.clone(), source)
}

pub fn map_source(self, to_replace: SourceId, replace_with: SourceId) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/sources/registry/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ impl IndexSummary {
} = serde_json::from_slice(line)?;
let v = v.unwrap_or(1);
tracing::trace!("json parsed registry {}/{}", name, vers);
let pkgid = PackageId::pure(name.into(), vers.clone(), source_id);
let pkgid = PackageId::new(name.into(), vers.clone(), source_id);
let deps = deps
.into_iter()
.map(|dep| dep.into_dep(source_id))
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ pub fn to_real_manifest(

package.version = version.clone().map(schema::InheritableField::Value);

let pkgid = PackageId::pure(
let pkgid = PackageId::new(
package.name.as_str().into(),
version
.clone()
Expand Down

0 comments on commit 52d1cfb

Please sign in to comment.