Remap impl-trait lifetimes on HIR instead of AST lowering.
This commit is contained in:
parent
298c7462c3
commit
b6e1214ac0
35 changed files with 508 additions and 597 deletions
|
@ -284,7 +284,7 @@ pub fn suggest_new_region_bound(
|
|||
}
|
||||
match fn_return.kind {
|
||||
// FIXME(precise_captures): Suggest adding to `use<...>` list instead.
|
||||
TyKind::OpaqueDef(opaque, _) => {
|
||||
TyKind::OpaqueDef(opaque) => {
|
||||
// Get the identity type for this RPIT
|
||||
let did = opaque.def_id.to_def_id();
|
||||
let ty = Ty::new_opaque(tcx, did, ty::GenericArgs::identity_for_item(tcx, did));
|
||||
|
|
|
@ -862,22 +862,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
self.add_lt_suggs.push(lt.suggestion(self.new_lt));
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'hir hir::Ty<'hir>) {
|
||||
let hir::TyKind::OpaqueDef(opaque_ty, _) = ty.kind else {
|
||||
return hir::intravisit::walk_ty(self, ty);
|
||||
};
|
||||
if let Some(&(_, b)) =
|
||||
opaque_ty.lifetime_mapping.iter().find(|&(a, _)| a.res == self.needle)
|
||||
{
|
||||
let prev_needle =
|
||||
std::mem::replace(&mut self.needle, hir::LifetimeName::Param(b));
|
||||
for bound in opaque_ty.bounds {
|
||||
self.visit_param_bound(bound);
|
||||
}
|
||||
self.needle = prev_needle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let (lifetime_def_id, lifetime_scope) =
|
||||
|
|
|
@ -361,7 +361,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
})
|
||||
| hir::Node::TraitItem(hir::TraitItem { generics, .. })
|
||||
| hir::Node::ImplItem(hir::ImplItem { generics, .. })
|
||||
| hir::Node::OpaqueTy(hir::OpaqueTy { generics, .. })
|
||||
if param_ty =>
|
||||
{
|
||||
// We skip the 0'th arg (self) because we do not want
|
||||
|
@ -424,10 +423,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
| hir::ItemKind::Const(_, generics, _)
|
||||
| hir::ItemKind::TraitAlias(generics, _),
|
||||
..
|
||||
})
|
||||
| hir::Node::OpaqueTy(hir::OpaqueTy { generics, .. })
|
||||
if !param_ty =>
|
||||
{
|
||||
}) if !param_ty => {
|
||||
// Missing generic type parameter bound.
|
||||
if suggest_arbitrary_trait_bound(
|
||||
self.tcx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue