diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-02-24 18:13:51 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-02-28 10:47:41 -0800 |
| commit | 8213e184477c19eba75840e9310266a6529de20a (patch) | |
| tree | f505c6cb68389a8b3660ab2d7972edd2987b77cb /src/libsyntax | |
| parent | 9b1be3d182e361697117bf79fadca7697f8b5aec (diff) | |
| download | rust-8213e184477c19eba75840e9310266a6529de20a.tar.gz rust-8213e184477c19eba75840e9310266a6529de20a.zip | |
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.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/crateid.rs | 9 |
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] |
