From 8213e184477c19eba75840e9310266a6529de20a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 24 Feb 2014 18:13:51 -0800 Subject: rustc: Simplify crate loading constraints The previous code passed around a {name,version} pair everywhere, but this is better expressed as a CrateId. This patch changes these paths to store and pass around crate ids instead of these pairs of name/version. This also prepares the code to change the type of hash that is stored in crates. --- src/libsyntax/crateid.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs index 659cd13c94d..b5f02fb7e64 100644 --- a/src/libsyntax/crateid.rs +++ b/src/libsyntax/crateid.rs @@ -107,6 +107,15 @@ impl CrateId { pub fn short_name_with_version(&self) -> ~str { format!("{}-{}", self.name, self.version_or_default()) } + + pub fn matches(&self, other: &CrateId) -> bool { + // FIXME: why does this not match on `path`? + if self.name != other.name { return false } + match (&self.version, &other.version) { + (&Some(ref v1), &Some(ref v2)) => v1 == v2, + _ => true, + } + } } #[test] -- cgit 1.4.1-3-g733a5