Skip to content

Commit 9f09a5e

Browse files
committed
Resolve nested inference variables.
I attempted that with the previous code, but I misunderstdood how `shallow_resolve` works.
1 parent a8551ab commit 9f09a5e

File tree

1 file changed

+7
-19
lines changed
  • compiler/rustc_mir/src/borrow_check/type_check

1 file changed

+7
-19
lines changed

compiler/rustc_mir/src/borrow_check/type_check/mod.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,13 @@ pub(crate) fn type_check<'mir, 'tcx>(
182182
let mut opaque_type_values = cx.opaque_type_values;
183183

184184
for (_, revealed_ty) in &mut opaque_type_values {
185-
// FIXME(oli-obk): Instead of looping, implement a visitor like
186-
// FullTypeResolver. We can't use FullTypeResolver here, as that will
187-
// resolve lifetimes lexically, which it can't because we didn't do old
188-
// borrowck stuff. We want to use MIR borrowck information instead.
189-
190-
while revealed_ty.has_infer_types_or_consts() {
191-
let prev = *revealed_ty;
192-
trace!(prev=?prev.kind());
193-
let type_resolved = infcx.shallow_resolve(prev);
194-
trace!(type_resolved=?type_resolved.kind());
195-
if prev == type_resolved {
196-
infcx.tcx.sess.delay_span_bug(
197-
body.span,
198-
&format!("could not resolve {:#?}", type_resolved.kind()),
199-
);
200-
*revealed_ty = infcx.tcx.ty_error();
201-
break;
202-
}
203-
*revealed_ty = type_resolved;
185+
*revealed_ty = infcx.resolve_vars_if_possible(*revealed_ty);
186+
if revealed_ty.has_infer_types_or_consts() {
187+
infcx.tcx.sess.delay_span_bug(
188+
body.span,
189+
&format!("could not resolve {:#?}", revealed_ty.kind()),
190+
);
191+
*revealed_ty = infcx.tcx.ty_error();
204192
}
205193
}
206194

0 commit comments

Comments
 (0)