Skip to content

Commit c1645b2

Browse files
committed
Use DefineOpaqueTypes::Yes where the new solver is unconditionally used already
1 parent 42180ca commit c1645b2

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
310310
nested_goals.extend(
311311
infcx
312312
.at(&ObligationCause::dummy(), param_env)
313-
.eq(DefineOpaqueTypes::No, orig, response)
313+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
314+
.eq(DefineOpaqueTypes::Yes, orig, response)
314315
.map(|InferOk { value: (), obligations }| {
315316
obligations.into_iter().map(|o| Goal::from(o))
316317
})

compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
708708
) -> Result<(), NoSolution> {
709709
self.infcx
710710
.at(&ObligationCause::dummy(), param_env)
711-
.eq(DefineOpaqueTypes::No, lhs, rhs)
711+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
712+
.eq(DefineOpaqueTypes::Yes, lhs, rhs)
712713
.map(|InferOk { value: (), obligations }| {
713714
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
714715
})
@@ -727,7 +728,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
727728
) -> Result<(), NoSolution> {
728729
self.infcx
729730
.at(&ObligationCause::dummy(), param_env)
730-
.sub(DefineOpaqueTypes::No, sub, sup)
731+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
732+
.sub(DefineOpaqueTypes::Yes, sub, sup)
731733
.map(|InferOk { value: (), obligations }| {
732734
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
733735
})
@@ -747,7 +749,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
747749
) -> Result<(), NoSolution> {
748750
self.infcx
749751
.at(&ObligationCause::dummy(), param_env)
750-
.relate(DefineOpaqueTypes::No, lhs, variance, rhs)
752+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
753+
.relate(DefineOpaqueTypes::Yes, lhs, variance, rhs)
751754
.map(|InferOk { value: (), obligations }| {
752755
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
753756
})
@@ -771,7 +774,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
771774
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
772775
self.infcx
773776
.at(&ObligationCause::dummy(), param_env)
774-
.eq(DefineOpaqueTypes::No, lhs, rhs)
777+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
778+
.eq(DefineOpaqueTypes::Yes, lhs, rhs)
775779
.map(|InferOk { value: (), obligations }| {
776780
obligations.into_iter().map(|o| o.into()).collect()
777781
})

compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ fn rematch_impl<'tcx>(
201201
nested.extend(
202202
infcx
203203
.at(&ObligationCause::dummy(), goal.param_env)
204-
.eq(DefineOpaqueTypes::No, goal.predicate.trait_ref, impl_trait_ref)
204+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
205+
.eq(DefineOpaqueTypes::Yes, goal.predicate.trait_ref, impl_trait_ref)
205206
.map_err(|_| SelectionError::Unimplemented)?
206207
.into_obligations(),
207208
);
@@ -277,7 +278,8 @@ fn rematch_unsize<'tcx>(
277278
nested.extend(
278279
infcx
279280
.at(&ObligationCause::dummy(), goal.param_env)
280-
.eq(DefineOpaqueTypes::No, a_elem_ty, b_elem_ty)
281+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
282+
.eq(DefineOpaqueTypes::Yes, a_elem_ty, b_elem_ty)
281283
.expect("expected rematch to succeed")
282284
.into_obligations(),
283285
);
@@ -320,7 +322,8 @@ fn rematch_unsize<'tcx>(
320322
nested.extend(
321323
infcx
322324
.at(&ObligationCause::dummy(), goal.param_env)
323-
.eq(DefineOpaqueTypes::No, unsized_a_ty, b_ty)
325+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
326+
.eq(DefineOpaqueTypes::Yes, unsized_a_ty, b_ty)
324327
.expect("expected rematch to succeed")
325328
.into_obligations(),
326329
);
@@ -349,7 +352,8 @@ fn rematch_unsize<'tcx>(
349352
nested.extend(
350353
infcx
351354
.at(&ObligationCause::dummy(), goal.param_env)
352-
.eq(DefineOpaqueTypes::No, unsized_a_ty, b_ty)
355+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
356+
.eq(DefineOpaqueTypes::Yes, unsized_a_ty, b_ty)
353357
.expect("expected rematch to succeed")
354358
.into_obligations(),
355359
);

compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ fn plug_infer_with_placeholders<'tcx>(
425425
if ty.is_ty_var() {
426426
let Ok(InferOk { value: (), obligations }) =
427427
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
428-
DefineOpaqueTypes::No,
428+
// Already using new solver, so `DefineOpaqueTypes` is unused
429+
DefineOpaqueTypes::Yes,
429430
ty,
430431
Ty::new_placeholder(
431432
self.infcx.tcx,
@@ -453,7 +454,8 @@ fn plug_infer_with_placeholders<'tcx>(
453454
if ct.is_ct_infer() {
454455
let Ok(InferOk { value: (), obligations }) =
455456
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
456-
DefineOpaqueTypes::No,
457+
// Already using new solver, so `DefineOpaqueTypes` is unused
458+
DefineOpaqueTypes::Yes,
457459
ct,
458460
ty::Const::new_placeholder(
459461
self.infcx.tcx,
@@ -482,7 +484,8 @@ fn plug_infer_with_placeholders<'tcx>(
482484
if r.is_var() {
483485
let Ok(InferOk { value: (), obligations }) =
484486
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
485-
DefineOpaqueTypes::No,
487+
// Already using new solver, so `DefineOpaqueTypes` is unused
488+
DefineOpaqueTypes::Yes,
486489
r,
487490
ty::Region::new_placeholder(
488491
self.infcx.tcx,

0 commit comments

Comments
 (0)