Skip to content

Commit 9f76362

Browse files
Teach HIR typeck how to deal with default-body RPITITs
1 parent 6fe1f9f commit 9f76362

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> InferCtxt<'tcx> {
5252
span: Span,
5353
param_env: ty::ParamEnv<'tcx>,
5454
) -> InferOk<'tcx, T> {
55-
if !value.has_opaque_types() {
55+
if !value.has_projections() {
5656
return InferOk { value, obligations: vec![] };
5757
}
5858
let mut obligations = vec![];
@@ -66,8 +66,11 @@ impl<'tcx> InferCtxt<'tcx> {
6666
lt_op: |lt| lt,
6767
ct_op: |ct| ct,
6868
ty_op: |ty| match *ty.kind() {
69-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })
70-
if replace_opaque_type(def_id) =>
69+
ty::Alias(_, ty::AliasTy { def_id, substs, .. })
70+
if matches!(
71+
self.tcx.def_kind(def_id),
72+
DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder
73+
) && replace_opaque_type(def_id) =>
7174
{
7275
let def_span = self.tcx.def_span(def_id);
7376
let span = if span.contains(def_span) { def_span } else { span };
@@ -81,9 +84,15 @@ impl<'tcx> InferCtxt<'tcx> {
8184
span,
8285
});
8386
obligations.extend(
84-
self.handle_opaque_type(ty, ty_var, true, &cause, param_env)
85-
.unwrap()
86-
.obligations,
87+
self.handle_opaque_type(
88+
self.tcx.mk_opaque(def_id, substs),
89+
ty_var,
90+
true,
91+
&cause,
92+
param_env,
93+
)
94+
.unwrap()
95+
.obligations,
8796
);
8897
ty_var
8998
}

0 commit comments

Comments
 (0)