about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-01-28 20:43:16 +0100
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-01-28 20:43:16 +0100
commit832751fe1df232e36b283fa136b4e26475e55c00 (patch)
tree2f4c799c8298bd01be6c026d90e5fd110197cc34 /compiler
parent7919ef0ec5776c72dace7fec1c68551a617505ad (diff)
downloadrust-832751fe1df232e36b283fa136b4e26475e55c00.tar.gz
rust-832751fe1df232e36b283fa136b4e26475e55c00.zip
Also erase substs for new infcx in pin move error
The code originally correctly erased the regions of the type it passed
to the newly created infcx. But after the `fn_sig` query was made to
return an `EarlyBinder<T>`, some substs that were around were
substituted there without erasing their regions. They were then passed
into the newly cerated infcx, which caused the ICE.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs
index 1011794d7b3..8c579bac7e8 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mod.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs
@@ -1128,8 +1128,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                                 "{place_name} {partially_str}moved due to this method call{loop_message}",
                             ),
                         );
+
                         let infcx = tcx.infer_ctxt().build();
+                        // Erase and shadow everything that could be passed to the new infcx.
                         let ty = tcx.erase_regions(moved_place.ty(self.body, tcx).ty);
+                        let method_substs = tcx.erase_regions(method_substs);
+
                         if let ty::Adt(def, substs) = ty.kind()
                             && Some(def.did()) == tcx.lang_items().pin_type()
                             && let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()