Skip to content

Commit 6d39729

Browse files
committed
---
yaml --- r: 79261 b: refs/heads/auto c: 9ab2cfd h: refs/heads/master i: 79259: bd1298b v: v3
1 parent c9da7d1 commit 6d39729

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: bc2a44daf1cf348da98de9553fccc23806e84f71
16+
refs/heads/auto: 9ab2cfdae610374760b86a8b6069baf365970f2f
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libsyntax/ast_util.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,50 @@ pub fn getLast(arr: &~[Mrk]) -> uint {
985985
*arr.last()
986986
}
987987
988+
// are two paths equal when compared unhygienically?
989+
// since I'm using this to replace ==, it seems appropriate
990+
// to compare the span, global, etc. fields as well.
991+
pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool {
992+
(a.span == b.span)
993+
&& (a.global == b.global)
994+
// NOTE: ident->name in lifetimes!
995+
&& (a.rp == b.rp)
996+
// NOTE: can a type contain an ident?
997+
&& (a.types == b.types)
998+
&& (idents_name_eq(a.idents, b.idents))
999+
}
1000+
1001+
// are two arrays of idents equal when compared unhygienically?
1002+
pub fn idents_name_eq(a : &[ast::ident], b : &[ast::ident]) -> bool {
1003+
if (a.len() != b.len()) {
1004+
false
1005+
} else {
1006+
for a.iter().enumerate().advance |(idx,id)|{
1007+
if (id.name != b[idx].name) {
1008+
return false;
1009+
}
1010+
}
1011+
true
1012+
}
1013+
}
9881014
9891015
#[cfg(test)]
9901016
mod test {
9911017
use ast::*;
9921018
use super::*;
9931019
use std::io;
9941020
1021+
#[test] fn idents_name_eq_test() {
1022+
assert!(idents_name_eq(~[ident{name:3,ctxt:4},
1023+
ident{name:78,ctxt:82}],
1024+
~[ident{name:3,ctxt:104},
1025+
ident{name:78,ctxt:182}]));
1026+
assert!(!idents_name_eq(~[ident{name:3,ctxt:4},
1027+
ident{name:78,ctxt:82}],
1028+
~[ident{name:3,ctxt:104},
1029+
ident{name:77,ctxt:182}]));
1030+
}
1031+
9951032
#[test] fn xorpush_test () {
9961033
let mut s = ~[];
9971034
xorPush(&mut s,14);

0 commit comments

Comments
 (0)