Rollup merge of #114301 - compiler-errors:dont-error-on-missing-region-outlives, r=spastorino
Don't check unnecessarily that impl trait is RPIT We have this random `return_type_impl_trait` function to detect if a function returns an RPIT which is used in outlives suggestions, but removing it doesn't actually change any diagnostics. Let's just remove it. Also, suppress a spurious outlives error from a ReError. Fixes #114274
This commit is contained in:
commit
f338a1f7ee
6 changed files with 46 additions and 35 deletions
|
@ -50,9 +50,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
|||
use rustc_hir::definitions::Definitions;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{
|
||||
Constness, ExprKind, HirId, ImplItemKind, ItemKind, Node, TraitCandidate, TraitItemKind,
|
||||
};
|
||||
use rustc_hir::{Constness, HirId, Node, TraitCandidate};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_query_system::dep_graph::DepNodeIndex;
|
||||
|
@ -1077,31 +1075,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
return None;
|
||||
}
|
||||
|
||||
pub fn return_type_impl_trait(self, scope_def_id: LocalDefId) -> Option<(Ty<'tcx>, Span)> {
|
||||
// `type_of()` will fail on these (#55796, #86483), so only allow `fn`s or closures.
|
||||
match self.hir().get_by_def_id(scope_def_id) {
|
||||
Node::Item(&hir::Item { kind: ItemKind::Fn(..), .. }) => {}
|
||||
Node::TraitItem(&hir::TraitItem { kind: TraitItemKind::Fn(..), .. }) => {}
|
||||
Node::ImplItem(&hir::ImplItem { kind: ImplItemKind::Fn(..), .. }) => {}
|
||||
Node::Expr(&hir::Expr { kind: ExprKind::Closure { .. }, .. }) => {}
|
||||
_ => return None,
|
||||
}
|
||||
|
||||
let ret_ty = self.type_of(scope_def_id).instantiate_identity();
|
||||
match ret_ty.kind() {
|
||||
ty::FnDef(_, _) => {
|
||||
let sig = ret_ty.fn_sig(self);
|
||||
let output = self.erase_late_bound_regions(sig.output());
|
||||
output.is_impl_trait().then(|| {
|
||||
let hir_id = self.hir().local_def_id_to_hir_id(scope_def_id);
|
||||
let fn_decl = self.hir().fn_decl_by_hir_id(hir_id).unwrap();
|
||||
(output, fn_decl.output.span())
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the bound region is in Impl Item.
|
||||
pub fn is_bound_region_in_impl_item(self, suitable_region_binding_scope: LocalDefId) -> bool {
|
||||
let container_id = self.parent(suitable_region_binding_scope.to_def_id());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue