@@ -44,7 +44,6 @@ impl<A> AutoTraitResult<A> {
4444pub struct AutoTraitInfo < ' cx > {
4545 pub full_user_env : ty:: ParamEnv < ' cx > ,
4646 pub region_data : RegionConstraintData < ' cx > ,
47- pub names_map : FxHashSet < String > ,
4847 pub vid_to_region : FxHashMap < ty:: RegionVid , ty:: Region < ' cx > > ,
4948}
5049
@@ -78,15 +77,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
7877 pub fn find_auto_trait_generics < A > (
7978 & self ,
8079 ty : Ty < ' tcx > ,
81- param_env_def_id : DefId ,
80+ orig_env : ty :: ParamEnv < ' tcx > ,
8281 trait_did : DefId ,
83- generics : & ty:: Generics ,
8482 auto_trait_callback : impl for < ' i > Fn ( & InferCtxt < ' _ , ' tcx , ' i > , AutoTraitInfo < ' i > ) -> A ,
8583 ) -> AutoTraitResult < A > {
8684 let tcx = self . tcx ;
8785
88- let orig_params = tcx. param_env ( param_env_def_id) ;
89-
9086 let trait_ref = ty:: TraitRef {
9187 def_id : trait_did,
9288 substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
@@ -98,16 +94,16 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
9894 let mut selcx = SelectionContext :: with_negative ( & infcx, true ) ;
9995 let result = selcx. select ( & Obligation :: new (
10096 ObligationCause :: dummy ( ) ,
101- orig_params ,
97+ orig_env ,
10298 trait_pred. to_poly_trait_predicate ( ) ,
10399 ) ) ;
104100
105101 match result {
106102 Ok ( Some ( Vtable :: VtableImpl ( _) ) ) => {
107103 debug ! (
108- "find_auto_trait_generics(ty={:?}, trait_did={:?}, generics= {:?}): \
104+ "find_auto_trait_generics({:?}): \
109105 manual impl found, bailing out",
110- ty , trait_did , generics
106+ trait_ref
111107 ) ;
112108 true
113109 }
@@ -160,8 +156,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
160156 & mut infcx,
161157 trait_did,
162158 ty,
163- orig_params . clone ( ) ,
164- orig_params ,
159+ orig_env ,
160+ orig_env ,
165161 & mut fresh_preds,
166162 false ,
167163 ) {
@@ -173,21 +169,21 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
173169 & mut infcx,
174170 trait_did,
175171 ty,
176- new_env. clone ( ) ,
172+ new_env,
177173 user_env,
178174 & mut fresh_preds,
179175 true ,
180176 ) . unwrap_or_else ( || {
181177 panic ! (
182178 "Failed to fully process: {:?} {:?} {:?}" ,
183- ty, trait_did, orig_params
179+ ty, trait_did, orig_env
184180 )
185181 } ) ;
186182
187183 debug ! (
188- "find_auto_trait_generics(ty={:?}, trait_did={:?}, generics= {:?}): fulfilling \
184+ "find_auto_trait_generics({:?}): fulfilling \
189185 with {:?}",
190- ty , trait_did , generics , full_env
186+ trait_ref , full_env
191187 ) ;
192188 infcx. clear_caches ( ) ;
193189
@@ -209,23 +205,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
209205 )
210206 } ) ;
211207
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-
221208 let body_id_map: FxHashMap < _ , _ > = infcx
222209 . region_obligations
223210 . borrow ( )
224211 . iter ( )
225212 . map ( |& ( id, _) | ( id, vec ! [ ] ) )
226213 . collect ( ) ;
227214
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) ;
229216
230217 let region_data = infcx
231218 . borrow_region_constraints ( )
@@ -237,7 +224,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
237224 let info = AutoTraitInfo {
238225 full_user_env,
239226 region_data,
240- names_map,
241227 vid_to_region,
242228 } ;
243229
@@ -284,7 +270,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
284270 // the final synthesized generics: we don't want our generated docs page to contain something
285271 // like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
286272 // '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 > (
288274 & self ,
289275 infcx : & InferCtxt < ' b , ' tcx , ' c > ,
290276 trait_did : DefId ,
@@ -311,13 +297,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
311297 let mut user_computed_preds: FxHashSet < _ > =
312298 user_env. caller_bounds . iter ( ) . cloned ( ) . collect ( ) ;
313299
314- let mut new_env = param_env. clone ( ) ;
300+ let mut new_env = param_env;
315301 let dummy_cause = ObligationCause :: misc ( DUMMY_SP , hir:: DUMMY_HIR_ID ) ;
316302
317303 while let Some ( pred) = predicates. pop_front ( ) {
318304 infcx. clear_caches ( ) ;
319305
320- if !already_visited. insert ( pred. clone ( ) ) {
306+ if !already_visited. insert ( pred) {
321307 continue ;
322308 }
323309
@@ -365,7 +351,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
365351 already_visited. remove ( & pred) ;
366352 self . add_user_pred (
367353 & mut user_computed_preds,
368- ty:: Predicate :: Trait ( pred. clone ( ) ) ,
354+ ty:: Predicate :: Trait ( pred) ,
369355 ) ;
370356 predicates. push_back ( pred) ;
371357 } else {
@@ -384,7 +370,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
384370
385371 computed_preds. extend ( user_computed_preds. iter ( ) . cloned ( ) ) ;
386372 let normalized_preds =
387- elaborate_predicates ( tcx, computed_preds. clone ( ) . into_iter ( ) . collect ( ) ) ;
373+ elaborate_predicates ( tcx, computed_preds. iter ( ) . cloned ( ) . collect ( ) ) ;
388374 new_env = ty:: ParamEnv :: new (
389375 tcx. mk_predicates ( normalized_preds) ,
390376 param_env. reveal ,
@@ -519,28 +505,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
519505 }
520506 }
521507
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-
541508 // This is very similar to handle_lifetimes. However, instead of matching ty::Region's
542509 // 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 > (
544511 & self ,
545512 regions : & RegionConstraintData < ' cx > ,
546513 ) -> FxHashMap < ty:: RegionVid , ty:: Region < ' cx > > {
@@ -650,7 +617,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
650617 }
651618 }
652619
653- pub fn evaluate_nested_obligations <
620+ fn evaluate_nested_obligations <
654621 ' b ,
655622 ' c ,
656623 ' d ,
@@ -669,10 +636,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
669636 let dummy_cause = ObligationCause :: misc ( DUMMY_SP , hir:: DUMMY_HIR_ID ) ;
670637
671638 for ( obligation, mut predicate) in nested
672- . map ( |o| ( o. clone ( ) , o. predicate . clone ( ) ) )
639+ . map ( |o| ( o. clone ( ) , o. predicate ) )
673640 {
674641 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) ) ;
676643
677644 // Resolve any inference variables that we can, to help selection succeed
678645 predicate = select. infcx ( ) . resolve_type_vars_if_possible ( & predicate) ;
@@ -690,14 +657,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
690657 // We check this by calling is_of_param on the relevant types
691658 // from the various possible predicates
692659 match & predicate {
693- & ty:: Predicate :: Trait ( ref p) => {
660+ & ty:: Predicate :: Trait ( p) => {
694661 if self . is_param_no_infer ( p. skip_binder ( ) . trait_ref . substs )
695662 && !only_projections
696663 && is_new_pred {
697664
698665 self . add_user_pred ( computed_preds, predicate) ;
699666 }
700- predicates. push_back ( p. clone ( ) ) ;
667+ predicates. push_back ( p) ;
701668 }
702669 & ty:: Predicate :: Projection ( p) => {
703670 debug ! ( "evaluate_nested_obligations: examining projection predicate {:?}" ,
@@ -739,7 +706,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
739706 if p. ty ( ) . skip_binder ( ) . has_infer_types ( ) {
740707 debug ! ( "Projecting and unifying projection predicate {:?}" ,
741708 predicate) ;
742- match poly_project_and_unify_type ( select, & obligation. with ( p. clone ( ) ) ) {
709+ match poly_project_and_unify_type ( select, & obligation. with ( p) ) {
743710 Err ( e) => {
744711 debug ! (
745712 "evaluate_nested_obligations: Unable to unify predicate \
0 commit comments