Skip to content

Commit d1979a7

Browse files
committed
Replace DefineOpaqueTypes::No => DefineOpaqueTypes::Yes
1 parent 2520ca8 commit d1979a7

File tree

21 files changed

+64
-53
lines changed

21 files changed

+64
-53
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::No, r_a, *r_b).is_ok()
168+
if infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, 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::No, ty_a, ty_b)
207+
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, 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::No, a, b) {
409+
if let Ok(ok) = infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, 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::No, effect, param) {
802+
match self.at(&cause, self.param_env).eq(infer::DefineOpaqueTypes::Yes, 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::No,
1143+
DefineOpaqueTypes::Yes,
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::No, a_sig, b_sig)
1197+
.lub(DefineOpaqueTypes::Yes, 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::No, prev_ty, new_ty)
1286+
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, 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::No, prev_ty, new_ty)
1299+
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, 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::No, method.sig.inputs()[idx + 1], arg_ty)
394+
.eq(DefineOpaqueTypes::Yes, 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::No, ideal_rcvr_ty, expected_ty)
473+
.eq(DefineOpaqueTypes::Yes, 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::No,
1754+
DefineOpaqueTypes::Yes,
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::No, interior, witness)
545+
.eq(DefineOpaqueTypes::Yes, 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::No,
1426+
DefineOpaqueTypes::Yes,
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::No,
304+
DefineOpaqueTypes::Yes,
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::No, formal_input_ty, coerced_ty)
599+
.sup(DefineOpaqueTypes::Yes, 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::No, method_self_ty, self_ty) {
505+
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::Yes, 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: 7 additions & 3 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::No, fty.inputs()[0], self_ty)
938+
.sup(DefineOpaqueTypes::Yes, 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::No,
1457+
DefineOpaqueTypes::Yes,
14581458
candidate.xform_self_ty,
14591459
self_ty,
14601460
);
@@ -1485,6 +1485,10 @@ 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
14881492
DefineOpaqueTypes::No,
14891493
probe.xform_self_ty,
14901494
self_ty,
@@ -1693,7 +1697,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
16931697
if let ProbeResult::Match = result
16941698
&& self
16951699
.at(&ObligationCause::dummy(), self.param_env)
1696-
.sup(DefineOpaqueTypes::No, return_ty, xform_ret_ty)
1700+
.sup(DefineOpaqueTypes::Yes, return_ty, xform_ret_ty)
16971701
.is_err()
16981702
{
16991703
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::No, a, b).is_ok())
911+
self.probe(|_| self.at(origin, param_env).sub(DefineOpaqueTypes::Yes, 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::No, a, b).is_ok())
919+
self.probe(|_| self.at(origin, param_env).eq(DefineOpaqueTypes::Yes, 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::No, a_is_expected, a, b)?;
1015+
self.at(cause, param_env).sub_exp(DefineOpaqueTypes::Yes, a_is_expected, a, b)?;
10161016

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

0 commit comments

Comments
 (0)