Skip to content

Commit 1875c79

Browse files
committed
more LocalDefId in ty::context
1 parent a4e7b47 commit 1875c79

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2626
);
2727
let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?;
2828
debug!("try_report_static_impl_trait: anon_reg_sup={:?}", anon_reg_sup);
29-
let fn_returns = self.tcx().return_type_impl_or_dyn_traits(anon_reg_sup.def_id);
29+
let fn_returns =
30+
self.tcx().return_type_impl_or_dyn_traits(anon_reg_sup.def_id.expect_local());
3031
if fn_returns.is_empty() {
3132
return None;
3233
}

src/librustc_middle/ty/context.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,11 @@ impl<'tcx> TyCtxt<'tcx> {
14361436
}
14371437

14381438
/// Given a `DefId` for an `fn`, return all the `dyn` and `impl` traits in its return type.
1439-
pub fn return_type_impl_or_dyn_traits(&self, scope_def_id: DefId) -> Vec<&'tcx hir::Ty<'tcx>> {
1440-
let hir_id = self.hir().as_local_hir_id(scope_def_id.expect_local());
1439+
pub fn return_type_impl_or_dyn_traits(
1440+
&self,
1441+
scope_def_id: LocalDefId,
1442+
) -> Vec<&'tcx hir::Ty<'tcx>> {
1443+
let hir_id = self.hir().as_local_hir_id(scope_def_id);
14411444
let hir_output = match self.hir().get(hir_id) {
14421445
Node::Item(hir::Item {
14431446
kind:
@@ -1480,9 +1483,9 @@ impl<'tcx> TyCtxt<'tcx> {
14801483
v.0
14811484
}
14821485

1483-
pub fn return_type_impl_trait(&self, scope_def_id: DefId) -> Option<(Ty<'tcx>, Span)> {
1486+
pub fn return_type_impl_trait(&self, scope_def_id: LocalDefId) -> Option<(Ty<'tcx>, Span)> {
14841487
// HACK: `type_of_def_id()` will fail on these (#55796), so return `None`.
1485-
let hir_id = self.hir().as_local_hir_id(scope_def_id.expect_local());
1488+
let hir_id = self.hir().as_local_hir_id(scope_def_id);
14861489
match self.hir().get(hir_id) {
14871490
Node::Item(item) => {
14881491
match item.kind {

src/librustc_mir/borrow_check/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
583583
.infcx
584584
.tcx
585585
.is_suitable_region(f)
586-
.map(|r| r.def_id)
586+
.map(|r| r.def_id.expect_local())
587587
.map(|id| self.infcx.tcx.return_type_impl_trait(id))
588588
.unwrap_or(None)
589589
{

0 commit comments

Comments
 (0)