Skip to content

Commit

Permalink
librustc: Don't allow enum struct variants to shadow structs.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Jun 20, 2013
1 parent f348465 commit 31b4b53
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,24 +1415,26 @@ impl Resolver {
(ReducedGraphParent,
vt<ReducedGraphParent>)) {
let ident = variant.node.name;
let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues,
variant.span);

let privacy;
match variant.node.vis {
public => privacy = Public,
private => privacy = Private,
inherited => privacy = parent_privacy
}

let privacy =
match variant.node.vis {
public => Public,
private => Private,
inherited => parent_privacy
};

match variant.node.kind {
tuple_variant_kind(_) => {
let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues,
variant.span);
child.define_value(privacy,
def_variant(item_id,
local_def(variant.node.id)),
variant.span);
}
struct_variant_kind(_) => {
let (child, _) = self.add_child(ident, parent, ForbidDuplicateTypesAndValues,
variant.span);
child.define_type(privacy,
def_variant(item_id,
local_def(variant.node.id)),
Expand Down

0 comments on commit 31b4b53

Please sign in to comment.