Skip to content

Commit 7b0ed94

Browse files
committed
rustc: Make enum export visibility inherit properly
1 parent 4eb5177 commit 7b0ed94

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/rustc/middle/resolve.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ impl Resolver {
10631063
for enum_definition.variants.each |variant| {
10641064
self.build_reduced_graph_for_variant(*variant,
10651065
local_def(item.id),
1066+
privacy,
10661067
new_parent,
10671068
visitor);
10681069
}
@@ -1156,17 +1157,20 @@ impl Resolver {
11561157
// type and/or value namespaces.
11571158
fn build_reduced_graph_for_variant(variant: variant,
11581159
item_id: def_id,
1160+
+parent_privacy: Privacy,
11591161
parent: ReducedGraphParent,
11601162
&&visitor: vt<ReducedGraphParent>) {
11611163

1162-
let legacy = match parent {
1163-
ModuleReducedGraphParent(m) => m.legacy_exports
1164-
};
1165-
11661164
let ident = variant.node.name;
11671165
let (child, _) = self.add_child(ident, parent, ~[ValueNS],
11681166
variant.span);
1169-
let privacy = self.visibility_to_privacy(variant.node.vis, legacy);
1167+
1168+
let privacy;
1169+
match variant.node.vis {
1170+
public => privacy = Public,
1171+
private => privacy = Private,
1172+
inherited => privacy = parent_privacy
1173+
}
11701174

11711175
match variant.node.kind {
11721176
tuple_variant_kind(_) => {
@@ -1188,6 +1192,7 @@ impl Resolver {
11881192
variant.span);
11891193
for enum_definition.variants.each |variant| {
11901194
self.build_reduced_graph_for_variant(*variant, item_id,
1195+
parent_privacy,
11911196
parent, visitor);
11921197
}
11931198
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mod a {
2+
pub enum Foo {
3+
Bar,
4+
Baz,
5+
Boo
6+
}
7+
}
8+
9+
fn main() {
10+
let x = a::Bar;
11+
}
12+

0 commit comments

Comments
 (0)