diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-01-28 19:50:48 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-01-29 10:02:03 +0100 |
| commit | 7a6f68c87275fc1be2b0c3aa1455bead5c9dce18 (patch) | |
| tree | d2e62b37b92cf39e34c9658b1df8302be85dd7ab /src | |
| parent | dd3fa07a522cb4f059a96f5e8d82f8d82c33d238 (diff) | |
Make error reporting work on generator upvars. Fixes #47793, #47805
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/error_reporting.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 7bd3b6e39f0..7fadc4b36e4 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -746,12 +746,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { self.describe_field_from_ty(&tnm.ty, field) } ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field), - ty::TyClosure(closure_def_id, _) => { + ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => { // Convert the def-id into a node-id. node-ids are only valid for // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't // be borrowck'ing it, so we can just unwrap: - let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap(); + let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let freevar = self.tcx.with_freevars(node_id, |fv| fv[field.index()]); self.tcx.hir.name(freevar.var_id()).to_string() |
