@@ -167,6 +167,23 @@ struct EmbargoVisitor<'a> {
167167 reexports : HashSet < ast:: NodeId > ,
168168}
169169
170+ impl < ' a > EmbargoVisitor < ' a > {
171+ // There are checks inside of privacy which depend on knowing whether a
172+ // trait should be exported or not. The two current consumers of this are:
173+ //
174+ // 1. Should default methods of a trait be exported?
175+ // 2. Should the methods of an implementation of a trait be exported?
176+ //
177+ // The answer to both of these questions partly rely on whether the trait
178+ // itself is exported or not. If the trait is somehow exported, then the
179+ // answers to both questions must be yes. Right now this question involves
180+ // more analysis than is currently done in rustc, so we conservatively
181+ // answer "yes" so that all traits need to be exported.
182+ fn exported_trait ( & self , _id : ast:: NodeId ) -> bool {
183+ true
184+ }
185+ }
186+
170187impl < ' a > Visitor < ( ) > for EmbargoVisitor < ' a > {
171188 fn visit_item ( & mut self , item : @ast:: item , _: ( ) ) {
172189 let orig_all_pub = self . prev_exported ;
@@ -175,6 +192,12 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
175192 // cannot have visibility qualifiers on them anyway
176193 ast:: item_impl( ..) | ast:: item_foreign_mod( ..) => { }
177194
195+ // Traits are a little special in that even if they themselves are
196+ // not public they may still be exported.
197+ ast:: item_trait( ..) => {
198+ self . prev_exported = self . exported_trait ( item. id ) ;
199+ }
200+
178201 // Private by default, hence we only retain the "public chain" if
179202 // `pub` is explicitly listed.
180203 _ => {
0 commit comments