diff options
| author | Brian Anderson <[email protected]> | 2011-05-01 16:01:27 -0400 |
|---|---|---|
| committer | Brian Anderson <[email protected]> | 2011-05-01 16:57:36 -0400 |
| commit | a6972102342611afb6647b34714556262de1e084 (patch) | |
| tree | 2510197fef80c2094724b51d1f44cf6e2683741f /src | |
| parent | Implement simple module export (diff) | |
| download | rust-a6972102342611afb6647b34714556262de1e084.tar.xz rust-a6972102342611afb6647b34714556262de1e084.zip | |
Hide unexported tag variants
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/middle/resolve.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/export-tag-variant.rs | 17 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 82975112..39b8e901 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -407,9 +407,11 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns) case (ast.mie_tag_variant(?item, ?variant_idx)) { alt (item.node) { case (ast.item_tag(_, ?variants, _, ?tid, _)) { - auto vid = variants.(variant_idx).node.id; - auto t = ast.def_variant(tid, vid); - ret some[def_wrap](def_wrap_other(t)); + if (visible(e, i, m)) { + auto vid = variants.(variant_idx).node.id; + auto t = ast.def_variant(tid, vid); + ret some[def_wrap](def_wrap_other(t)); + } } case (_) { log_err "tag item not actually a tag"; diff --git a/src/test/compile-fail/export-tag-variant.rs b/src/test/compile-fail/export-tag-variant.rs new file mode 100644 index 00000000..c37dac2e --- /dev/null +++ b/src/test/compile-fail/export-tag-variant.rs @@ -0,0 +1,17 @@ +// xfail-boot +// error-pattern: unresolved name + +mod foo { + export x; + + fn x() { + } + + tag y { + y1; + } +} + +fn main() { + auto z = foo.y1; +} |