Skip to content

Commit 3811f6e

Browse files
committed
always define opaque types outside of trait solver
1 parent 63ef74b commit 3811f6e

File tree

18 files changed

+39
-35
lines changed

18 files changed

+39
-35
lines changed

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
160160
use rustc_type_ir::sty::TyKind::*;
161161
match (source.kind(), target.kind()) {
162162
(&Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b))
163-
if infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, r_a, *r_b).is_ok()
163+
if infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, r_a, *r_b).is_ok()
164164
&& mutbl_a == *mutbl_b => {}
165165
(&RawPtr(tm_a), &RawPtr(tm_b)) if tm_a.mutbl == tm_b.mutbl => (),
166166
(&Adt(def_a, substs_a), &Adt(def_b, substs_b))
@@ -205,7 +205,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
205205
}
206206

207207
if let Ok(ok) =
208-
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, ty_a, ty_b)
208+
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, ty_a, ty_b)
209209
{
210210
if ok.obligations.is_empty() {
211211
create_err(
@@ -427,7 +427,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
427427
// we may have to evaluate constraint
428428
// expressions in the course of execution.)
429429
// See e.g., #41936.
430-
if let Ok(ok) = infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, a, b) {
430+
if let Ok(ok) = infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, a, b) {
431431
if ok.obligations.is_empty() {
432432
return None;
433433
}

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
787787
if let Some(idx) = generics.host_effect_index {
788788
let param = callee_substs.const_at(idx);
789789
let cause = self.misc(span);
790-
match self.at(&cause, self.param_env).eq(infer::DefineOpaqueTypes::No, effect, param) {
790+
match self.at(&cause, self.param_env).eq(infer::DefineOpaqueTypes::Yes, effect, param) {
791791
Ok(infer::InferOk { obligations, value: () }) => {
792792
self.register_predicates(obligations);
793793
}

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11271127
// are the same function and their parameters have a LUB.
11281128
match self.commit_if_ok(|_| {
11291129
self.at(cause, self.param_env).lub(
1130-
DefineOpaqueTypes::No,
1130+
DefineOpaqueTypes::Yes,
11311131
prev_ty,
11321132
new_ty,
11331133
)
@@ -1181,7 +1181,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11811181
let sig = self
11821182
.at(cause, self.param_env)
11831183
.trace(prev_ty, new_ty)
1184-
.lub(DefineOpaqueTypes::No, a_sig, b_sig)
1184+
.lub(DefineOpaqueTypes::Yes, a_sig, b_sig)
11851185
.map(|ok| self.register_infer_ok_obligations(ok))?;
11861186

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

12711271
return self
12721272
.commit_if_ok(|_| {
1273-
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
1273+
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty)
12741274
})
12751275
.map(|ok| self.register_infer_ok_obligations(ok));
12761276
}
@@ -1283,7 +1283,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12831283
Err(e)
12841284
} else {
12851285
self.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
}

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
387387
// what our ideal rcvr ty would look like.
388388
let _ = self
389389
.at(&ObligationCause::dummy(), self.param_env)
390-
.eq(DefineOpaqueTypes::No, method.sig.inputs()[idx + 1], arg_ty)
390+
.eq(DefineOpaqueTypes::Yes, method.sig.inputs()[idx + 1], arg_ty)
391391
.ok()?;
392392
self.select_obligations_where_possible(|errs| {
393393
// Yeet the errors, we're already reporting errors.
@@ -449,7 +449,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
449449
.ok()
450450
.and_then(|method| {
451451
let _ = self.at(&ObligationCause::dummy(), self.param_env)
452-
.eq(DefineOpaqueTypes::No, ideal_rcvr_ty, expected_ty)
452+
.eq(DefineOpaqueTypes::Yes, ideal_rcvr_ty, expected_ty)
453453
.ok()?;
454454
Some(method)
455455
});

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17361736
let target_ty = self.field_ty(base_expr.span, f, substs);
17371737
let cause = self.misc(base_expr.span);
17381738
match self.at(&cause, self.param_env).sup(
1739-
DefineOpaqueTypes::No,
1739+
DefineOpaqueTypes::Yes,
17401740
target_ty,
17411741
fru_ty,
17421742
) {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
564564
let span = self.tcx.hir().body(body_id).value.span;
565565
let ok = self
566566
.at(&self.misc(span), self.param_env)
567-
.eq(DefineOpaqueTypes::No, interior, witness)
567+
.eq(DefineOpaqueTypes::Yes, interior, witness)
568568
.expect("Failed to unify generator interior type");
569569
let mut obligations = ok.obligations;
570570

@@ -1400,7 +1400,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14001400
let impl_ty = self.normalize(span, tcx.type_of(impl_def_id).subst(tcx, substs));
14011401
let self_ty = self.normalize(span, self_ty);
14021402
match self.at(&self.misc(span), self.param_env).eq(
1403-
DefineOpaqueTypes::No,
1403+
DefineOpaqueTypes::Yes,
14041404
impl_ty,
14051405
self_ty,
14061406
) {

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
296296
// 3. Check if the formal type is a supertype of the checked one
297297
// and register any such obligations for future type checks
298298
let supertype_error = self.at(&self.misc(provided_arg.span), self.param_env).sup(
299-
DefineOpaqueTypes::No,
299+
DefineOpaqueTypes::Yes,
300300
formal_input_ty,
301301
coerced_ty,
302302
);
@@ -591,7 +591,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
591591
// Using probe here, since we don't want this subtyping to affect inference.
592592
let subtyping_error = self.probe(|_| {
593593
self.at(&self.misc(arg_span), self.param_env)
594-
.sup(DefineOpaqueTypes::No, formal_input_ty, coerced_ty)
594+
.sup(DefineOpaqueTypes::Yes, formal_input_ty, coerced_ty)
595595
.err()
596596
});
597597

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub fn resolve_interior<'a, 'tcx>(
327327

328328
// Unify the type variable inside the generator with the new witness
329329
match fcx.at(&fcx.misc(body.value.span), fcx.param_env).eq(
330-
DefineOpaqueTypes::No,
330+
DefineOpaqueTypes::Yes,
331331
interior,
332332
witness,
333333
) {

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
substs,
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
936936
if let Some(self_ty) = self_ty {
937937
if self
938938
.at(&ObligationCause::dummy(), self.param_env)
939-
.sup(DefineOpaqueTypes::No, fty.inputs()[0], self_ty)
939+
.sup(DefineOpaqueTypes::Yes, fty.inputs()[0], self_ty)
940940
.is_err()
941941
{
942942
return false;
@@ -1455,7 +1455,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14551455
}
14561456
TraitCandidate(trait_ref) => self.probe(|_| {
14571457
let _ = self.at(&ObligationCause::dummy(), self.param_env).sup(
1458-
DefineOpaqueTypes::No,
1458+
DefineOpaqueTypes::Yes,
14591459
candidate.xform_self_ty,
14601460
self_ty,
14611461
);
@@ -1486,7 +1486,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14861486
self.probe(|_| {
14871487
// First check that the self type can be related.
14881488
let sub_obligations = match self.at(&ObligationCause::dummy(), self.param_env).sup(
1489-
DefineOpaqueTypes::No,
1489+
DefineOpaqueTypes::Yes,
14901490
probe.xform_self_ty,
14911491
self_ty,
14921492
) {
@@ -1698,7 +1698,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
16981698
if let ProbeResult::Match = result
16991699
&& self
17001700
.at(&ObligationCause::dummy(), self.param_env)
1701-
.sup(DefineOpaqueTypes::No, return_ty, xform_ret_ty)
1701+
.sup(DefineOpaqueTypes::Yes, return_ty, xform_ret_ty)
17021702
.is_err()
17031703
{
17041704
result = ProbeResult::BadReturnType;

0 commit comments

Comments
 (0)