@@ -518,6 +518,21 @@ impl determine_rp_ctxt {
518
518
}
519
519
}
520
520
521
+ // For named types like Foo, if there is no explicit region
522
+ // parameter, then we will add the anonymous region, so there is
523
+ // a dependency if the anonymous region implies rp.
524
+ //
525
+ // If the region is explicitly specified, then we follows the
526
+ // normal rules.
527
+ fn opt_region_is_relevant ( opt_r : option < @ast:: region > ) -> bool {
528
+ debug ! ( "opt_region_is_relevant: %? (anon_implies_rp=%b)" ,
529
+ opt_r, self . anon_implies_rp) ;
530
+ match opt_r {
531
+ none => self . anon_implies_rp ,
532
+ some( r) => self . region_is_relevant ( r)
533
+ }
534
+ }
535
+
521
536
fn with ( item_id : ast:: node_id ,
522
537
anon_implies_rp : bool ,
523
538
f : fn ( ) ) {
@@ -613,19 +628,23 @@ fn determine_rp_in_ty(ty: @ast::ty,
613
628
// then check whether it is region-parameterized and consider
614
629
// that as a direct dependency.
615
630
match ty. node {
616
- ast:: ty_path( _ , id) => {
631
+ ast:: ty_path( path , id) => {
617
632
match cx. def_map . get ( id) {
618
633
ast:: def_ty( did) | ast:: def_class( did, _) => {
619
634
if did. crate == ast:: local_crate {
620
- cx. add_dep ( did. node ) ;
635
+ if cx. opt_region_is_relevant ( path. rp ) {
636
+ cx. add_dep ( did. node ) ;
637
+ }
621
638
} else {
622
639
let cstore = cx. sess . cstore ;
623
640
match csearch:: get_region_param ( cstore, did) {
624
641
none => { }
625
642
some( variance) => {
626
643
debug ! ( "reference to external, rp'd type %s" ,
627
644
pprust:: ty_to_str( ty, cx. sess. intr( ) ) ) ;
628
- cx. add_rp ( cx. item_id , cx. add_variance ( variance) )
645
+ if cx. opt_region_is_relevant ( path. rp ) {
646
+ cx. add_rp ( cx. item_id , cx. add_variance ( variance) )
647
+ }
629
648
}
630
649
}
631
650
}
0 commit comments