mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 22:18:23 +03:00
more LocalDefId in ty::context
This commit is contained in:
@@ -26,7 +26,8 @@ pub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorReported> {
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1436,8 +1436,11 @@ pub fn is_suitable_region(&self, region: Region<'tcx>) -> Option<FreeRegionInfo>
|
||||
}
|
||||
|
||||
/// 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 @@ pub fn return_type_impl_or_dyn_traits(&self, scope_def_id: DefId) -> Vec<&'tcx h
|
||||
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 {
|
||||
|
||||
@@ -583,7 +583,7 @@ fn add_static_impl_trait_suggestion(
|
||||
.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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user