@@ -47,10 +47,12 @@ pub(crate) fn collapse_interchangable_instances<'a, 'tcx>(
47
47
if false /*param.name.as_str().starts_with("<")*/ {
48
48
ty. into ( )
49
49
} else {
50
+ tcx. sess . warn ( & format ! ( "Unused subst for {:?}" , inst) ) ;
50
51
tcx. mk_ty ( ty:: TyNever )
51
52
}
52
53
} else {
53
54
// Can't use TyError as it gives some ICE in rustc_trans::callee::get_fn
55
+ tcx. sess . warn ( & format ! ( "Unused subst for {:?}" , inst) ) ;
54
56
tcx. mk_ty ( ty:: TyNever )
55
57
} ;
56
58
Kind :: from ( ty)
@@ -140,7 +142,7 @@ impl<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> TypeFolder<'gcx, 'tcx> for SubstsVisitor<'a,
140
142
141
143
fn used_substs_for_instance < ' a , ' tcx : ' a > (
142
144
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
143
- instance : Instance < ' tcx >
145
+ instance : Instance < ' tcx > ,
144
146
) -> UsedSubsts {
145
147
let mir = tcx. instance_mir ( instance. def ) ;
146
148
let sig = :: rustc:: ty:: ty_fn_sig ( tcx, instance. ty ( tcx) ) ;
@@ -154,5 +156,19 @@ fn used_substs_for_instance<'a, 'tcx: 'a>(
154
156
let mut used_substs = substs_visitor. 2 ;
155
157
used_substs. substs . sort_by_key ( |s|s. idx ) ;
156
158
used_substs. substs . dedup_by_key ( |s|s. idx ) ;
159
+ used_substs. promoted = mir. promoted . iter ( ) . map ( |mir| used_substs_for_mir ( tcx, mir) ) . collect ( ) ;
160
+ used_substs
161
+ }
162
+
163
+ fn used_substs_for_mir < ' a , ' tcx : ' a > (
164
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
165
+ mir : & ' tcx Mir < ' tcx > ,
166
+ ) -> UsedSubsts {
167
+ let mut substs_visitor = SubstsVisitor ( tcx, mir, UsedSubsts :: default ( ) ) ;
168
+ substs_visitor. visit_mir ( mir) ;
169
+ let mut used_substs = substs_visitor. 2 ;
170
+ used_substs. substs . sort_by_key ( |s|s. idx ) ;
171
+ used_substs. substs . dedup_by_key ( |s|s. idx ) ;
172
+ used_substs. promoted = mir. promoted . iter ( ) . map ( |mir| used_substs_for_mir ( tcx, mir) ) . collect ( ) ;
157
173
used_substs
158
174
}
0 commit comments