Rollup merge of #141931 - ArtemIsmagilov:issue-141849_2, r=nnethercote
Deconstruct values in the THIR visitor I continue to add deconstruction for task rust-lang/rust#141849 The changes concern a more complex part of the task `compiler/rustc_hir/src/intravisit.rs` r? `@nnethercote`
This commit is contained in:
commit
757d0e70d6
1 changed files with 147 additions and 90 deletions
|
|
@ -527,13 +527,15 @@ pub trait VisitorExt<'v>: Visitor<'v> {
|
|||
impl<'v, V: Visitor<'v>> VisitorExt<'v> for V {}
|
||||
|
||||
pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(param.hir_id));
|
||||
visitor.visit_pat(param.pat)
|
||||
let Param { hir_id, pat, ty_span: _, span: _ } = param;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visitor.visit_pat(pat)
|
||||
}
|
||||
|
||||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::Result {
|
||||
let Item { owner_id: _, kind, span: _, vis_span: _ } = item;
|
||||
try_visit!(visitor.visit_id(item.hir_id()));
|
||||
match item.kind {
|
||||
match *kind {
|
||||
ItemKind::ExternCrate(orig_name, ident) => {
|
||||
visit_opt!(visitor, visit_name, orig_name);
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
|
|
@ -631,8 +633,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
|||
}
|
||||
|
||||
pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &Body<'v>) -> V::Result {
|
||||
walk_list!(visitor, visit_param, body.params);
|
||||
visitor.visit_expr(body.value)
|
||||
let Body { params, value } = body;
|
||||
walk_list!(visitor, visit_param, *params);
|
||||
visitor.visit_expr(*value)
|
||||
}
|
||||
|
||||
pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) -> V::Result {
|
||||
|
|
@ -640,7 +643,8 @@ pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) -> V::Resul
|
|||
}
|
||||
|
||||
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>) -> V::Result {
|
||||
walk_list!(visitor, visit_nested_item, module.item_ids.iter().copied());
|
||||
let Mod { spans: _, item_ids } = module;
|
||||
walk_list!(visitor, visit_nested_item, item_ids.iter().copied());
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
|
|
@ -648,10 +652,11 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
foreign_item: &'v ForeignItem<'v>,
|
||||
) -> V::Result {
|
||||
let ForeignItem { ident, kind, owner_id: _, span: _, vis_span: _ } = foreign_item;
|
||||
try_visit!(visitor.visit_id(foreign_item.hir_id()));
|
||||
try_visit!(visitor.visit_ident(foreign_item.ident));
|
||||
try_visit!(visitor.visit_ident(*ident));
|
||||
|
||||
match foreign_item.kind {
|
||||
match *kind {
|
||||
ForeignItemKind::Fn(ref sig, param_idents, ref generics) => {
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_fn_decl(sig.decl));
|
||||
|
|
@ -670,24 +675,27 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
|
|||
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v LetStmt<'v>) -> V::Result {
|
||||
// Intentionally visiting the expr first - the initialization expr
|
||||
// dominates the local's definition.
|
||||
visit_opt!(visitor, visit_expr, local.init);
|
||||
try_visit!(visitor.visit_id(local.hir_id));
|
||||
try_visit!(visitor.visit_pat(local.pat));
|
||||
visit_opt!(visitor, visit_block, local.els);
|
||||
visit_opt!(visitor, visit_ty_unambig, local.ty);
|
||||
let LetStmt { super_: _, pat, ty, init, els, hir_id, span: _, source: _ } = local;
|
||||
visit_opt!(visitor, visit_expr, *init);
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
try_visit!(visitor.visit_pat(*pat));
|
||||
visit_opt!(visitor, visit_block, *els);
|
||||
visit_opt!(visitor, visit_ty_unambig, *ty);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(block.hir_id));
|
||||
walk_list!(visitor, visit_stmt, block.stmts);
|
||||
visit_opt!(visitor, visit_expr, block.expr);
|
||||
let Block { stmts, expr, hir_id, rules: _, span: _, targeted_by_break: _ } = block;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
walk_list!(visitor, visit_stmt, *stmts);
|
||||
visit_opt!(visitor, visit_expr, *expr);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(statement.hir_id));
|
||||
match statement.kind {
|
||||
let Stmt { kind, hir_id, span: _ } = statement;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match *kind {
|
||||
StmtKind::Let(ref local) => visitor.visit_local(local),
|
||||
StmtKind::Item(item) => visitor.visit_nested_item(item),
|
||||
StmtKind::Expr(ref expression) | StmtKind::Semi(ref expression) => {
|
||||
|
|
@ -697,15 +705,17 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) -
|
|||
}
|
||||
|
||||
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(arm.hir_id));
|
||||
try_visit!(visitor.visit_pat(arm.pat));
|
||||
visit_opt!(visitor, visit_expr, arm.guard);
|
||||
visitor.visit_expr(arm.body)
|
||||
let Arm { hir_id, span: _, pat, guard, body } = arm;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
try_visit!(visitor.visit_pat(*pat));
|
||||
visit_opt!(visitor, visit_expr, *guard);
|
||||
visitor.visit_expr(*body)
|
||||
}
|
||||
|
||||
pub fn walk_ty_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v TyPat<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(pattern.hir_id));
|
||||
match pattern.kind {
|
||||
let TyPat { kind, hir_id, span: _ } = pattern;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match *kind {
|
||||
TyPatKind::Range(lower_bound, upper_bound) => {
|
||||
try_visit!(visitor.visit_const_arg_unambig(lower_bound));
|
||||
try_visit!(visitor.visit_const_arg_unambig(upper_bound));
|
||||
|
|
@ -717,14 +727,15 @@ pub fn walk_ty_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v TyPat<'v>)
|
|||
}
|
||||
|
||||
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(pattern.hir_id));
|
||||
match pattern.kind {
|
||||
let Pat { hir_id, kind, span, default_binding_modes: _ } = pattern;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match *kind {
|
||||
PatKind::TupleStruct(ref qpath, children, _) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
|
||||
try_visit!(visitor.visit_qpath(qpath, *hir_id, *span));
|
||||
walk_list!(visitor, visit_pat, children);
|
||||
}
|
||||
PatKind::Struct(ref qpath, fields, _) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
|
||||
try_visit!(visitor.visit_qpath(qpath, *hir_id, *span));
|
||||
walk_list!(visitor, visit_pat_field, fields);
|
||||
}
|
||||
PatKind::Or(pats) => walk_list!(visitor, visit_pat, pats),
|
||||
|
|
@ -760,36 +771,41 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V:
|
|||
}
|
||||
|
||||
pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(field.hir_id));
|
||||
try_visit!(visitor.visit_ident(field.ident));
|
||||
visitor.visit_pat(field.pat)
|
||||
let PatField { hir_id, ident, pat, is_shorthand: _, span: _ } = field;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
try_visit!(visitor.visit_ident(*ident));
|
||||
visitor.visit_pat(*pat)
|
||||
}
|
||||
|
||||
pub fn walk_pat_expr<'v, V: Visitor<'v>>(visitor: &mut V, expr: &'v PatExpr<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(expr.hir_id));
|
||||
match &expr.kind {
|
||||
PatExprKind::Lit { lit, negated } => visitor.visit_lit(expr.hir_id, lit, *negated),
|
||||
let PatExpr { hir_id, span, kind } = expr;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match kind {
|
||||
PatExprKind::Lit { lit, negated } => visitor.visit_lit(*hir_id, lit, *negated),
|
||||
PatExprKind::ConstBlock(c) => visitor.visit_inline_const(c),
|
||||
PatExprKind::Path(qpath) => visitor.visit_qpath(qpath, expr.hir_id, expr.span),
|
||||
PatExprKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, *span),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonConst) -> V::Result {
|
||||
try_visit!(visitor.visit_id(constant.hir_id));
|
||||
visitor.visit_nested_body(constant.body)
|
||||
let AnonConst { hir_id, def_id: _, body, span: _ } = constant;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visitor.visit_nested_body(*body)
|
||||
}
|
||||
|
||||
pub fn walk_inline_const<'v, V: Visitor<'v>>(
|
||||
visitor: &mut V,
|
||||
constant: &'v ConstBlock,
|
||||
) -> V::Result {
|
||||
try_visit!(visitor.visit_id(constant.hir_id));
|
||||
visitor.visit_nested_body(constant.body)
|
||||
let ConstBlock { hir_id, def_id: _, body } = constant;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visitor.visit_nested_body(*body)
|
||||
}
|
||||
|
||||
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(expression.hir_id));
|
||||
match expression.kind {
|
||||
let Expr { hir_id, kind, span } = expression;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match *kind {
|
||||
ExprKind::Array(subexpressions) => {
|
||||
walk_list!(visitor, visit_expr, subexpressions);
|
||||
}
|
||||
|
|
@ -801,7 +817,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
try_visit!(visitor.visit_const_arg_unambig(count));
|
||||
}
|
||||
ExprKind::Struct(ref qpath, fields, ref optional_base) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, expression.hir_id, expression.span));
|
||||
try_visit!(visitor.visit_qpath(qpath, *hir_id, *span));
|
||||
walk_list!(visitor, visit_expr_field, fields);
|
||||
match optional_base {
|
||||
StructTailExpr::Base(base) => try_visit!(visitor.visit_expr(base)),
|
||||
|
|
@ -869,7 +885,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
constness: _,
|
||||
}) => {
|
||||
walk_list!(visitor, visit_generic_param, bound_generic_params);
|
||||
try_visit!(visitor.visit_fn(FnKind::Closure, fn_decl, body, expression.span, def_id));
|
||||
try_visit!(visitor.visit_fn(FnKind::Closure, fn_decl, body, *span, def_id));
|
||||
}
|
||||
ExprKind::Block(ref block, ref opt_label) => {
|
||||
visit_opt!(visitor, visit_label, opt_label);
|
||||
|
|
@ -892,7 +908,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
try_visit!(visitor.visit_expr(index_expression));
|
||||
}
|
||||
ExprKind::Path(ref qpath) => {
|
||||
try_visit!(visitor.visit_qpath(qpath, expression.hir_id, expression.span));
|
||||
try_visit!(visitor.visit_qpath(qpath, *hir_id, *span));
|
||||
}
|
||||
ExprKind::Break(ref destination, ref opt_expr) => {
|
||||
visit_opt!(visitor, visit_label, &destination.label);
|
||||
|
|
@ -906,7 +922,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
}
|
||||
ExprKind::Become(ref expr) => try_visit!(visitor.visit_expr(expr)),
|
||||
ExprKind::InlineAsm(ref asm) => {
|
||||
try_visit!(visitor.visit_inline_asm(asm, expression.hir_id));
|
||||
try_visit!(visitor.visit_inline_asm(asm, *hir_id));
|
||||
}
|
||||
ExprKind::OffsetOf(ref container, ref fields) => {
|
||||
try_visit!(visitor.visit_ty_unambig(container));
|
||||
|
|
@ -919,16 +935,17 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
try_visit!(visitor.visit_expr(expr));
|
||||
visit_opt!(visitor, visit_ty_unambig, ty);
|
||||
}
|
||||
ExprKind::Lit(lit) => try_visit!(visitor.visit_lit(expression.hir_id, lit, false)),
|
||||
ExprKind::Lit(lit) => try_visit!(visitor.visit_lit(*hir_id, lit, false)),
|
||||
ExprKind::Err(_) => {}
|
||||
}
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(field.hir_id));
|
||||
try_visit!(visitor.visit_ident(field.ident));
|
||||
visitor.visit_expr(field.expr)
|
||||
let ExprField { hir_id, ident, expr, span: _, is_shorthand: _ } = field;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
try_visit!(visitor.visit_ident(*ident));
|
||||
visitor.visit_expr(*expr)
|
||||
}
|
||||
/// We track whether an infer var is from a [`Ty`], [`ConstArg`], or [`GenericArg`] so that
|
||||
/// HIR visitors overriding [`Visitor::visit_infer`] can determine what kind of infer is being visited
|
||||
|
|
@ -946,7 +963,10 @@ pub fn walk_generic_arg<'v, V: Visitor<'v>>(
|
|||
GenericArg::Lifetime(lt) => visitor.visit_lifetime(lt),
|
||||
GenericArg::Type(ty) => visitor.visit_ty(ty),
|
||||
GenericArg::Const(ct) => visitor.visit_const_arg(ct),
|
||||
GenericArg::Infer(inf) => visitor.visit_infer(inf.hir_id, inf.span, InferKind::Ambig(inf)),
|
||||
GenericArg::Infer(inf) => {
|
||||
let InferArg { hir_id, span } = inf;
|
||||
visitor.visit_infer(*hir_id, *span, InferKind::Ambig(inf))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -954,16 +974,18 @@ pub fn walk_unambig_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) ->
|
|||
match typ.try_as_ambig_ty() {
|
||||
Some(ambig_ty) => visitor.visit_ty(ambig_ty),
|
||||
None => {
|
||||
try_visit!(visitor.visit_id(typ.hir_id));
|
||||
visitor.visit_infer(typ.hir_id, typ.span, InferKind::Ty(typ))
|
||||
let Ty { hir_id, span, kind: _ } = typ;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visitor.visit_infer(*hir_id, *span, InferKind::Ty(typ))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -> V::Result {
|
||||
try_visit!(visitor.visit_id(typ.hir_id));
|
||||
let Ty { hir_id, span: _, kind } = typ;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
|
||||
match typ.kind {
|
||||
match *kind {
|
||||
TyKind::Slice(ref ty) => try_visit!(visitor.visit_ty_unambig(ty)),
|
||||
TyKind::Ptr(ref mutable_type) => try_visit!(visitor.visit_ty_unambig(mutable_type.ty)),
|
||||
TyKind::Ref(ref lifetime, ref mutable_type) => {
|
||||
|
|
@ -1018,8 +1040,9 @@ pub fn walk_const_arg<'v, V: Visitor<'v>>(
|
|||
match const_arg.try_as_ambig_ct() {
|
||||
Some(ambig_ct) => visitor.visit_const_arg(ambig_ct),
|
||||
None => {
|
||||
try_visit!(visitor.visit_id(const_arg.hir_id));
|
||||
visitor.visit_infer(const_arg.hir_id, const_arg.span(), InferKind::Const(const_arg))
|
||||
let ConstArg { hir_id, kind: _ } = const_arg;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visitor.visit_infer(*hir_id, const_arg.span(), InferKind::Const(const_arg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1028,9 +1051,10 @@ pub fn walk_ambig_const_arg<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
const_arg: &'v ConstArg<'v, AmbigArg>,
|
||||
) -> V::Result {
|
||||
try_visit!(visitor.visit_id(const_arg.hir_id));
|
||||
match &const_arg.kind {
|
||||
ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, const_arg.hir_id, qpath.span()),
|
||||
let ConstArg { hir_id, kind } = const_arg;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match kind {
|
||||
ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, qpath.span()),
|
||||
ConstArgKind::Anon(anon) => visitor.visit_anon_const(*anon),
|
||||
}
|
||||
}
|
||||
|
|
@ -1039,12 +1063,22 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
param: &'v GenericParam<'v>,
|
||||
) -> V::Result {
|
||||
try_visit!(visitor.visit_id(param.hir_id));
|
||||
match param.name {
|
||||
let GenericParam {
|
||||
hir_id,
|
||||
def_id: _,
|
||||
name,
|
||||
span: _,
|
||||
pure_wrt_drop: _,
|
||||
kind,
|
||||
colon_span: _,
|
||||
source: _,
|
||||
} = param;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
match *name {
|
||||
ParamName::Plain(ident) | ParamName::Error(ident) => try_visit!(visitor.visit_ident(ident)),
|
||||
ParamName::Fresh => {}
|
||||
}
|
||||
match param.kind {
|
||||
match *kind {
|
||||
GenericParamKind::Lifetime { .. } => {}
|
||||
GenericParamKind::Type { ref default, .. } => {
|
||||
visit_opt!(visitor, visit_ty_unambig, default)
|
||||
|
|
@ -1052,7 +1086,7 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(
|
|||
GenericParamKind::Const { ref ty, ref default, synthetic: _ } => {
|
||||
try_visit!(visitor.visit_ty_unambig(ty));
|
||||
if let Some(default) = default {
|
||||
try_visit!(visitor.visit_const_param_default(param.hir_id, default));
|
||||
try_visit!(visitor.visit_const_param_default(*hir_id, default));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1067,8 +1101,15 @@ pub fn walk_const_param_default<'v, V: Visitor<'v>>(
|
|||
}
|
||||
|
||||
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) -> V::Result {
|
||||
walk_list!(visitor, visit_generic_param, generics.params);
|
||||
walk_list!(visitor, visit_where_predicate, generics.predicates);
|
||||
let &Generics {
|
||||
params,
|
||||
predicates,
|
||||
has_where_clause_predicates: _,
|
||||
where_clause_span: _,
|
||||
span: _,
|
||||
} = generics;
|
||||
walk_list!(visitor, visit_generic_param, params);
|
||||
walk_list!(visitor, visit_where_predicate, predicates);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
|
|
@ -1109,8 +1150,10 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
function_declaration: &'v FnDecl<'v>,
|
||||
) -> V::Result {
|
||||
walk_list!(visitor, visit_ty_unambig, function_declaration.inputs);
|
||||
visitor.visit_fn_ret_ty(&function_declaration.output)
|
||||
let FnDecl { inputs, output, c_variadic: _, implicit_self: _, lifetime_elision_allowed: _ } =
|
||||
function_declaration;
|
||||
walk_list!(visitor, visit_ty_unambig, *inputs);
|
||||
visitor.visit_fn_ret_ty(output)
|
||||
}
|
||||
|
||||
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) -> V::Result {
|
||||
|
|
@ -1264,8 +1307,9 @@ pub fn walk_trait_ref<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
trait_ref: &'v TraitRef<'v>,
|
||||
) -> V::Result {
|
||||
try_visit!(visitor.visit_id(trait_ref.hir_ref_id));
|
||||
visitor.visit_path(trait_ref.path, trait_ref.hir_ref_id)
|
||||
let TraitRef { hir_ref_id, path } = trait_ref;
|
||||
try_visit!(visitor.visit_id(*hir_ref_id));
|
||||
visitor.visit_path(*path, *hir_ref_id)
|
||||
}
|
||||
|
||||
pub fn walk_param_bound<'v, V: Visitor<'v>>(
|
||||
|
|
@ -1288,7 +1332,10 @@ pub fn walk_precise_capturing_arg<'v, V: Visitor<'v>>(
|
|||
) -> V::Result {
|
||||
match *arg {
|
||||
PreciseCapturingArg::Lifetime(lt) => visitor.visit_lifetime(lt),
|
||||
PreciseCapturingArg::Param(param) => visitor.visit_id(param.hir_id),
|
||||
PreciseCapturingArg::Param(param) => {
|
||||
let PreciseCapturingNonLifetimeArg { hir_id, ident: _, res: _ } = param;
|
||||
visitor.visit_id(hir_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1296,8 +1343,9 @@ pub fn walk_poly_trait_ref<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
trait_ref: &'v PolyTraitRef<'v>,
|
||||
) -> V::Result {
|
||||
walk_list!(visitor, visit_generic_param, trait_ref.bound_generic_params);
|
||||
visitor.visit_trait_ref(&trait_ref.trait_ref)
|
||||
let PolyTraitRef { bound_generic_params, modifiers: _, trait_ref, span: _ } = trait_ref;
|
||||
walk_list!(visitor, visit_generic_param, *bound_generic_params);
|
||||
visitor.visit_trait_ref(trait_ref)
|
||||
}
|
||||
|
||||
pub fn walk_opaque_ty<'v, V: Visitor<'v>>(visitor: &mut V, opaque: &'v OpaqueTy<'v>) -> V::Result {
|
||||
|
|
@ -1330,29 +1378,34 @@ pub fn walk_enum_def<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
enum_definition: &'v EnumDef<'v>,
|
||||
) -> V::Result {
|
||||
walk_list!(visitor, visit_variant, enum_definition.variants);
|
||||
let EnumDef { variants } = enum_definition;
|
||||
walk_list!(visitor, visit_variant, *variants);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, variant: &'v Variant<'v>) -> V::Result {
|
||||
try_visit!(visitor.visit_ident(variant.ident));
|
||||
try_visit!(visitor.visit_id(variant.hir_id));
|
||||
try_visit!(visitor.visit_variant_data(&variant.data));
|
||||
visit_opt!(visitor, visit_anon_const, &variant.disr_expr);
|
||||
let Variant { ident, hir_id, def_id: _, data, disr_expr, span: _ } = variant;
|
||||
try_visit!(visitor.visit_ident(*ident));
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
try_visit!(visitor.visit_variant_data(data));
|
||||
visit_opt!(visitor, visit_anon_const, disr_expr);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
pub fn walk_label<'v, V: Visitor<'v>>(visitor: &mut V, label: &'v Label) -> V::Result {
|
||||
visitor.visit_ident(label.ident)
|
||||
let Label { ident } = label;
|
||||
visitor.visit_ident(*ident)
|
||||
}
|
||||
|
||||
pub fn walk_inf<'v, V: Visitor<'v>>(visitor: &mut V, inf: &'v InferArg) -> V::Result {
|
||||
visitor.visit_id(inf.hir_id)
|
||||
let InferArg { hir_id, span: _ } = inf;
|
||||
visitor.visit_id(*hir_id)
|
||||
}
|
||||
|
||||
pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime) -> V::Result {
|
||||
try_visit!(visitor.visit_id(lifetime.hir_id));
|
||||
visitor.visit_ident(lifetime.ident)
|
||||
let Lifetime { hir_id, ident, kind: _, source: _, syntax: _ } = lifetime;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visitor.visit_ident(*ident)
|
||||
}
|
||||
|
||||
pub fn walk_qpath<'v, V: Visitor<'v>>(
|
||||
|
|
@ -1374,7 +1427,8 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(
|
|||
}
|
||||
|
||||
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &Path<'v>) -> V::Result {
|
||||
walk_list!(visitor, visit_path_segment, path.segments);
|
||||
let Path { segments, span: _, res: _ } = path;
|
||||
walk_list!(visitor, visit_path_segment, *segments);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
|
|
@ -1382,9 +1436,10 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
segment: &'v PathSegment<'v>,
|
||||
) -> V::Result {
|
||||
try_visit!(visitor.visit_ident(segment.ident));
|
||||
try_visit!(visitor.visit_id(segment.hir_id));
|
||||
visit_opt!(visitor, visit_generic_args, segment.args);
|
||||
let PathSegment { ident, hir_id, res: _, args, infer_args: _ } = segment;
|
||||
try_visit!(visitor.visit_ident(*ident));
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
visit_opt!(visitor, visit_generic_args, *args);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
|
|
@ -1392,8 +1447,9 @@ pub fn walk_generic_args<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
generic_args: &'v GenericArgs<'v>,
|
||||
) -> V::Result {
|
||||
walk_list!(visitor, visit_generic_arg, generic_args.args);
|
||||
walk_list!(visitor, visit_assoc_item_constraint, generic_args.constraints);
|
||||
let GenericArgs { args, constraints, parenthesized: _, span_ext: _ } = generic_args;
|
||||
walk_list!(visitor, visit_generic_arg, *args);
|
||||
walk_list!(visitor, visit_assoc_item_constraint, *constraints);
|
||||
V::Result::output()
|
||||
}
|
||||
|
||||
|
|
@ -1401,9 +1457,10 @@ pub fn walk_assoc_item_constraint<'v, V: Visitor<'v>>(
|
|||
visitor: &mut V,
|
||||
constraint: &'v AssocItemConstraint<'v>,
|
||||
) -> V::Result {
|
||||
try_visit!(visitor.visit_id(constraint.hir_id));
|
||||
try_visit!(visitor.visit_ident(constraint.ident));
|
||||
try_visit!(visitor.visit_generic_args(constraint.gen_args));
|
||||
let AssocItemConstraint { hir_id, ident, gen_args, kind: _, span: _ } = constraint;
|
||||
try_visit!(visitor.visit_id(*hir_id));
|
||||
try_visit!(visitor.visit_ident(*ident));
|
||||
try_visit!(visitor.visit_generic_args(*gen_args));
|
||||
match constraint.kind {
|
||||
AssocItemConstraintKind::Equality { ref term } => match term {
|
||||
Term::Ty(ty) => try_visit!(visitor.visit_ty_unambig(ty)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue