Skip to content

Commit 7a6f68c

Browse files
committed
Make error reporting work on generator upvars. Fixes #47793, #47805
1 parent dd3fa07 commit 7a6f68c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
746746
self.describe_field_from_ty(&tnm.ty, field)
747747
}
748748
ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field),
749-
ty::TyClosure(closure_def_id, _) => {
749+
ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => {
750750
// Convert the def-id into a node-id. node-ids are only valid for
751751
// the local code in the current crate, so this returns an `Option` in case
752752
// the closure comes from another crate. But in that case we wouldn't
753753
// be borrowck'ing it, so we can just unwrap:
754-
let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap();
754+
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
755755
let freevar = self.tcx.with_freevars(node_id, |fv| fv[field.index()]);
756756

757757
self.tcx.hir.name(freevar.var_id()).to_string()

0 commit comments

Comments
 (0)