@@ -38,16 +38,18 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
38
38
// check_for_overlapping_impls_of_trait() check, since that
39
39
// check can populate this table further with impls from other
40
40
// crates.
41
- let trait_def_ids: Vec < ast:: DefId > =
42
- self . tcx . trait_impls . borrow ( ) . keys ( ) . map ( |& d| d) . collect ( ) ;
41
+ let trait_def_ids: Vec < ( ast:: DefId , Vec < ast:: DefId > ) > =
42
+ self . tcx . trait_impls . borrow ( ) . iter ( ) . map ( |( & k, v) |
43
+ ( k, v. borrow ( ) . clone ( ) ) ) . collect ( ) ;
43
44
44
- for trait_def_id in trait_def_ids. iter ( ) {
45
- self . check_for_overlapping_impls_of_trait ( * trait_def_id) ;
45
+ for & ( trait_def_id, ref impls ) in trait_def_ids. iter ( ) {
46
+ self . check_for_overlapping_impls_of_trait ( trait_def_id, impls ) ;
46
47
}
47
48
}
48
49
49
50
fn check_for_overlapping_impls_of_trait ( & self ,
50
- trait_def_id : ast:: DefId )
51
+ trait_def_id : ast:: DefId ,
52
+ trait_impls : & Vec < ast:: DefId > )
51
53
{
52
54
debug ! ( "check_for_overlapping_impls_of_trait(trait_def_id={})" ,
53
55
trait_def_id. repr( self . tcx) ) ;
@@ -57,17 +59,14 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
57
59
ty:: populate_implementations_for_trait_if_necessary ( self . tcx ,
58
60
trait_def_id) ;
59
61
60
- let mut impls = Vec :: new ( ) ;
61
- self . push_impls_of_trait ( trait_def_id, & mut impls) ;
62
-
63
- for ( i, & impl1_def_id) in impls. iter ( ) . enumerate ( ) {
62
+ for ( i, & impl1_def_id) in trait_impls. iter ( ) . enumerate ( ) {
64
63
if impl1_def_id. krate != ast:: LOCAL_CRATE {
65
64
// we don't need to check impls if both are external;
66
65
// that's the other crate's job.
67
66
continue ;
68
67
}
69
68
70
- for & impl2_def_id in impls . slice_from ( i+1 ) . iter ( ) {
69
+ for & impl2_def_id in trait_impls . slice_from ( i+1 ) . iter ( ) {
71
70
self . check_if_impls_overlap ( trait_def_id,
72
71
impl1_def_id,
73
72
impl2_def_id) ;
@@ -108,15 +107,6 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
108
107
}
109
108
}
110
109
111
- fn push_impls_of_trait ( & self ,
112
- trait_def_id : ast:: DefId ,
113
- out : & mut Vec < ast:: DefId > ) {
114
- match self . tcx . trait_impls . borrow ( ) . get ( & trait_def_id) {
115
- Some ( impls) => { out. push_all ( impls. borrow ( ) . as_slice ( ) ) ; }
116
- None => { /* no impls */ }
117
- }
118
- }
119
-
120
110
fn span_of_impl ( & self , impl_did : ast:: DefId ) -> Span {
121
111
assert_eq ! ( impl_did. krate, ast:: LOCAL_CRATE ) ;
122
112
self . tcx . map . span ( impl_did. node )
0 commit comments