@@ -738,17 +738,6 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
738
738
tcx. predicates . borrow_mut ( ) . insert ( def_id, ty_predicates. clone ( ) ) ;
739
739
740
740
741
- // If there is a trait reference, treat the methods as always public.
742
- // This is to work around some incorrect behavior in privacy checking:
743
- // when the method belongs to a trait, it should acquire the privacy
744
- // from the trait, not the impl. Forcing the visibility to be public
745
- // makes things sorta work.
746
- let parent_visibility = if opt_trait_ref. is_some ( ) {
747
- hir:: Public
748
- } else {
749
- it. vis
750
- } ;
751
-
752
741
// Convert all the associated consts.
753
742
// Also, check if there are any duplicate associated items
754
743
let mut seen_type_items = FnvHashSet ( ) ;
@@ -771,9 +760,12 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
771
760
generics : ty_generics. clone ( ) ,
772
761
ty : ty,
773
762
} ) ;
763
+ // Trait-associated constants are always public.
764
+ let visibility =
765
+ if opt_trait_ref. is_some ( ) { hir:: Public } else { impl_item. vis } ;
774
766
convert_associated_const ( ccx, ImplContainer ( def_id) ,
775
767
impl_item. name , impl_item. id ,
776
- impl_item . vis . inherit_from ( parent_visibility ) ,
768
+ visibility ,
777
769
impl_item. defaultness ,
778
770
ty, true /* has_value */ ) ;
779
771
}
@@ -797,11 +789,9 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
797
789
798
790
for impl_item in impl_items {
799
791
if let hir:: ImplItemKind :: Method ( ref sig, _) = impl_item. node {
800
- // if the method specifies a visibility, use that, otherwise
801
- // inherit the visibility from the impl (so `foo` in `pub impl
802
- // { fn foo(); }` is public, but private in `impl { fn
803
- // foo(); }`).
804
- let method_vis = impl_item. vis . inherit_from ( parent_visibility) ;
792
+ // Trait methods are always public.
793
+ let method_vis =
794
+ if opt_trait_ref. is_some ( ) { hir:: Public } else { impl_item. vis } ;
805
795
806
796
convert_method ( ccx, ImplContainer ( def_id) ,
807
797
impl_item. name , impl_item. id , method_vis,
0 commit comments