Lower and resolve precise captures in HIR

This commit is contained in:
Michael Goulet 2024-04-04 10:48:47 -04:00
parent c897092654
commit 41cf87b71b
8 changed files with 108 additions and 46 deletions

View file

@ -557,6 +557,31 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
}
}
fn visit_precise_capturing_arg(
&mut self,
arg: &'tcx hir::PreciseCapturingArg<'tcx>,
) -> Self::Result {
match *arg {
hir::PreciseCapturingArg::Lifetime(lt) => match lt.res {
LifetimeName::Param(def_id) => {
self.resolve_lifetime_ref(def_id, lt);
}
LifetimeName::Error => {}
LifetimeName::ImplicitObjectLifetimeDefault
| LifetimeName::Infer
| LifetimeName::Static => todo!("TODO: Error on invalid lifetime"),
},
hir::PreciseCapturingArg::Param(res, hir_id) => match res {
Res::Def(DefKind::TyParam | DefKind::ConstParam, def_id)
| Res::SelfTyParam { trait_: def_id } => {
self.resolve_type_ref(def_id.expect_local(), hir_id);
}
Res::Err => {}
_ => todo!("TODO: Error on invalid param res"),
},
}
}
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
match item.kind {
hir::ForeignItemKind::Fn(_, _, generics) => {