diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index 7231c137251..885d2c61caf 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -3,6 +3,7 @@ use std::fmt::{self, Formatter}; use std::hash; use std::hash::Hash; use std::path::Path; +use std::ptr; use std::sync::Mutex; use semver; @@ -18,7 +19,7 @@ lazy_static! { } /// Identifier for a specific version of a package in a specific source. -#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy, Eq, Hash, PartialOrd, Ord)] pub struct PackageId { inner: &'static PackageIdInner, } @@ -96,6 +97,15 @@ impl<'de> de::Deserialize<'de> for PackageId { } } +impl PartialEq for PackageId { + fn eq(&self, other: &PackageId) -> bool { + if ptr::eq(self.inner, other.inner) { + return true; + } + (*self.inner).eq(&*other.inner) + } +} + impl PackageId { pub fn new(name: &str, version: T, sid: SourceId) -> CargoResult { let v = version.to_semver()?;