Skip to content

Commit 2247aaf

Browse files
committed
Use DefineOpaqueTypes::Yes where the new solver is unconditionally used already
1 parent 82ceed2 commit 2247aaf

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
720720
) -> Result<(), NoSolution> {
721721
self.infcx
722722
.at(&ObligationCause::dummy(), param_env)
723-
.eq(DefineOpaqueTypes::No, lhs, rhs)
723+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
724+
.eq(DefineOpaqueTypes::Yes, lhs, rhs)
724725
.map(|InferOk { value: (), obligations }| {
725726
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
726727
})
@@ -759,7 +760,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
759760
) -> Result<(), NoSolution> {
760761
self.infcx
761762
.at(&ObligationCause::dummy(), param_env)
762-
.sub(DefineOpaqueTypes::No, sub, sup)
763+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
764+
.sub(DefineOpaqueTypes::Yes, sub, sup)
763765
.map(|InferOk { value: (), obligations }| {
764766
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
765767
})
@@ -779,7 +781,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
779781
) -> Result<(), NoSolution> {
780782
self.infcx
781783
.at(&ObligationCause::dummy(), param_env)
782-
.relate(DefineOpaqueTypes::No, lhs, variance, rhs)
784+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
785+
.relate(DefineOpaqueTypes::Yes, lhs, variance, rhs)
783786
.map(|InferOk { value: (), obligations }| {
784787
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
785788
})
@@ -803,7 +806,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
803806
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
804807
self.infcx
805808
.at(&ObligationCause::dummy(), param_env)
806-
.eq(DefineOpaqueTypes::No, lhs, rhs)
809+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
810+
.eq(DefineOpaqueTypes::Yes, lhs, rhs)
807811
.map(|InferOk { value: (), obligations }| {
808812
obligations.into_iter().map(|o| o.into()).collect()
809813
})

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ fn rematch_impl<'tcx>(
182182

183183
let mut nested = infcx
184184
.at(&ObligationCause::dummy(), goal.param_env)
185-
.eq(DefineOpaqueTypes::No, goal.predicate.trait_ref, impl_trait_ref)
185+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
186+
.eq(DefineOpaqueTypes::Yes, goal.predicate.trait_ref, impl_trait_ref)
186187
.map_err(|_| SelectionError::Unimplemented)?
187188
.into_obligations();
188189

@@ -257,7 +258,8 @@ fn rematch_unsize<'tcx>(
257258
nested.extend(
258259
infcx
259260
.at(&ObligationCause::dummy(), goal.param_env)
260-
.eq(DefineOpaqueTypes::No, a_elem_ty, b_elem_ty)
261+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
262+
.eq(DefineOpaqueTypes::Yes, a_elem_ty, b_elem_ty)
261263
.expect("expected rematch to succeed")
262264
.into_obligations(),
263265
);
@@ -300,7 +302,8 @@ fn rematch_unsize<'tcx>(
300302
nested.extend(
301303
infcx
302304
.at(&ObligationCause::dummy(), goal.param_env)
303-
.eq(DefineOpaqueTypes::No, unsized_a_ty, b_ty)
305+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
306+
.eq(DefineOpaqueTypes::Yes, unsized_a_ty, b_ty)
304307
.expect("expected rematch to succeed")
305308
.into_obligations(),
306309
);
@@ -329,7 +332,8 @@ fn rematch_unsize<'tcx>(
329332
nested.extend(
330333
infcx
331334
.at(&ObligationCause::dummy(), goal.param_env)
332-
.eq(DefineOpaqueTypes::No, unsized_a_ty, b_ty)
335+
// New solver ignores DefineOpaqueTypes, so choose Yes for consistency
336+
.eq(DefineOpaqueTypes::Yes, unsized_a_ty, b_ty)
333337
.expect("expected rematch to succeed")
334338
.into_obligations(),
335339
);

compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ fn plug_infer_with_placeholders<'tcx>(
477477
if ty.is_ty_var() {
478478
let Ok(InferOk { value: (), obligations }) =
479479
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
480-
DefineOpaqueTypes::No,
480+
// Comparing against a type variable never registers hidden types anyway
481+
DefineOpaqueTypes::Yes,
481482
ty,
482483
Ty::new_placeholder(
483484
self.infcx.tcx,
@@ -504,7 +505,9 @@ fn plug_infer_with_placeholders<'tcx>(
504505
if ct.is_ct_infer() {
505506
let Ok(InferOk { value: (), obligations }) =
506507
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
507-
DefineOpaqueTypes::No,
508+
// The types of the constants are the same, so there is no hidden type
509+
// registration happening anyway.
510+
DefineOpaqueTypes::Yes,
508511
ct,
509512
ty::Const::new_placeholder(
510513
self.infcx.tcx,
@@ -532,7 +535,8 @@ fn plug_infer_with_placeholders<'tcx>(
532535
if r.is_var() {
533536
let Ok(InferOk { value: (), obligations }) =
534537
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
535-
DefineOpaqueTypes::No,
538+
// Lifetimes don't contain opaque types (or any types for that matter).
539+
DefineOpaqueTypes::Yes,
536540
r,
537541
ty::Region::new_placeholder(
538542
self.infcx.tcx,

0 commit comments

Comments
 (0)