diff options
| author | Oli Scherer <github35764891676564198441@oli-obk.de> | 2021-07-20 15:10:55 +0000 |
|---|---|---|
| committer | Oli Scherer <github35764891676564198441@oli-obk.de> | 2021-07-22 11:20:29 +0000 |
| commit | 9f09a5eb8b9b59360528f24f0c73fdaf6bf3300a (patch) | |
| tree | 805ecd2455600ecc03487dacde012884b0e84a58 /compiler | |
| parent | a8551abd4787e6746d515a656b1e7ab00cf67d4a (diff) | |
| download | rust-9f09a5eb8b9b59360528f24f0c73fdaf6bf3300a.tar.gz rust-9f09a5eb8b9b59360528f24f0c73fdaf6bf3300a.zip | |
Resolve nested inference variables.
I attempted that with the previous code, but I misunderstdood how `shallow_resolve` works.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir/src/borrow_check/type_check/mod.rs | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index 03ffad4a814..3fb06cd2f5f 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -182,25 +182,13 @@ pub(crate) fn type_check<'mir, 'tcx>( let mut opaque_type_values = cx.opaque_type_values; for (_, revealed_ty) in &mut opaque_type_values { - // FIXME(oli-obk): Instead of looping, implement a visitor like - // FullTypeResolver. We can't use FullTypeResolver here, as that will - // resolve lifetimes lexically, which it can't because we didn't do old - // borrowck stuff. We want to use MIR borrowck information instead. - - while revealed_ty.has_infer_types_or_consts() { - let prev = *revealed_ty; - trace!(prev=?prev.kind()); - let type_resolved = infcx.shallow_resolve(prev); - trace!(type_resolved=?type_resolved.kind()); - if prev == type_resolved { - infcx.tcx.sess.delay_span_bug( - body.span, - &format!("could not resolve {:#?}", type_resolved.kind()), - ); - *revealed_ty = infcx.tcx.ty_error(); - break; - } - *revealed_ty = type_resolved; + *revealed_ty = infcx.resolve_vars_if_possible(*revealed_ty); + if revealed_ty.has_infer_types_or_consts() { + infcx.tcx.sess.delay_span_bug( + body.span, + &format!("could not resolve {:#?}", revealed_ty.kind()), + ); + *revealed_ty = infcx.tcx.ty_error(); } } |
