Skip to content

Commit 19a5e1d

Browse files
Don't drop region constraints that come from plugging infer regions with placeholders
1 parent 46ecc10 commit 19a5e1d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -415,20 +415,20 @@ fn impl_intersection_has_negative_obligation(
415415
return false;
416416
};
417417

418-
plug_infer_with_placeholders(
419-
infcx,
420-
root_universe,
421-
(impl1_header.impl_args, impl2_header.impl_args),
422-
);
423-
let param_env = infcx.resolve_vars_if_possible(param_env);
424-
425418
// FIXME(with_negative_coherence): the infcx has constraints from equating
426419
// the impl headers. We should use these constraints as assumptions, not as
427420
// requirements, when proving the negated where clauses below.
428421
drop(equate_obligations);
429422
drop(infcx.take_registered_region_obligations());
430423
drop(infcx.take_and_reset_region_constraints());
431424

425+
plug_infer_with_placeholders(
426+
infcx,
427+
root_universe,
428+
(impl1_header.impl_args, impl2_header.impl_args),
429+
);
430+
let param_env = infcx.resolve_vars_if_possible(param_env);
431+
432432
util::elaborate(tcx, tcx.predicates_of(impl2_def_id).instantiate(tcx, impl2_header.impl_args))
433433
.any(|(clause, _)| try_prove_negated_where_clause(infcx, clause, param_env))
434434
}

tests/ui/coherence/coherence-negative-outlives-lifetimes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// revisions: stock with_negative_coherence
2+
23
//[with_negative_coherence] known-bug: unknown
4+
// Ideally this would work, but we don't use `&'a T` to imply that `T: 'a`
5+
// which is required for `&'a T: !MyPredicate` to hold. This is similar to the
6+
// test `negative-coherence-placeholder-region-constraints-on-unification.explicit.stderr`
37

48
#![feature(negative_impls)]
59
#![cfg_attr(with_negative_coherence, feature(with_negative_coherence))]

tests/ui/coherence/coherence-negative-outlives-lifetimes.stock.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `MyTrait<'_>` for type `&_`
2-
--> $DIR/coherence-negative-outlives-lifetimes.rs:14:1
2+
--> $DIR/coherence-negative-outlives-lifetimes.rs:18:1
33
|
44
LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
55
| ---------------------------------------------- first implementation here

tests/ui/coherence/coherence-negative-outlives-lifetimes.with_negative_coherence.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `MyTrait<'_>` for type `&_`
2-
--> $DIR/coherence-negative-outlives-lifetimes.rs:14:1
2+
--> $DIR/coherence-negative-outlives-lifetimes.rs:18:1
33
|
44
LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
55
| ---------------------------------------------- first implementation here

0 commit comments

Comments
 (0)