Lower and resolve precise captures in HIR
This commit is contained in:
parent
c897092654
commit
41cf87b71b
8 changed files with 108 additions and 46 deletions
|
@ -63,7 +63,7 @@ impl fmt::Debug for Label {
|
|||
|
||||
/// A "Lifetime" is an annotation of the scope in which variable
|
||||
/// can be used, e.g. `'a` in `&'a i32`.
|
||||
#[derive(Clone, Encodable, Decodable, Copy, PartialEq, Eq)]
|
||||
#[derive(Clone, Encodable, Decodable, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct Lifetime {
|
||||
pub id: NodeId,
|
||||
pub ident: Ident,
|
||||
|
|
|
@ -259,10 +259,6 @@ pub trait MutVisitor: Sized {
|
|||
noop_visit_param_bound(tpb, self);
|
||||
}
|
||||
|
||||
fn visit_precise_capturing_args(&mut self, args: &mut ThinVec<PreciseCapturingArg>) {
|
||||
noop_visit_precise_capturing_args(args, self);
|
||||
}
|
||||
|
||||
fn visit_precise_capturing_arg(&mut self, arg: &mut PreciseCapturingArg) {
|
||||
noop_visit_precise_capturing_arg(arg, self);
|
||||
}
|
||||
|
@ -530,7 +526,9 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
|
|||
vis.visit_id(id);
|
||||
visit_vec(bounds, |bound| vis.visit_param_bound(bound));
|
||||
visit_opt(precise_capturing, |precise_capturing| {
|
||||
vis.visit_precise_capturing_args(precise_capturing);
|
||||
for arg in precise_capturing {
|
||||
vis.visit_precise_capturing_arg(arg);
|
||||
}
|
||||
});
|
||||
}
|
||||
TyKind::MacCall(mac) => vis.visit_mac_call(mac),
|
||||
|
@ -925,15 +923,6 @@ pub fn noop_visit_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T)
|
|||
}
|
||||
}
|
||||
|
||||
pub fn noop_visit_precise_capturing_args<T: MutVisitor>(
|
||||
args: &mut ThinVec<PreciseCapturingArg>,
|
||||
vis: &mut T,
|
||||
) {
|
||||
for arg in args {
|
||||
vis.visit_precise_capturing_arg(arg);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg, vis: &mut T) {
|
||||
match arg {
|
||||
PreciseCapturingArg::Lifetime(lt) => {
|
||||
|
|
|
@ -20,7 +20,6 @@ use rustc_span::Span;
|
|||
|
||||
pub use rustc_ast_ir::visit::VisitorResult;
|
||||
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum AssocCtxt {
|
||||
|
@ -185,9 +184,6 @@ pub trait Visitor<'ast>: Sized {
|
|||
fn visit_param_bound(&mut self, bounds: &'ast GenericBound, _ctxt: BoundKind) -> Self::Result {
|
||||
walk_param_bound(self, bounds)
|
||||
}
|
||||
fn visit_precise_capturing_args(&mut self, args: &'ast ThinVec<PreciseCapturingArg>) {
|
||||
walk_precise_capturing_args(self, args);
|
||||
}
|
||||
fn visit_precise_capturing_arg(&mut self, arg: &'ast PreciseCapturingArg) {
|
||||
walk_precise_capturing_arg(self, arg);
|
||||
}
|
||||
|
@ -466,7 +462,11 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) -> V::Result {
|
|||
}
|
||||
TyKind::ImplTrait(_, bounds, precise_capturing) => {
|
||||
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Impl);
|
||||
visit_opt!(visitor, visit_precise_capturing_args, precise_capturing);
|
||||
if let Some(precise_capturing) = precise_capturing {
|
||||
for arg in precise_capturing {
|
||||
try_visit!(visitor.visit_precise_capturing_arg(arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
TyKind::Typeof(expression) => try_visit!(visitor.visit_anon_const(expression)),
|
||||
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Err(_) => {}
|
||||
|
@ -645,15 +645,6 @@ pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericB
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_precise_capturing_args<'a, V: Visitor<'a>>(
|
||||
visitor: &mut V,
|
||||
args: &'a ThinVec<PreciseCapturingArg>,
|
||||
) {
|
||||
for arg in args {
|
||||
visitor.visit_precise_capturing_arg(arg);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_precise_capturing_arg<'a, V: Visitor<'a>>(
|
||||
visitor: &mut V,
|
||||
arg: &'a PreciseCapturingArg,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue