diff options
| author | Mark Mansi <markm@cs.wisc.edu> | 2020-01-24 12:13:45 -0600 |
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2020-02-22 13:11:15 -0600 |
| commit | 245062cdcd9907bd7f71822f958219dc8ce994d2 (patch) | |
| tree | 84d5f9a5cb37498c891fd9894c1288c9e2cbf3c5 | |
| parent | 4d22e757cd97d1a69ed8ddda7d346355ce466255 (diff) | |
| download | rust-245062cdcd9907bd7f71822f958219dc8ce994d2.tar.gz rust-245062cdcd9907bd7f71822f958219dc8ce994d2.zip | |
some fixes
| -rw-r--r-- | src/librustc/ty/context.rs | 11 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs | 13 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/diagnostics/region_errors.rs | 2 |
3 files changed, 6 insertions, 20 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fd2f58d24f8..07c7ccfd16d 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1518,13 +1518,10 @@ impl<'tcx> TyCtxt<'tcx> { &self, def_id: crate::hir::def_id::DefId, ) -> (&'static str, &'static str) { - self.def_kind(def_id).map_or_else( - || { - // TODO: is it a problem to try to use the ty here? - self.type_of(def_id).kind.article_and_description() - }, - |def_kind| (def_kind.article(), def_kind.descr(def_id)), - ) + match self.def_kind(def_id) { + Some(def_kind) => (def_kind.article(), def_kind.descr(def_id)), + None => self.type_of(def_id).kind.article_and_description(), + } } } diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 41a99d1125b..83669a53eb4 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -1275,18 +1275,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ) -> DiagnosticBuilder<'cx> { let tcx = self.infcx.tcx; - let escapes_from = if tcx.is_closure(self.mir_def_id) { - let tables = tcx.typeck_tables_of(self.mir_def_id); - let mir_hir_id = tcx.hir().def_index_to_hir_id(self.mir_def_id.index); - match tables.node_type(mir_hir_id).kind { - ref kind @ ty::Closure(..) | ref kind @ ty::Generator(..) => { - kind.article_and_description().1 - } - _ => bug!("Closure body doesn't have a closure or generator type"), - } - } else { - "function" - }; + let (_, escapes_from) = tcx.article_and_description(self.mir_def_id); let mut err = borrowck_errors::borrowed_data_escapes_closure(tcx, escape_span, escapes_from); diff --git a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs index 0f0fd64844a..f4089b26860 100644 --- a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs @@ -435,7 +435,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if (fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none()) || (*category == ConstraintCategory::Assignment && self.universal_regions.defining_ty.is_fn_def()) - || self.universal_regions.defining_ty.is_closure() + || self.universal_regions.defining_ty.is_const() { return self.report_general_error(&ErrorConstraintInfo { fr_is_local: true, |
