Skip to content

Commit 80a83e3

Browse files
committed
---
yaml --- r: 79358 b: refs/heads/try c: 9c1689d h: refs/heads/master v: v3
1 parent f949837 commit 80a83e3

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e6de6b7da8ee88bf84b0e217900051334be08da
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 60fba4d7d677ec098e6a43014132fe99f7547363
5-
refs/heads/try: be93735e4e818fb4bbb5be2a71921fd94726286e
5+
refs/heads/try: 9c1689d38ccccc44f40b1a09c698df8760c9d30b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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)