Skip to content

Commit

Permalink
more LocalDefId in ty::context
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jun 27, 2020
1 parent a4e7b47 commit 1875c79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 1875c79

Please sign in to comment.