Skip to content

Commit e2567b0

Browse files
committed
Remove intermediate function doesn't make more sense
1 parent 19e3c86 commit e2567b0

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+11-28
Original file line numberDiff line numberDiff line change
@@ -249,33 +249,6 @@ fn stable_disjoint<'cx, 'tcx>(
249249
param_env: ty::ParamEnv<'tcx>,
250250
impl1_header: &ty::ImplHeader<'tcx>,
251251
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,
279252
) -> bool {
280253
debug!("overlap: impl1_header={:?}", impl1_header);
281254
debug!("overlap: impl2_header={:?}", impl2_header);
@@ -316,6 +289,7 @@ fn disjoint_with_filter<'cx, 'tcx>(
316289
// hold we need to check if `&'?a str: !Error` holds, if doesn't hold there's overlap because
317290
// at some point an impl for `&'?a str: Error` could be added.
318291
let infcx = selcx.infcx();
292+
let tcx = infcx.tcx;
319293
let opt_failing_obligation = impl1_header
320294
.predicates
321295
.iter()
@@ -329,7 +303,7 @@ fn disjoint_with_filter<'cx, 'tcx>(
329303
predicate: p,
330304
})
331305
.chain(obligations)
332-
.find(|o| filter(selcx, o));
306+
.find(|o| loose_check(selcx, o) || tcx.features().negative_impls && strict_check(selcx, o));
333307
// FIXME: the call to `selcx.predicate_may_hold_fatal` above should be ported
334308
// to the canonical trait query form, `infcx.predicate_may_hold`, once
335309
// the new system supports intercrate mode (which coherence needs).
@@ -344,6 +318,15 @@ fn disjoint_with_filter<'cx, 'tcx>(
344318

345319
/// Given impl1 and impl2 check if both impls are never satisfied by a common type (including
346320
/// 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+
347330
fn explicit_disjoint<'cx, 'tcx>(
348331
selcx: &mut SelectionContext<'cx, 'tcx>,
349332
impl1_def_id: DefId,

0 commit comments

Comments
 (0)