File tree 3 files changed +48
-6
lines changed
3 files changed +48
-6
lines changed Original file line number Diff line number Diff line change @@ -1620,18 +1620,20 @@ impl<'a> Resolver<'a> {
1620
1620
1621
1621
match def {
1622
1622
DefMod ( _) | DefForeignMod ( _) => { }
1623
- DefVariant ( _ , variant_id, is_struct) => {
1623
+ DefVariant ( enum_did , variant_id, is_struct) => {
1624
1624
debug ! ( "(building reduced graph for external crate) building \
1625
1625
variant {}",
1626
1626
final_ident) ;
1627
- // We assume the parent is visible, or else we wouldn't have seen
1628
- // it. Also variants are public-by-default if the parent was also
1629
- // public.
1627
+ // If this variant is public, then it was publicly reexported,
1628
+ // otherwise we need to inherit the visibility of the enum
1629
+ // definition.
1630
+ let is_exported = is_public ||
1631
+ self . external_exports . contains ( & enum_did) ;
1630
1632
if is_struct {
1631
- child_name_bindings. define_type ( def, DUMMY_SP , true ) ;
1633
+ child_name_bindings. define_type ( def, DUMMY_SP , is_exported ) ;
1632
1634
self . structs . insert ( variant_id) ;
1633
1635
} else {
1634
- child_name_bindings. define_value ( def, DUMMY_SP , true ) ;
1636
+ child_name_bindings. define_value ( def, DUMMY_SP , is_exported ) ;
1635
1637
}
1636
1638
}
1637
1639
DefFn ( ..) | DefStaticMethod ( ..) | DefStatic ( ..) => {
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ enum Foo {
12
+ Bar ( int )
13
+ }
14
+
15
+ pub mod test {
16
+ enum Foo {
17
+ Bar ( int )
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // aux-build:issue-11680.rs
12
+
13
+ extern crate other = "issue-11680" ;
14
+
15
+ fn main ( ) {
16
+ let _b = other:: Bar ( 1 ) ;
17
+ //~^ ERROR: variant `Bar` is private
18
+
19
+ let _b = other:: test:: Bar ( 1 ) ;
20
+ //~^ ERROR: variant `Bar` is private
21
+ }
You can’t perform that action at this time.
0 commit comments