@@ -40,6 +40,7 @@ pub struct At<'a, 'tcx> {
40
40
/// matching from matching anything against opaque
41
41
/// types.
42
42
pub define_opaque_types : bool ,
43
+ pub defer_projection_equality : bool ,
43
44
}
44
45
45
46
pub struct Trace < ' a , ' tcx > {
@@ -55,7 +56,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
55
56
cause : & ' a ObligationCause < ' tcx > ,
56
57
param_env : ty:: ParamEnv < ' tcx > ,
57
58
) -> At < ' a , ' tcx > {
58
- At { infcx : self , cause, param_env, define_opaque_types : true }
59
+ At {
60
+ infcx : self ,
61
+ cause,
62
+ param_env,
63
+ define_opaque_types : true ,
64
+ defer_projection_equality : true ,
65
+ }
59
66
}
60
67
61
68
/// Forks the inference context, creating a new inference context with the same inference
@@ -101,6 +108,10 @@ impl<'a, 'tcx> At<'a, 'tcx> {
101
108
Self { define_opaque_types, ..self }
102
109
}
103
110
111
+ pub fn defer_projection_equality ( self , defer_projection_equality : bool ) -> Self {
112
+ Self { defer_projection_equality, ..self }
113
+ }
114
+
104
115
/// Hacky routine for equating two impl headers in coherence.
105
116
pub fn eq_impl_headers (
106
117
self ,
@@ -252,7 +263,12 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
252
263
{
253
264
let Trace { at, trace, a_is_expected } = self ;
254
265
at. infcx . commit_if_ok ( |_| {
255
- let mut fields = at. infcx . combine_fields ( trace, at. param_env , at. define_opaque_types ) ;
266
+ let mut fields = at. infcx . combine_fields (
267
+ trace,
268
+ at. param_env ,
269
+ at. define_opaque_types ,
270
+ at. defer_projection_equality ,
271
+ ) ;
256
272
fields
257
273
. sub ( a_is_expected)
258
274
. relate ( a, b)
@@ -269,7 +285,12 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
269
285
{
270
286
let Trace { at, trace, a_is_expected } = self ;
271
287
at. infcx . commit_if_ok ( |_| {
272
- let mut fields = at. infcx . combine_fields ( trace, at. param_env , at. define_opaque_types ) ;
288
+ let mut fields = at. infcx . combine_fields (
289
+ trace,
290
+ at. param_env ,
291
+ at. define_opaque_types ,
292
+ at. defer_projection_equality ,
293
+ ) ;
273
294
fields
274
295
. equate ( a_is_expected)
275
296
. relate ( a, b)
@@ -284,7 +305,12 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
284
305
{
285
306
let Trace { at, trace, a_is_expected } = self ;
286
307
at. infcx . commit_if_ok ( |_| {
287
- let mut fields = at. infcx . combine_fields ( trace, at. param_env , at. define_opaque_types ) ;
308
+ let mut fields = at. infcx . combine_fields (
309
+ trace,
310
+ at. param_env ,
311
+ at. define_opaque_types ,
312
+ at. defer_projection_equality ,
313
+ ) ;
288
314
fields
289
315
. lub ( a_is_expected)
290
316
. relate ( a, b)
@@ -299,7 +325,12 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
299
325
{
300
326
let Trace { at, trace, a_is_expected } = self ;
301
327
at. infcx . commit_if_ok ( |_| {
302
- let mut fields = at. infcx . combine_fields ( trace, at. param_env , at. define_opaque_types ) ;
328
+ let mut fields = at. infcx . combine_fields (
329
+ trace,
330
+ at. param_env ,
331
+ at. define_opaque_types ,
332
+ at. defer_projection_equality ,
333
+ ) ;
303
334
fields
304
335
. glb ( a_is_expected)
305
336
. relate ( a, b)
0 commit comments