@@ -80,6 +80,9 @@ pub struct LoweringContext<'a> {
80
80
impl_items : BTreeMap < hir:: ImplItemId , hir:: ImplItem > ,
81
81
bodies : FxHashMap < hir:: BodyId , hir:: Body > ,
82
82
83
+ trait_impls : BTreeMap < DefId , Vec < NodeId > > ,
84
+ trait_default_impl : BTreeMap < DefId , NodeId > ,
85
+
83
86
loop_scopes : Vec < NodeId > ,
84
87
is_in_loop_condition : bool ,
85
88
@@ -116,6 +119,8 @@ pub fn lower_crate(sess: &Session,
116
119
trait_items : BTreeMap :: new ( ) ,
117
120
impl_items : BTreeMap :: new ( ) ,
118
121
bodies : FxHashMap ( ) ,
122
+ trait_impls : BTreeMap :: new ( ) ,
123
+ trait_default_impl : BTreeMap :: new ( ) ,
119
124
loop_scopes : Vec :: new ( ) ,
120
125
is_in_loop_condition : false ,
121
126
type_def_lifetime_params : DefIdMap ( ) ,
@@ -201,6 +206,8 @@ impl<'a> LoweringContext<'a> {
201
206
trait_items : self . trait_items ,
202
207
impl_items : self . impl_items ,
203
208
bodies : self . bodies ,
209
+ trait_impls : self . trait_impls ,
210
+ trait_default_impl : self . trait_default_impl ,
204
211
}
205
212
}
206
213
@@ -1089,14 +1096,27 @@ impl<'a> LoweringContext<'a> {
1089
1096
hir:: ItemUnion ( vdata, self . lower_generics ( generics) )
1090
1097
}
1091
1098
ItemKind :: DefaultImpl ( unsafety, ref trait_ref) => {
1099
+ let trait_ref = self . lower_trait_ref ( trait_ref) ;
1100
+
1101
+ if let Def :: Trait ( def_id) = trait_ref. path . def {
1102
+ self . trait_default_impl . insert ( def_id, id) ;
1103
+ }
1104
+
1092
1105
hir:: ItemDefaultImpl ( self . lower_unsafety ( unsafety) ,
1093
- self . lower_trait_ref ( trait_ref) )
1106
+ trait_ref)
1094
1107
}
1095
1108
ItemKind :: Impl ( unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
1096
1109
let new_impl_items = impl_items. iter ( )
1097
1110
. map ( |item| self . lower_impl_item_ref ( item) )
1098
1111
. collect ( ) ;
1099
1112
let ifce = ifce. as_ref ( ) . map ( |trait_ref| self . lower_trait_ref ( trait_ref) ) ;
1113
+
1114
+ if let Some ( ref trait_ref) = ifce {
1115
+ if let Def :: Trait ( def_id) = trait_ref. path . def {
1116
+ self . trait_impls . entry ( def_id) . or_insert ( vec ! [ ] ) . push ( id) ;
1117
+ }
1118
+ }
1119
+
1100
1120
hir:: ItemImpl ( self . lower_unsafety ( unsafety) ,
1101
1121
self . lower_impl_polarity ( polarity) ,
1102
1122
self . lower_generics ( generics) ,
0 commit comments