@@ -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
@@ -77,15 +76,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
7776 /// in the future.
7877 pub fn find_auto_trait_generics < A > (
7978 & self ,
80- did : DefId ,
79+ ty : Ty < ' tcx > ,
80+ orig_env : ty:: ParamEnv < ' tcx > ,
8181 trait_did : DefId ,
82- generics : & ty:: Generics ,
8382 auto_trait_callback : impl for < ' i > Fn ( & InferCtxt < ' _ , ' tcx , ' i > , AutoTraitInfo < ' i > ) -> A ,
8483 ) -> AutoTraitResult < A > {
8584 let tcx = self . tcx ;
86- let ty = self . tcx . type_of ( did) ;
87-
88- let orig_params = tcx. param_env ( did) ;
8985
9086 let trait_ref = ty:: TraitRef {
9187 def_id : trait_did,
@@ -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(did={:?}, trait_did={:?}, generics= {:?}): \
104+ "find_auto_trait_generics({:?}): \
109105 manual impl found, bailing out",
110- did , trait_did , generics
106+ trait_ref
111107 ) ;
112108 true
113109 }
@@ -158,11 +154,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
158154
159155 let ( new_env, user_env) = match self . evaluate_predicates (
160156 & mut infcx,
161- did,
162157 trait_did,
163158 ty,
164- orig_params . clone ( ) ,
165- orig_params ,
159+ orig_env ,
160+ orig_env ,
166161 & mut fresh_preds,
167162 false ,
168163 ) {
@@ -172,24 +167,23 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
172167
173168 let ( full_env, full_user_env) = self . evaluate_predicates (
174169 & mut infcx,
175- did,
176170 trait_did,
177171 ty,
178- new_env. clone ( ) ,
172+ new_env,
179173 user_env,
180174 & mut fresh_preds,
181175 true ,
182176 ) . unwrap_or_else ( || {
183177 panic ! (
184178 "Failed to fully process: {:?} {:?} {:?}" ,
185- ty, trait_did, orig_params
179+ ty, trait_did, orig_env
186180 )
187181 } ) ;
188182
189183 debug ! (
190- "find_auto_trait_generics(did={:?}, trait_did={:?}, generics= {:?}): fulfilling \
184+ "find_auto_trait_generics({:?}): fulfilling \
191185 with {:?}",
192- did , trait_did , generics , full_env
186+ trait_ref , full_env
193187 ) ;
194188 infcx. clear_caches ( ) ;
195189
@@ -211,23 +205,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
211205 )
212206 } ) ;
213207
214- let names_map: FxHashSet < String > = generics
215- . params
216- . iter ( )
217- . filter_map ( |param| match param. kind {
218- ty:: GenericParamDefKind :: Lifetime => Some ( param. name . to_string ( ) ) ,
219- _ => None ,
220- } )
221- . collect ( ) ;
222-
223208 let body_id_map: FxHashMap < _ , _ > = infcx
224209 . region_obligations
225210 . borrow ( )
226211 . iter ( )
227212 . map ( |& ( id, _) | ( id, vec ! [ ] ) )
228213 . collect ( ) ;
229214
230- infcx. process_registered_region_obligations ( & body_id_map, None , full_env. clone ( ) ) ;
215+ infcx. process_registered_region_obligations ( & body_id_map, None , full_env) ;
231216
232217 let region_data = infcx
233218 . borrow_region_constraints ( )
@@ -239,7 +224,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
239224 let info = AutoTraitInfo {
240225 full_user_env,
241226 region_data,
242- names_map,
243227 vid_to_region,
244228 } ;
245229
@@ -286,10 +270,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
286270 // the final synthesized generics: we don't want our generated docs page to contain something
287271 // like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
288272 // 'user_env', which only holds the predicates that will actually be displayed to the user.
289- pub fn evaluate_predicates < ' b , ' gcx , ' c > (
273+ fn evaluate_predicates < ' b , ' gcx , ' c > (
290274 & self ,
291275 infcx : & InferCtxt < ' b , ' tcx , ' c > ,
292- ty_did : DefId ,
293276 trait_did : DefId ,
294277 ty : Ty < ' c > ,
295278 param_env : ty:: ParamEnv < ' c > ,
@@ -314,13 +297,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
314297 let mut user_computed_preds: FxHashSet < _ > =
315298 user_env. caller_bounds . iter ( ) . cloned ( ) . collect ( ) ;
316299
317- let mut new_env = param_env. clone ( ) ;
300+ let mut new_env = param_env;
318301 let dummy_cause = ObligationCause :: misc ( DUMMY_SP , hir:: DUMMY_HIR_ID ) ;
319302
320303 while let Some ( pred) = predicates. pop_front ( ) {
321304 infcx. clear_caches ( ) ;
322305
323- if !already_visited. insert ( pred. clone ( ) ) {
306+ if !already_visited. insert ( pred) {
324307 continue ;
325308 }
326309
@@ -368,7 +351,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
368351 already_visited. remove ( & pred) ;
369352 self . add_user_pred (
370353 & mut user_computed_preds,
371- ty:: Predicate :: Trait ( pred. clone ( ) ) ,
354+ ty:: Predicate :: Trait ( pred) ,
372355 ) ;
373356 predicates. push_back ( pred) ;
374357 } else {
@@ -387,7 +370,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
387370
388371 computed_preds. extend ( user_computed_preds. iter ( ) . cloned ( ) ) ;
389372 let normalized_preds =
390- elaborate_predicates ( tcx, computed_preds. clone ( ) . into_iter ( ) . collect ( ) ) ;
373+ elaborate_predicates ( tcx, computed_preds. iter ( ) . cloned ( ) . collect ( ) ) ;
391374 new_env = ty:: ParamEnv :: new (
392375 tcx. mk_predicates ( normalized_preds) ,
393376 param_env. reveal ,
@@ -401,9 +384,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
401384 None
402385 ) ;
403386 debug ! (
404- "evaluate_nested_obligations(ty_did ={:?}, trait_did={:?}): succeeded with '{:?}' \
387+ "evaluate_nested_obligations(ty ={:?}, trait_did={:?}): succeeded with '{:?}' \
405388 '{:?}'",
406- ty_did , trait_did, new_env, final_user_env
389+ ty , trait_did, new_env, final_user_env
407390 ) ;
408391
409392 return Some ( ( new_env, final_user_env) ) ;
@@ -522,28 +505,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
522505 }
523506 }
524507
525- pub fn region_name ( & self , region : Region < ' _ > ) -> Option < String > {
526- match region {
527- & ty:: ReEarlyBound ( r) => Some ( r. name . to_string ( ) ) ,
528- _ => None ,
529- }
530- }
531-
532- pub fn get_lifetime ( & self , region : Region < ' _ > ,
533- names_map : & FxHashMap < String , String > ) -> String {
534- self . region_name ( region)
535- . map ( |name|
536- names_map. get ( & name) . unwrap_or_else ( ||
537- panic ! ( "Missing lifetime with name {:?} for {:?}" , name, region)
538- )
539- )
540- . cloned ( )
541- . unwrap_or_else ( || "'static" . to_owned ( ) )
542- }
543-
544508 // This is very similar to handle_lifetimes. However, instead of matching ty::Region's
545509 // to each other, we match ty::RegionVid's to ty::Region's
546- pub fn map_vid_to_region < ' cx > (
510+ fn map_vid_to_region < ' cx > (
547511 & self ,
548512 regions : & RegionConstraintData < ' cx > ,
549513 ) -> FxHashMap < ty:: RegionVid , ty:: Region < ' cx > > {
@@ -653,7 +617,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
653617 }
654618 }
655619
656- pub fn evaluate_nested_obligations <
620+ fn evaluate_nested_obligations <
657621 ' b ,
658622 ' c ,
659623 ' d ,
@@ -672,10 +636,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
672636 let dummy_cause = ObligationCause :: misc ( DUMMY_SP , hir:: DUMMY_HIR_ID ) ;
673637
674638 for ( obligation, mut predicate) in nested
675- . map ( |o| ( o. clone ( ) , o. predicate . clone ( ) ) )
639+ . map ( |o| ( o. clone ( ) , o. predicate ) )
676640 {
677641 let is_new_pred =
678- fresh_preds. insert ( self . clean_pred ( select. infcx ( ) , predicate. clone ( ) ) ) ;
642+ fresh_preds. insert ( self . clean_pred ( select. infcx ( ) , predicate) ) ;
679643
680644 // Resolve any inference variables that we can, to help selection succeed
681645 predicate = select. infcx ( ) . resolve_type_vars_if_possible ( & predicate) ;
@@ -693,14 +657,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
693657 // We check this by calling is_of_param on the relevant types
694658 // from the various possible predicates
695659 match & predicate {
696- & ty:: Predicate :: Trait ( ref p) => {
660+ & ty:: Predicate :: Trait ( p) => {
697661 if self . is_param_no_infer ( p. skip_binder ( ) . trait_ref . substs )
698662 && !only_projections
699663 && is_new_pred {
700664
701665 self . add_user_pred ( computed_preds, predicate) ;
702666 }
703- predicates. push_back ( p. clone ( ) ) ;
667+ predicates. push_back ( p) ;
704668 }
705669 & ty:: Predicate :: Projection ( p) => {
706670 debug ! ( "evaluate_nested_obligations: examining projection predicate {:?}" ,
@@ -742,7 +706,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
742706 if p. ty ( ) . skip_binder ( ) . has_infer_types ( ) {
743707 debug ! ( "Projecting and unifying projection predicate {:?}" ,
744708 predicate) ;
745- match poly_project_and_unify_type ( select, & obligation. with ( p. clone ( ) ) ) {
709+ match poly_project_and_unify_type ( select, & obligation. with ( p) ) {
746710 Err ( e) => {
747711 debug ! (
748712 "evaluate_nested_obligations: Unable to unify predicate \
0 commit comments