aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-12-01 10:19:20 -0800
committerPatrick Walton <[email protected]>2010-12-01 10:19:38 -0800
commit42282a25c03182a19e80fb1a3294d3869859d6fa (patch)
treed1e68961c74eae3f52e5ab937121b62e562166a7 /src/comp/middle
parentMake the ugly detailed leak-spray on rustc failures optional. (diff)
downloadrust-42282a25c03182a19e80fb1a3294d3869859d6fa.tar.xz
rust-42282a25c03182a19e80fb1a3294d3869859d6fa.zip
rustc: Resolve tag variant names
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/resolve.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index ed4d6c04..2655a6c5 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -38,6 +38,9 @@ fn lookup_name(&env e, ast.ident i) -> option.t[def] {
case (ast.item_ty(_, _, _, ?id, _)) {
ret some[def](ast.def_ty(id));
}
+ case (ast.item_tag(_, _, _, ?id)) {
+ ret some[def](ast.def_ty(id));
+ }
}
}
@@ -59,8 +62,24 @@ fn lookup_name(&env e, ast.ident i) -> option.t[def] {
fn check_mod(ast.ident i, ast._mod m) -> option.t[def] {
alt (m.index.find(i)) {
- case (some[uint](?ix)) {
- ret found_def_item(m.items.(ix));
+ case (some[ast.mod_index_entry](?ent)) {
+ alt (ent) {
+ case (ast.mie_item(?ix)) {
+ ret found_def_item(m.items.(ix));
+ }
+ case (ast.mie_tag_variant(?item_idx, ?variant_idx)) {
+ alt (m.items.(item_idx).node) {
+ case (ast.item_tag(_, ?variants, _, ?tid)) {
+ auto vid = variants.(variant_idx).id;
+ ret some[def](ast.def_variant(tid, vid));
+ }
+ case (_) {
+ log "tag item not actually a tag";
+ fail;
+ }
+ }
+ }
+ }
}
}
ret none[def];