@@ -245,8 +245,13 @@ impl Graph<PackageId, Rc<Vec<Dependency>>> {
245
245
#[ derive( Clone , Debug , Default ) ]
246
246
pub struct PublicDependency {
247
247
/// For each active package the set of all the names it can see,
248
- /// for each name the exact package that name resolves to and whether it exports that visibility.
249
- inner : im_rc:: HashMap < PackageId , im_rc:: HashMap < InternedString , ( PackageId , bool ) > > ,
248
+ /// for each name the exact package that name resolves to,
249
+ /// the `ContextAge` when it was first visible,
250
+ /// and the `ContextAge` when it was first exported.
251
+ inner : im_rc:: HashMap <
252
+ PackageId ,
253
+ im_rc:: HashMap < InternedString , ( PackageId , ContextAge , Option < ContextAge > ) > ,
254
+ > ,
250
255
}
251
256
252
257
impl PublicDependency {
@@ -260,7 +265,7 @@ impl PublicDependency {
260
265
. get ( & candidate_pid) // if we have seen it before
261
266
. iter ( )
262
267
. flat_map ( |x| x. values ( ) ) // all the things we have stored
263
- . filter ( |x| x. 1 ) // as publicly exported
268
+ . filter ( |x| x. 2 . is_some ( ) ) // as publicly exported
264
269
. map ( |x| x. 0 )
265
270
. chain ( Some ( candidate_pid) ) // but even if not we know that everything exports itself
266
271
. collect ( )
@@ -270,6 +275,7 @@ impl PublicDependency {
270
275
candidate_pid : PackageId ,
271
276
parent_pid : PackageId ,
272
277
is_public : bool ,
278
+ age : ContextAge ,
273
279
parents : & Graph < PackageId , Rc < Vec < Dependency > > > ,
274
280
) {
275
281
// one tricky part is that `candidate_pid` may already be active and
@@ -284,21 +290,22 @@ impl PublicDependency {
284
290
im_rc:: hashmap:: Entry :: Occupied ( mut o) => {
285
291
// the (transitive) parent can already see something by `c`s name, it had better be `c`.
286
292
assert_eq ! ( o. get( ) . 0 , c) ;
287
- if o. get ( ) . 1 {
293
+ if o. get ( ) . 2 . is_some ( ) {
288
294
// The previous time the parent saw `c`, it was a public dependency.
289
295
// So all of its parents already know about `c`
290
296
// and we can save some time by stopping now.
291
297
continue ;
292
298
}
293
299
if public {
294
300
// Mark that `c` has now bean seen publicly
295
- o. insert ( ( c, public) ) ;
301
+ let old_age = o. get ( ) . 1 ;
302
+ o. insert ( ( c, old_age, if public { Some ( age) } else { None } ) ) ;
296
303
}
297
304
}
298
305
im_rc:: hashmap:: Entry :: Vacant ( v) => {
299
306
// The (transitive) parent does not have anything by `c`s name,
300
307
// so we add `c`.
301
- v. insert ( ( c, public) ) ;
308
+ v. insert ( ( c, age , if public { Some ( age ) } else { None } ) ) ;
302
309
}
303
310
}
304
311
// if `candidate_pid` was a private dependency of `p` then `p` parents can't see `c` thru `p`
@@ -331,7 +338,7 @@ impl PublicDependency {
331
338
// So, adding `b` will cause `p` to have a public dependency conflict on `t`.
332
339
return Err ( ( p, ConflictReason :: PublicDependency ) ) ;
333
340
}
334
- if o. 1 {
341
+ if o. 2 . is_some ( ) {
335
342
// The previous time the parent saw `t`, it was a public dependency.
336
343
// So all of its parents already know about `t`
337
344
// and we can save some time by stopping now.
0 commit comments