Skip to content

Commit efb1470

Browse files
committed
Revert "Replace DefineOpaqueTypes::No => DefineOpaqueTypes::Yes"
This reverts commit 5f842a7.
1 parent d1979a7 commit efb1470

File tree

21 files changed

+53
-64
lines changed

21 files changed

+53
-64
lines changed

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
165165
use rustc_type_ir::TyKind::*;
166166
match (source.kind(), target.kind()) {
167167
(&Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b))
168-
if infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, r_a, *r_b).is_ok()
168+
if infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, r_a, *r_b).is_ok()
169169
&& mutbl_a == *mutbl_b => {}
170170
(&RawPtr(tm_a), &RawPtr(tm_b)) if tm_a.mutbl == tm_b.mutbl => (),
171171
(&Adt(def_a, args_a), &Adt(def_b, args_b)) if def_a.is_struct() && def_b.is_struct() => {
@@ -204,7 +204,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
204204
}
205205

206206
if let Ok(ok) =
207-
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, ty_a, ty_b)
207+
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, ty_a, ty_b)
208208
{
209209
if ok.obligations.is_empty() {
210210
tcx.sess.emit_err(errors::DispatchFromDynZST {
@@ -406,7 +406,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
406406
// we may have to evaluate constraint
407407
// expressions in the course of execution.)
408408
// See e.g., #41936.
409-
if let Ok(ok) = infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, a, b) {
409+
if let Ok(ok) = infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, a, b) {
410410
if ok.obligations.is_empty() {
411411
return None;
412412
}

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
799799

800800
let param = callee_args.const_at(host_effect_index);
801801
let cause = self.misc(span);
802-
match self.at(&cause, self.param_env).eq(infer::DefineOpaqueTypes::Yes, effect, param) {
802+
match self.at(&cause, self.param_env).eq(infer::DefineOpaqueTypes::No, effect, param) {
803803
Ok(infer::InferOk { obligations, value: () }) => {
804804
self.register_predicates(obligations);
805805
}

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11401140
// are the same function and their parameters have a LUB.
11411141
match self.commit_if_ok(|_| {
11421142
self.at(cause, self.param_env).lub(
1143-
DefineOpaqueTypes::Yes,
1143+
DefineOpaqueTypes::No,
11441144
prev_ty,
11451145
new_ty,
11461146
)
@@ -1194,7 +1194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11941194
let sig = self
11951195
.at(cause, self.param_env)
11961196
.trace(prev_ty, new_ty)
1197-
.lub(DefineOpaqueTypes::Yes, a_sig, b_sig)
1197+
.lub(DefineOpaqueTypes::No, a_sig, b_sig)
11981198
.map(|ok| self.register_infer_ok_obligations(ok))?;
11991199

12001200
// Reify both sides and return the reified fn pointer type.
@@ -1283,7 +1283,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12831283

12841284
return self
12851285
.commit_if_ok(|_| {
1286-
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty)
1286+
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
12871287
})
12881288
.map(|ok| self.register_infer_ok_obligations(ok));
12891289
}
@@ -1296,7 +1296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12961296
Err(e)
12971297
} else {
12981298
self.commit_if_ok(|_| {
1299-
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty)
1299+
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
13001300
})
13011301
.map(|ok| self.register_infer_ok_obligations(ok))
13021302
}

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
391391
// what our ideal rcvr ty would look like.
392392
let _ = self
393393
.at(&ObligationCause::dummy(), self.param_env)
394-
.eq(DefineOpaqueTypes::Yes, method.sig.inputs()[idx + 1], arg_ty)
394+
.eq(DefineOpaqueTypes::No, method.sig.inputs()[idx + 1], arg_ty)
395395
.ok()?;
396396
self.select_obligations_where_possible(|errs| {
397397
// Yeet the errors, we're already reporting errors.
@@ -470,7 +470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
470470
.and_then(|method| {
471471
let _ = self
472472
.at(&ObligationCause::dummy(), self.param_env)
473-
.eq(DefineOpaqueTypes::Yes, ideal_rcvr_ty, expected_ty)
473+
.eq(DefineOpaqueTypes::No, ideal_rcvr_ty, expected_ty)
474474
.ok()?;
475475
Some(method)
476476
});

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17511751
let target_ty = self.field_ty(base_expr.span, f, args);
17521752
let cause = self.misc(base_expr.span);
17531753
match self.at(&cause, self.param_env).sup(
1754-
DefineOpaqueTypes::Yes,
1754+
DefineOpaqueTypes::No,
17551755
target_ty,
17561756
fru_ty,
17571757
) {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
542542
let span = self.tcx.hir().body(body_id).value.span;
543543
let ok = self
544544
.at(&self.misc(span), self.param_env)
545-
.eq(DefineOpaqueTypes::Yes, interior, witness)
545+
.eq(DefineOpaqueTypes::No, interior, witness)
546546
.expect("Failed to unify coroutine interior type");
547547
let mut obligations = ok.obligations;
548548

@@ -1423,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14231423
let impl_ty = self.normalize(span, tcx.type_of(impl_def_id).instantiate(tcx, args));
14241424
let self_ty = self.normalize(span, self_ty);
14251425
match self.at(&self.misc(span), self.param_env).eq(
1426-
DefineOpaqueTypes::Yes,
1426+
DefineOpaqueTypes::No,
14271427
impl_ty,
14281428
self_ty,
14291429
) {

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
301301
// 3. Check if the formal type is a supertype of the checked one
302302
// and register any such obligations for future type checks
303303
let supertype_error = self.at(&self.misc(provided_arg.span), self.param_env).sup(
304-
DefineOpaqueTypes::Yes,
304+
DefineOpaqueTypes::No,
305305
formal_input_ty,
306306
coerced_ty,
307307
);
@@ -596,7 +596,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
596596
// Using probe here, since we don't want this subtyping to affect inference.
597597
let subtyping_error = self.probe(|_| {
598598
self.at(&self.misc(arg_span), self.param_env)
599-
.sup(DefineOpaqueTypes::Yes, formal_input_ty, coerced_ty)
599+
.sup(DefineOpaqueTypes::No, formal_input_ty, coerced_ty)
600600
.err()
601601
});
602602

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
502502
args,
503503
})),
504504
);
505-
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::Yes, method_self_ty, self_ty) {
505+
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::No, method_self_ty, self_ty) {
506506
Ok(InferOk { obligations, value: () }) => {
507507
self.register_predicates(obligations);
508508
}

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
935935
if let Some(self_ty) = self_ty {
936936
if self
937937
.at(&ObligationCause::dummy(), self.param_env)
938-
.sup(DefineOpaqueTypes::Yes, fty.inputs()[0], self_ty)
938+
.sup(DefineOpaqueTypes::No, fty.inputs()[0], self_ty)
939939
.is_err()
940940
{
941941
return false;
@@ -1454,7 +1454,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14541454
}
14551455
TraitCandidate(trait_ref) => self.probe(|_| {
14561456
let _ = self.at(&ObligationCause::dummy(), self.param_env).sup(
1457-
DefineOpaqueTypes::Yes,
1457+
DefineOpaqueTypes::No,
14581458
candidate.xform_self_ty,
14591459
self_ty,
14601460
);
@@ -1485,10 +1485,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14851485
self.probe(|_| {
14861486
// First check that the self type can be related.
14871487
let sub_obligations = match self.at(&ObligationCause::dummy(), self.param_env).sup(
1488-
// https://github.com/rust-lang/rust/issues/116652
1489-
// Failed tests:
1490-
// tests/ui/impl-trait/issues/issue-70877.rs
1491-
// tests/ui/type-alias-impl-trait/type-alias-impl-trait.rs
14921488
DefineOpaqueTypes::No,
14931489
probe.xform_self_ty,
14941490
self_ty,
@@ -1697,7 +1693,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
16971693
if let ProbeResult::Match = result
16981694
&& self
16991695
.at(&ObligationCause::dummy(), self.param_env)
1700-
.sup(DefineOpaqueTypes::Yes, return_ty, xform_ret_ty)
1696+
.sup(DefineOpaqueTypes::No, return_ty, xform_ret_ty)
17011697
.is_err()
17021698
{
17031699
result = ProbeResult::BadReturnType;

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,15 +908,15 @@ impl<'tcx> InferCtxt<'tcx> {
908908
T: at::ToTrace<'tcx>,
909909
{
910910
let origin = &ObligationCause::dummy();
911-
self.probe(|_| self.at(origin, param_env).sub(DefineOpaqueTypes::Yes, a, b).is_ok())
911+
self.probe(|_| self.at(origin, param_env).sub(DefineOpaqueTypes::No, a, b).is_ok())
912912
}
913913

914914
pub fn can_eq<T>(&self, param_env: ty::ParamEnv<'tcx>, a: T, b: T) -> bool
915915
where
916916
T: at::ToTrace<'tcx>,
917917
{
918918
let origin = &ObligationCause::dummy();
919-
self.probe(|_| self.at(origin, param_env).eq(DefineOpaqueTypes::Yes, a, b).is_ok())
919+
self.probe(|_| self.at(origin, param_env).eq(DefineOpaqueTypes::No, a, b).is_ok())
920920
}
921921

922922
#[instrument(skip(self), level = "debug")]
@@ -1012,7 +1012,7 @@ impl<'tcx> InferCtxt<'tcx> {
10121012
self.instantiate_binder_with_placeholders(predicate);
10131013

10141014
let ok =
1015-
self.at(cause, param_env).sub_exp(DefineOpaqueTypes::Yes, a_is_expected, a, b)?;
1015+
self.at(cause, param_env).sub_exp(DefineOpaqueTypes::No, a_is_expected, a, b)?;
10161016

10171017
Ok(ok.unit())
10181018
}))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
323323
nested_goals.extend(
324324
infcx
325325
.at(&ObligationCause::dummy(), param_env)
326-
.eq(DefineOpaqueTypes::Yes, orig, response)
326+
.eq(DefineOpaqueTypes::No, orig, response)
327327
.map(|InferOk { value: (), obligations }| {
328328
obligations.into_iter().map(|o| Goal::from(o))
329329
})

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
721721
) -> Result<(), NoSolution> {
722722
self.infcx
723723
.at(&ObligationCause::dummy(), param_env)
724-
.eq(DefineOpaqueTypes::Yes, lhs, rhs)
724+
.eq(DefineOpaqueTypes::No, lhs, rhs)
725725
.map(|InferOk { value: (), obligations }| {
726726
self.add_goals(obligations.into_iter().map(|o| o.into()));
727727
})
@@ -740,7 +740,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
740740
) -> Result<(), NoSolution> {
741741
self.infcx
742742
.at(&ObligationCause::dummy(), param_env)
743-
.sub(DefineOpaqueTypes::Yes, sub, sup)
743+
.sub(DefineOpaqueTypes::No, sub, sup)
744744
.map(|InferOk { value: (), obligations }| {
745745
self.add_goals(obligations.into_iter().map(|o| o.into()));
746746
})
@@ -764,7 +764,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
764764
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
765765
self.infcx
766766
.at(&ObligationCause::dummy(), param_env)
767-
.eq(DefineOpaqueTypes::Yes, lhs, rhs)
767+
.eq(DefineOpaqueTypes::No, lhs, rhs)
768768
.map(|InferOk { value: (), obligations }| {
769769
obligations.into_iter().map(|o| o.into()).collect()
770770
})

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn rematch_impl<'tcx>(
202202
nested.extend(
203203
infcx
204204
.at(&ObligationCause::dummy(), goal.param_env)
205-
.eq(DefineOpaqueTypes::Yes, goal.predicate.trait_ref, impl_trait_ref)
205+
.eq(DefineOpaqueTypes::No, goal.predicate.trait_ref, impl_trait_ref)
206206
.map_err(|_| SelectionError::Unimplemented)?
207207
.into_obligations(),
208208
);
@@ -278,7 +278,7 @@ fn rematch_unsize<'tcx>(
278278
nested.extend(
279279
infcx
280280
.at(&ObligationCause::dummy(), goal.param_env)
281-
.eq(DefineOpaqueTypes::Yes, a_elem_ty, b_elem_ty)
281+
.eq(DefineOpaqueTypes::No, a_elem_ty, b_elem_ty)
282282
.expect("expected rematch to succeed")
283283
.into_obligations(),
284284
);
@@ -321,7 +321,7 @@ fn rematch_unsize<'tcx>(
321321
nested.extend(
322322
infcx
323323
.at(&ObligationCause::dummy(), goal.param_env)
324-
.eq(DefineOpaqueTypes::Yes, unsized_a_ty, b_ty)
324+
.eq(DefineOpaqueTypes::No, unsized_a_ty, b_ty)
325325
.expect("expected rematch to succeed")
326326
.into_obligations(),
327327
);
@@ -350,7 +350,7 @@ fn rematch_unsize<'tcx>(
350350
nested.extend(
351351
infcx
352352
.at(&ObligationCause::dummy(), goal.param_env)
353-
.eq(DefineOpaqueTypes::Yes, unsized_a_ty, b_ty)
353+
.eq(DefineOpaqueTypes::No, unsized_a_ty, b_ty)
354354
.expect("expected rematch to succeed")
355355
.into_obligations(),
356356
);

compiler/rustc_trait_selection/src/traits/auto_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
804804

805805
match (evaluate(c1), evaluate(c2)) {
806806
(Ok(c1), Ok(c2)) => {
807-
match selcx.infcx.at(&obligation.cause, obligation.param_env).eq(DefineOpaqueTypes::Yes,c1, c2)
807+
match selcx.infcx.at(&obligation.cause, obligation.param_env).eq(DefineOpaqueTypes::No,c1, c2)
808808
{
809809
Ok(_) => (),
810810
Err(_) => return false,

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3592,7 +3592,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
35923592
for (expected, actual) in zipped {
35933593
self.probe(|_| {
35943594
match self.at(&ObligationCause::misc(expr.span, body_id), param_env).eq(
3595-
DefineOpaqueTypes::Yes,
3595+
DefineOpaqueTypes::No,
35963596
expected,
35973597
actual,
35983598
) {

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
537537
if let Ok(new_obligations) = infcx
538538
.at(&obligation.cause, obligation.param_env)
539539
.trace(c1, c2)
540-
.eq(DefineOpaqueTypes::Yes, a.args, b.args)
540+
.eq(DefineOpaqueTypes::No, a.args, b.args)
541541
{
542542
return ProcessResult::Changed(mk_pending(
543543
new_obligations.into_obligations(),
@@ -548,7 +548,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
548548
(_, _) => {
549549
if let Ok(new_obligations) = infcx
550550
.at(&obligation.cause, obligation.param_env)
551-
.eq(DefineOpaqueTypes::Yes, c1, c2)
551+
.eq(DefineOpaqueTypes::No, c1, c2)
552552
{
553553
return ProcessResult::Changed(mk_pending(
554554
new_obligations.into_obligations(),
@@ -589,7 +589,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
589589
match (evaluate(c1), evaluate(c2)) {
590590
(Ok(c1), Ok(c2)) => {
591591
match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq(
592-
DefineOpaqueTypes::Yes,
592+
DefineOpaqueTypes::No,
593593
c1,
594594
c2,
595595
) {
@@ -631,7 +631,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
631631
}
632632
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
633633
match self.selcx.infcx.at(&obligation.cause, obligation.param_env).eq(
634-
DefineOpaqueTypes::Yes,
634+
DefineOpaqueTypes::No,
635635
ct.ty(),
636636
ty,
637637
) {

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ pub fn compute_inherent_assoc_ty_args<'a, 'b, 'tcx>(
14411441
// Infer the generic parameters of the impl by unifying the
14421442
// impl type with the self type of the projection.
14431443
let self_ty = alias_ty.self_ty();
1444-
match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, impl_ty, self_ty) {
1444+
match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, impl_ty, self_ty) {
14451445
Ok(mut ok) => obligations.append(&mut ok.obligations),
14461446
Err(_) => {
14471447
tcx.sess.delay_span_bug(
@@ -2354,7 +2354,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
23542354
debug!(?cache_projection, ?obligation_projection);
23552355

23562356
match infcx.at(cause, param_env).eq(
2357-
DefineOpaqueTypes::Yes,
2357+
DefineOpaqueTypes::No,
23582358
cache_projection,
23592359
obligation_projection,
23602360
) {

0 commit comments

Comments
 (0)