about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/crateid.rs9
1 files changed, 9 insertions, 0 deletions
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]