1
Fork 0

more LocalDefId in ty::context

This commit is contained in:
Bastian Kauschke 2020-06-27 13:15:12 +02:00
parent a4e7b47984
commit 1875c79772
3 changed files with 10 additions and 6 deletions

View file

@ -26,7 +26,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
);
let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?;
debug!("try_report_static_impl_trait: anon_reg_sup={:?}", anon_reg_sup);
let fn_returns = self.tcx().return_type_impl_or_dyn_traits(anon_reg_sup.def_id);
let fn_returns =
self.tcx().return_type_impl_or_dyn_traits(anon_reg_sup.def_id.expect_local());
if fn_returns.is_empty() {
return None;
}

View file

@ -1436,8 +1436,11 @@ impl<'tcx> TyCtxt<'tcx> {
}
/// Given a `DefId` for an `fn`, return all the `dyn` and `impl` traits in its return type.
pub fn return_type_impl_or_dyn_traits(&self, scope_def_id: DefId) -> Vec<&'tcx hir::Ty<'tcx>> {
let hir_id = self.hir().as_local_hir_id(scope_def_id.expect_local());
pub fn return_type_impl_or_dyn_traits(
&self,
scope_def_id: LocalDefId,
) -> Vec<&'tcx hir::Ty<'tcx>> {
let hir_id = self.hir().as_local_hir_id(scope_def_id);
let hir_output = match self.hir().get(hir_id) {
Node::Item(hir::Item {
kind:
@ -1480,9 +1483,9 @@ impl<'tcx> TyCtxt<'tcx> {
v.0
}
pub fn return_type_impl_trait(&self, scope_def_id: DefId) -> Option<(Ty<'tcx>, Span)> {
pub fn return_type_impl_trait(&self, scope_def_id: LocalDefId) -> Option<(Ty<'tcx>, Span)> {
// HACK: `type_of_def_id()` will fail on these (#55796), so return `None`.
let hir_id = self.hir().as_local_hir_id(scope_def_id.expect_local());
let hir_id = self.hir().as_local_hir_id(scope_def_id);
match self.hir().get(hir_id) {
Node::Item(item) => {
match item.kind {

View file

@ -583,7 +583,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
.infcx
.tcx
.is_suitable_region(f)
.map(|r| r.def_id)
.map(|r| r.def_id.expect_local())
.map(|id| self.infcx.tcx.return_type_impl_trait(id))
.unwrap_or(None)
{