@@ -249,33 +249,6 @@ fn stable_disjoint<'cx, 'tcx>(
249
249
param_env : ty:: ParamEnv < ' tcx > ,
250
250
impl1_header : & ty:: ImplHeader < ' tcx > ,
251
251
impl2_header : ty:: ImplHeader < ' tcx > ,
252
- ) -> bool {
253
- let infcx = selcx. infcx ( ) ;
254
- let tcx = infcx. tcx ;
255
-
256
- disjoint_with_filter ( selcx, param_env, impl1_header, impl2_header, |selcx, o| {
257
- loose_check ( selcx, o) || tcx. features ( ) . negative_impls && strict_check ( selcx, o)
258
- } )
259
- }
260
-
261
- fn strict_disjoint < ' cx , ' tcx > (
262
- selcx : & mut SelectionContext < ' cx , ' tcx > ,
263
- impl1_def_id : DefId ,
264
- impl2_def_id : DefId ,
265
- ) -> bool {
266
- explicit_disjoint ( selcx, impl1_def_id, impl2_def_id)
267
- || explicit_disjoint ( selcx, impl2_def_id, impl1_def_id)
268
- }
269
-
270
- fn disjoint_with_filter < ' cx , ' tcx > (
271
- selcx : & mut SelectionContext < ' cx , ' tcx > ,
272
- param_env : ty:: ParamEnv < ' tcx > ,
273
- impl1_header : & ty:: ImplHeader < ' tcx > ,
274
- impl2_header : ty:: ImplHeader < ' tcx > ,
275
- mut filter : impl FnMut (
276
- & mut SelectionContext < ' cx , ' tcx > ,
277
- & rustc_infer:: traits:: Obligation < ' tcx , rustc_middle:: ty:: Predicate < ' tcx > > ,
278
- ) -> bool ,
279
252
) -> bool {
280
253
debug ! ( "overlap: impl1_header={:?}" , impl1_header) ;
281
254
debug ! ( "overlap: impl2_header={:?}" , impl2_header) ;
@@ -316,6 +289,7 @@ fn disjoint_with_filter<'cx, 'tcx>(
316
289
// hold we need to check if `&'?a str: !Error` holds, if doesn't hold there's overlap because
317
290
// at some point an impl for `&'?a str: Error` could be added.
318
291
let infcx = selcx. infcx ( ) ;
292
+ let tcx = infcx. tcx ;
319
293
let opt_failing_obligation = impl1_header
320
294
. predicates
321
295
. iter ( )
@@ -329,7 +303,7 @@ fn disjoint_with_filter<'cx, 'tcx>(
329
303
predicate : p,
330
304
} )
331
305
. chain ( obligations)
332
- . find ( |o| filter ( selcx, o) ) ;
306
+ . find ( |o| loose_check ( selcx , o ) || tcx . features ( ) . negative_impls && strict_check ( selcx, o) ) ;
333
307
// FIXME: the call to `selcx.predicate_may_hold_fatal` above should be ported
334
308
// to the canonical trait query form, `infcx.predicate_may_hold`, once
335
309
// the new system supports intercrate mode (which coherence needs).
@@ -344,6 +318,15 @@ fn disjoint_with_filter<'cx, 'tcx>(
344
318
345
319
/// Given impl1 and impl2 check if both impls are never satisfied by a common type (including
346
320
/// where-clauses) If so, return true, they are disjoint and false otherwise.
321
+ fn strict_disjoint < ' cx , ' tcx > (
322
+ selcx : & mut SelectionContext < ' cx , ' tcx > ,
323
+ impl1_def_id : DefId ,
324
+ impl2_def_id : DefId ,
325
+ ) -> bool {
326
+ explicit_disjoint ( selcx, impl1_def_id, impl2_def_id)
327
+ || explicit_disjoint ( selcx, impl2_def_id, impl1_def_id)
328
+ }
329
+
347
330
fn explicit_disjoint < ' cx , ' tcx > (
348
331
selcx : & mut SelectionContext < ' cx , ' tcx > ,
349
332
impl1_def_id : DefId ,
0 commit comments