@@ -44,7 +44,6 @@ impl<A> AutoTraitResult<A> {
44
44
pub struct AutoTraitInfo < ' cx > {
45
45
pub full_user_env : ty:: ParamEnv < ' cx > ,
46
46
pub region_data : RegionConstraintData < ' cx > ,
47
- pub names_map : FxHashSet < String > ,
48
47
pub vid_to_region : FxHashMap < ty:: RegionVid , ty:: Region < ' cx > > ,
49
48
}
50
49
@@ -78,15 +77,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
78
77
pub fn find_auto_trait_generics < A > (
79
78
& self ,
80
79
ty : Ty < ' tcx > ,
81
- param_env_def_id : DefId ,
80
+ orig_env : ty :: ParamEnv < ' tcx > ,
82
81
trait_did : DefId ,
83
- generics : & ty:: Generics ,
84
82
auto_trait_callback : impl for < ' i > Fn ( & InferCtxt < ' _ , ' tcx , ' i > , AutoTraitInfo < ' i > ) -> A ,
85
83
) -> AutoTraitResult < A > {
86
84
let tcx = self . tcx ;
87
85
88
- let orig_params = tcx. param_env ( param_env_def_id) ;
89
-
90
86
let trait_ref = ty:: TraitRef {
91
87
def_id : trait_did,
92
88
substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
@@ -98,16 +94,16 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
98
94
let mut selcx = SelectionContext :: with_negative ( & infcx, true ) ;
99
95
let result = selcx. select ( & Obligation :: new (
100
96
ObligationCause :: dummy ( ) ,
101
- orig_params ,
97
+ orig_env ,
102
98
trait_pred. to_poly_trait_predicate ( ) ,
103
99
) ) ;
104
100
105
101
match result {
106
102
Ok ( Some ( Vtable :: VtableImpl ( _) ) ) => {
107
103
debug ! (
108
- "find_auto_trait_generics(ty={:?}, trait_did={:?}, generics= {:?}): \
104
+ "find_auto_trait_generics({:?}): \
109
105
manual impl found, bailing out",
110
- ty , trait_did , generics
106
+ trait_ref
111
107
) ;
112
108
true
113
109
}
@@ -160,8 +156,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
160
156
& mut infcx,
161
157
trait_did,
162
158
ty,
163
- orig_params . clone ( ) ,
164
- orig_params ,
159
+ orig_env ,
160
+ orig_env ,
165
161
& mut fresh_preds,
166
162
false ,
167
163
) {
@@ -173,21 +169,21 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
173
169
& mut infcx,
174
170
trait_did,
175
171
ty,
176
- new_env. clone ( ) ,
172
+ new_env,
177
173
user_env,
178
174
& mut fresh_preds,
179
175
true ,
180
176
) . unwrap_or_else ( || {
181
177
panic ! (
182
178
"Failed to fully process: {:?} {:?} {:?}" ,
183
- ty, trait_did, orig_params
179
+ ty, trait_did, orig_env
184
180
)
185
181
} ) ;
186
182
187
183
debug ! (
188
- "find_auto_trait_generics(ty={:?}, trait_did={:?}, generics= {:?}): fulfilling \
184
+ "find_auto_trait_generics({:?}): fulfilling \
189
185
with {:?}",
190
- ty , trait_did , generics , full_env
186
+ trait_ref , full_env
191
187
) ;
192
188
infcx. clear_caches ( ) ;
193
189
@@ -209,23 +205,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
209
205
)
210
206
} ) ;
211
207
212
- let names_map: FxHashSet < String > = generics
213
- . params
214
- . iter ( )
215
- . filter_map ( |param| match param. kind {
216
- ty:: GenericParamDefKind :: Lifetime => Some ( param. name . to_string ( ) ) ,
217
- _ => None ,
218
- } )
219
- . collect ( ) ;
220
-
221
208
let body_id_map: FxHashMap < _ , _ > = infcx
222
209
. region_obligations
223
210
. borrow ( )
224
211
. iter ( )
225
212
. map ( |& ( id, _) | ( id, vec ! [ ] ) )
226
213
. collect ( ) ;
227
214
228
- infcx. process_registered_region_obligations ( & body_id_map, None , full_env. clone ( ) ) ;
215
+ infcx. process_registered_region_obligations ( & body_id_map, None , full_env) ;
229
216
230
217
let region_data = infcx
231
218
. borrow_region_constraints ( )
@@ -237,7 +224,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
237
224
let info = AutoTraitInfo {
238
225
full_user_env,
239
226
region_data,
240
- names_map,
241
227
vid_to_region,
242
228
} ;
243
229
@@ -284,7 +270,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
284
270
// the final synthesized generics: we don't want our generated docs page to contain something
285
271
// like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
286
272
// 'user_env', which only holds the predicates that will actually be displayed to the user.
287
- pub fn evaluate_predicates < ' b , ' gcx , ' c > (
273
+ fn evaluate_predicates < ' b , ' gcx , ' c > (
288
274
& self ,
289
275
infcx : & InferCtxt < ' b , ' tcx , ' c > ,
290
276
trait_did : DefId ,
@@ -311,13 +297,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
311
297
let mut user_computed_preds: FxHashSet < _ > =
312
298
user_env. caller_bounds . iter ( ) . cloned ( ) . collect ( ) ;
313
299
314
- let mut new_env = param_env. clone ( ) ;
300
+ let mut new_env = param_env;
315
301
let dummy_cause = ObligationCause :: misc ( DUMMY_SP , hir:: DUMMY_HIR_ID ) ;
316
302
317
303
while let Some ( pred) = predicates. pop_front ( ) {
318
304
infcx. clear_caches ( ) ;
319
305
320
- if !already_visited. insert ( pred. clone ( ) ) {
306
+ if !already_visited. insert ( pred) {
321
307
continue ;
322
308
}
323
309
@@ -365,7 +351,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
365
351
already_visited. remove ( & pred) ;
366
352
self . add_user_pred (
367
353
& mut user_computed_preds,
368
- ty:: Predicate :: Trait ( pred. clone ( ) ) ,
354
+ ty:: Predicate :: Trait ( pred) ,
369
355
) ;
370
356
predicates. push_back ( pred) ;
371
357
} else {
@@ -384,7 +370,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
384
370
385
371
computed_preds. extend ( user_computed_preds. iter ( ) . cloned ( ) ) ;
386
372
let normalized_preds =
387
- elaborate_predicates ( tcx, computed_preds. clone ( ) . into_iter ( ) . collect ( ) ) ;
373
+ elaborate_predicates ( tcx, computed_preds. iter ( ) . cloned ( ) . collect ( ) ) ;
388
374
new_env = ty:: ParamEnv :: new (
389
375
tcx. mk_predicates ( normalized_preds) ,
390
376
param_env. reveal ,
@@ -519,28 +505,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
519
505
}
520
506
}
521
507
522
- pub fn region_name ( & self , region : Region < ' _ > ) -> Option < String > {
523
- match region {
524
- & ty:: ReEarlyBound ( r) => Some ( r. name . to_string ( ) ) ,
525
- _ => None ,
526
- }
527
- }
528
-
529
- pub fn get_lifetime ( & self , region : Region < ' _ > ,
530
- names_map : & FxHashMap < String , String > ) -> String {
531
- self . region_name ( region)
532
- . map ( |name|
533
- names_map. get ( & name) . unwrap_or_else ( ||
534
- panic ! ( "Missing lifetime with name {:?} for {:?}" , name, region)
535
- )
536
- )
537
- . cloned ( )
538
- . unwrap_or_else ( || "'static" . to_owned ( ) )
539
- }
540
-
541
508
// This is very similar to handle_lifetimes. However, instead of matching ty::Region's
542
509
// to each other, we match ty::RegionVid's to ty::Region's
543
- pub fn map_vid_to_region < ' cx > (
510
+ fn map_vid_to_region < ' cx > (
544
511
& self ,
545
512
regions : & RegionConstraintData < ' cx > ,
546
513
) -> FxHashMap < ty:: RegionVid , ty:: Region < ' cx > > {
@@ -650,7 +617,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
650
617
}
651
618
}
652
619
653
- pub fn evaluate_nested_obligations <
620
+ fn evaluate_nested_obligations <
654
621
' b ,
655
622
' c ,
656
623
' d ,
@@ -669,10 +636,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
669
636
let dummy_cause = ObligationCause :: misc ( DUMMY_SP , hir:: DUMMY_HIR_ID ) ;
670
637
671
638
for ( obligation, mut predicate) in nested
672
- . map ( |o| ( o. clone ( ) , o. predicate . clone ( ) ) )
639
+ . map ( |o| ( o. clone ( ) , o. predicate ) )
673
640
{
674
641
let is_new_pred =
675
- fresh_preds. insert ( self . clean_pred ( select. infcx ( ) , predicate. clone ( ) ) ) ;
642
+ fresh_preds. insert ( self . clean_pred ( select. infcx ( ) , predicate) ) ;
676
643
677
644
// Resolve any inference variables that we can, to help selection succeed
678
645
predicate = select. infcx ( ) . resolve_type_vars_if_possible ( & predicate) ;
@@ -690,14 +657,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
690
657
// We check this by calling is_of_param on the relevant types
691
658
// from the various possible predicates
692
659
match & predicate {
693
- & ty:: Predicate :: Trait ( ref p) => {
660
+ & ty:: Predicate :: Trait ( p) => {
694
661
if self . is_param_no_infer ( p. skip_binder ( ) . trait_ref . substs )
695
662
&& !only_projections
696
663
&& is_new_pred {
697
664
698
665
self . add_user_pred ( computed_preds, predicate) ;
699
666
}
700
- predicates. push_back ( p. clone ( ) ) ;
667
+ predicates. push_back ( p) ;
701
668
}
702
669
& ty:: Predicate :: Projection ( p) => {
703
670
debug ! ( "evaluate_nested_obligations: examining projection predicate {:?}" ,
@@ -739,7 +706,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
739
706
if p. ty ( ) . skip_binder ( ) . has_infer_types ( ) {
740
707
debug ! ( "Projecting and unifying projection predicate {:?}" ,
741
708
predicate) ;
742
- match poly_project_and_unify_type ( select, & obligation. with ( p. clone ( ) ) ) {
709
+ match poly_project_and_unify_type ( select, & obligation. with ( p) ) {
743
710
Err ( e) => {
744
711
debug ! (
745
712
"evaluate_nested_obligations: Unable to unify predicate \
0 commit comments