some fixes
This commit is contained in:
parent
4d22e757cd
commit
245062cdcd
3 changed files with 6 additions and 20 deletions
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue