@@ -167,6 +167,23 @@ struct EmbargoVisitor<'a> {
167
167
reexports : HashSet < ast:: NodeId > ,
168
168
}
169
169
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
+
170
187
impl < ' a > Visitor < ( ) > for EmbargoVisitor < ' a > {
171
188
fn visit_item ( & mut self , item : @ast:: item , _: ( ) ) {
172
189
let orig_all_pub = self . prev_exported ;
@@ -175,6 +192,12 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
175
192
// cannot have visibility qualifiers on them anyway
176
193
ast:: item_impl( ..) | ast:: item_foreign_mod( ..) => { }
177
194
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
+
178
201
// Private by default, hence we only retain the "public chain" if
179
202
// `pub` is explicitly listed.
180
203
_ => {
0 commit comments