@@ -162,24 +162,29 @@ pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>(
162162 obligation) ;
163163
164164 let infcx = selcx. infcx ( ) ;
165- infcx. commit_if_ok ( |snapshot| {
166- let ( skol_predicate, skol_map) =
167- infcx. skolemize_late_bound_regions ( & obligation. predicate , snapshot) ;
168-
169- let skol_obligation = obligation. with ( skol_predicate) ;
170- match project_and_unify_type ( selcx, & skol_obligation) {
171- Ok ( result) => {
172- let span = obligation. cause . span ;
173- match infcx. leak_check ( false , span, & skol_map, snapshot) {
174- Ok ( ( ) ) => Ok ( infcx. plug_leaks ( skol_map, snapshot, result) ) ,
175- Err ( e) => Err ( MismatchedProjectionTypes { err : e } ) ,
165+ if let Some ( skol_predicate) = infcx. tcx . no_late_bound_regions ( & obligation. predicate ) {
166+ // Fastpath: no escaping regions.
167+ project_and_unify_type ( selcx, & obligation. with ( skol_predicate) )
168+ } else {
169+ infcx. commit_if_ok ( |snapshot| {
170+ let ( skol_predicate, skol_map) =
171+ infcx. skolemize_late_bound_regions ( & obligation. predicate , snapshot) ;
172+
173+ let skol_obligation = obligation. with ( skol_predicate) ;
174+ match project_and_unify_type ( selcx, & skol_obligation) {
175+ Ok ( result) => {
176+ let span = obligation. cause . span ;
177+ match infcx. leak_check ( false , span, & skol_map, snapshot) {
178+ Ok ( ( ) ) => Ok ( infcx. plug_leaks ( skol_map, snapshot, result) ) ,
179+ Err ( e) => Err ( MismatchedProjectionTypes { err : e } ) ,
180+ }
181+ }
182+ Err ( e) => {
183+ Err ( e)
176184 }
177185 }
178- Err ( e) => {
179- Err ( e)
180- }
181- }
182- } )
186+ } )
187+ }
183188}
184189
185190/// Evaluates constraints of the form:
0 commit comments