more LocalDefId in ty::context
This commit is contained in:
parent
a4e7b47984
commit
1875c79772
3 changed files with 10 additions and 6 deletions
|
@ -26,7 +26,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?;
|
let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?;
|
||||||
debug!("try_report_static_impl_trait: anon_reg_sup={:?}", anon_reg_sup);
|
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() {
|
if fn_returns.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
/// 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>> {
|
pub fn return_type_impl_or_dyn_traits(
|
||||||
let hir_id = self.hir().as_local_hir_id(scope_def_id.expect_local());
|
&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) {
|
let hir_output = match self.hir().get(hir_id) {
|
||||||
Node::Item(hir::Item {
|
Node::Item(hir::Item {
|
||||||
kind:
|
kind:
|
||||||
|
@ -1480,9 +1483,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
v.0
|
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`.
|
// 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) {
|
match self.hir().get(hir_id) {
|
||||||
Node::Item(item) => {
|
Node::Item(item) => {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
|
|
|
@ -583,7 +583,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
.infcx
|
.infcx
|
||||||
.tcx
|
.tcx
|
||||||
.is_suitable_region(f)
|
.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))
|
.map(|id| self.infcx.tcx.return_type_impl_trait(id))
|
||||||
.unwrap_or(None)
|
.unwrap_or(None)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue