Pass Ident by reference in ast Visitor
This commit is contained in:
parent
5ae4d75eff
commit
64a3451835
@ -135,7 +135,7 @@ pub trait Visitor<'ast>: Sized {
|
|||||||
/// or `ControlFlow<T>`.
|
/// or `ControlFlow<T>`.
|
||||||
type Result: VisitorResult = ();
|
type Result: VisitorResult = ();
|
||||||
|
|
||||||
fn visit_ident(&mut self, _ident: Ident) -> Self::Result {
|
fn visit_ident(&mut self, _ident: &'ast Ident) -> Self::Result {
|
||||||
Self::Result::output()
|
Self::Result::output()
|
||||||
}
|
}
|
||||||
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) -> Self::Result {
|
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) -> Self::Result {
|
||||||
@ -317,12 +317,12 @@ pub fn walk_local<'a, V: Visitor<'a>>(visitor: &mut V, local: &'a Local) -> V::R
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_label<'a, V: Visitor<'a>>(visitor: &mut V, Label { ident }: &'a Label) -> V::Result {
|
pub fn walk_label<'a, V: Visitor<'a>>(visitor: &mut V, Label { ident }: &'a Label) -> V::Result {
|
||||||
visitor.visit_ident(*ident)
|
visitor.visit_ident(ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_lifetime<'a, V: Visitor<'a>>(visitor: &mut V, lifetime: &'a Lifetime) -> V::Result {
|
pub fn walk_lifetime<'a, V: Visitor<'a>>(visitor: &mut V, lifetime: &'a Lifetime) -> V::Result {
|
||||||
let Lifetime { id: _, ident } = lifetime;
|
let Lifetime { id: _, ident } = lifetime;
|
||||||
visitor.visit_ident(*ident)
|
visitor.visit_ident(ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_poly_trait_ref<'a, V>(visitor: &mut V, trait_ref: &'a PolyTraitRef) -> V::Result
|
pub fn walk_poly_trait_ref<'a, V>(visitor: &mut V, trait_ref: &'a PolyTraitRef) -> V::Result
|
||||||
@ -429,7 +429,7 @@ fn walk<'a, V: Visitor<'a>>(
|
|||||||
}) => {
|
}) => {
|
||||||
try_visit!(walk_qself(visitor, qself));
|
try_visit!(walk_qself(visitor, qself));
|
||||||
try_visit!(visitor.visit_path(path, *id));
|
try_visit!(visitor.visit_path(path, *id));
|
||||||
visit_opt!(visitor, visit_ident, *rename);
|
visit_opt!(visitor, visit_ident, rename);
|
||||||
visit_opt!(visitor, visit_block, body);
|
visit_opt!(visitor, visit_block, body);
|
||||||
}
|
}
|
||||||
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
|
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
|
||||||
@ -437,9 +437,9 @@ fn walk<'a, V: Visitor<'a>>(
|
|||||||
try_visit!(visitor.visit_path(prefix, *id));
|
try_visit!(visitor.visit_path(prefix, *id));
|
||||||
if let Some(suffixes) = suffixes {
|
if let Some(suffixes) = suffixes {
|
||||||
for (ident, rename) in suffixes {
|
for (ident, rename) in suffixes {
|
||||||
visitor.visit_ident(*ident);
|
visitor.visit_ident(ident);
|
||||||
if let Some(rename) = rename {
|
if let Some(rename) = rename {
|
||||||
visitor.visit_ident(*rename);
|
visitor.visit_ident(rename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,7 +472,7 @@ pub fn walk_variant<'a, V: Visitor<'a>>(visitor: &mut V, variant: &'a Variant) -
|
|||||||
let Variant { attrs, id: _, span: _, vis, ident, data, disr_expr, is_placeholder: _ } = variant;
|
let Variant { attrs, id: _, span: _, vis, ident, data, disr_expr, is_placeholder: _ } = variant;
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
try_visit!(visitor.visit_vis(vis));
|
try_visit!(visitor.visit_vis(vis));
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
try_visit!(visitor.visit_variant_data(data));
|
try_visit!(visitor.visit_variant_data(data));
|
||||||
visit_opt!(visitor, visit_variant_discr, disr_expr);
|
visit_opt!(visitor, visit_variant_discr, disr_expr);
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
@ -481,7 +481,7 @@ pub fn walk_variant<'a, V: Visitor<'a>>(visitor: &mut V, variant: &'a Variant) -
|
|||||||
pub fn walk_expr_field<'a, V: Visitor<'a>>(visitor: &mut V, f: &'a ExprField) -> V::Result {
|
pub fn walk_expr_field<'a, V: Visitor<'a>>(visitor: &mut V, f: &'a ExprField) -> V::Result {
|
||||||
let ExprField { attrs, id: _, span: _, ident, expr, is_shorthand: _, is_placeholder: _ } = f;
|
let ExprField { attrs, id: _, span: _, ident, expr, is_shorthand: _, is_placeholder: _ } = f;
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
try_visit!(visitor.visit_expr(expr));
|
try_visit!(visitor.visit_expr(expr));
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ pub fn walk_expr_field<'a, V: Visitor<'a>>(visitor: &mut V, f: &'a ExprField) ->
|
|||||||
pub fn walk_pat_field<'a, V: Visitor<'a>>(visitor: &mut V, fp: &'a PatField) -> V::Result {
|
pub fn walk_pat_field<'a, V: Visitor<'a>>(visitor: &mut V, fp: &'a PatField) -> V::Result {
|
||||||
let PatField { ident, pat, is_shorthand: _, attrs, id: _, span: _, is_placeholder: _ } = fp;
|
let PatField { ident, pat, is_shorthand: _, attrs, id: _, span: _, is_placeholder: _ } = fp;
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
try_visit!(visitor.visit_pat(pat));
|
try_visit!(visitor.visit_pat(pat));
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>(
|
|||||||
match kind {
|
match kind {
|
||||||
UseTreeKind::Simple(rename) => {
|
UseTreeKind::Simple(rename) => {
|
||||||
// The extra IDs are handled during AST lowering.
|
// The extra IDs are handled during AST lowering.
|
||||||
visit_opt!(visitor, visit_ident, *rename);
|
visit_opt!(visitor, visit_ident, rename);
|
||||||
}
|
}
|
||||||
UseTreeKind::Glob => {}
|
UseTreeKind::Glob => {}
|
||||||
UseTreeKind::Nested { ref items, span: _ } => {
|
UseTreeKind::Nested { ref items, span: _ } => {
|
||||||
@ -581,7 +581,7 @@ pub fn walk_path_segment<'a, V: Visitor<'a>>(
|
|||||||
segment: &'a PathSegment,
|
segment: &'a PathSegment,
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
let PathSegment { ident, id: _, args } = segment;
|
let PathSegment { ident, id: _, args } = segment;
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
visit_opt!(visitor, visit_generic_args, args);
|
visit_opt!(visitor, visit_generic_args, args);
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
@ -627,7 +627,7 @@ pub fn walk_assoc_item_constraint<'a, V: Visitor<'a>>(
|
|||||||
constraint: &'a AssocItemConstraint,
|
constraint: &'a AssocItemConstraint,
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
let AssocItemConstraint { id: _, ident, gen_args, kind, span: _ } = constraint;
|
let AssocItemConstraint { id: _, ident, gen_args, kind, span: _ } = constraint;
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
visit_opt!(visitor, visit_generic_args, gen_args);
|
visit_opt!(visitor, visit_generic_args, gen_args);
|
||||||
match kind {
|
match kind {
|
||||||
AssocItemConstraintKind::Equality { term } => match term {
|
AssocItemConstraintKind::Equality { term } => match term {
|
||||||
@ -665,7 +665,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
|
|||||||
try_visit!(visitor.visit_pat(subpattern));
|
try_visit!(visitor.visit_pat(subpattern));
|
||||||
}
|
}
|
||||||
PatKind::Ident(_bmode, ident, optional_subpattern) => {
|
PatKind::Ident(_bmode, ident, optional_subpattern) => {
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
visit_opt!(visitor, visit_pat, optional_subpattern);
|
visit_opt!(visitor, visit_pat, optional_subpattern);
|
||||||
}
|
}
|
||||||
PatKind::Lit(expression) => try_visit!(visitor.visit_expr(expression)),
|
PatKind::Lit(expression) => try_visit!(visitor.visit_expr(expression)),
|
||||||
@ -751,7 +751,7 @@ pub fn walk_generic_param<'a, V: Visitor<'a>>(
|
|||||||
let GenericParam { id: _, ident, attrs, bounds, is_placeholder: _, kind, colon_span: _ } =
|
let GenericParam { id: _, ident, attrs, bounds, is_placeholder: _, kind, colon_span: _ } =
|
||||||
param;
|
param;
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
|
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
|
||||||
match kind {
|
match kind {
|
||||||
GenericParamKind::Lifetime => (),
|
GenericParamKind::Lifetime => (),
|
||||||
@ -889,7 +889,7 @@ fn walk<'a, V: Visitor<'a>>(
|
|||||||
}) => {
|
}) => {
|
||||||
try_visit!(walk_qself(visitor, qself));
|
try_visit!(walk_qself(visitor, qself));
|
||||||
try_visit!(visitor.visit_path(path, *id));
|
try_visit!(visitor.visit_path(path, *id));
|
||||||
visit_opt!(visitor, visit_ident, *rename);
|
visit_opt!(visitor, visit_ident, rename);
|
||||||
visit_opt!(visitor, visit_block, body);
|
visit_opt!(visitor, visit_block, body);
|
||||||
}
|
}
|
||||||
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
|
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
|
||||||
@ -897,9 +897,9 @@ fn walk<'a, V: Visitor<'a>>(
|
|||||||
try_visit!(visitor.visit_path(prefix, id));
|
try_visit!(visitor.visit_path(prefix, id));
|
||||||
if let Some(suffixes) = suffixes {
|
if let Some(suffixes) = suffixes {
|
||||||
for (ident, rename) in suffixes {
|
for (ident, rename) in suffixes {
|
||||||
visitor.visit_ident(*ident);
|
visitor.visit_ident(ident);
|
||||||
if let Some(rename) = rename {
|
if let Some(rename) = rename {
|
||||||
visitor.visit_ident(*rename);
|
visitor.visit_ident(rename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -915,7 +915,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(
|
|||||||
item: &'a Item<impl WalkItemKind>,
|
item: &'a Item<impl WalkItemKind>,
|
||||||
ctxt: AssocCtxt,
|
ctxt: AssocCtxt,
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
|
let Item { id: _, span: _, ident, vis, attrs, kind, tokens: _ } = item;
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
try_visit!(visitor.visit_vis(vis));
|
try_visit!(visitor.visit_vis(vis));
|
||||||
try_visit!(visitor.visit_ident(ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
@ -935,7 +935,7 @@ pub fn walk_field_def<'a, V: Visitor<'a>>(visitor: &mut V, field: &'a FieldDef)
|
|||||||
let FieldDef { attrs, id: _, span: _, vis, ident, ty, is_placeholder: _ } = field;
|
let FieldDef { attrs, id: _, span: _, vis, ident, ty, is_placeholder: _ } = field;
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
try_visit!(visitor.visit_vis(vis));
|
try_visit!(visitor.visit_vis(vis));
|
||||||
visit_opt!(visitor, visit_ident, *ident);
|
visit_opt!(visitor, visit_ident, ident);
|
||||||
try_visit!(visitor.visit_ty(ty));
|
try_visit!(visitor.visit_ty(ty));
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
@ -1017,7 +1017,7 @@ pub fn walk_format_args<'a, V: Visitor<'a>>(visitor: &mut V, fmt: &'a FormatArgs
|
|||||||
for FormatArgument { kind, expr } in arguments.all_args() {
|
for FormatArgument { kind, expr } in arguments.all_args() {
|
||||||
match kind {
|
match kind {
|
||||||
FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
|
FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
|
||||||
try_visit!(visitor.visit_ident(*ident))
|
try_visit!(visitor.visit_ident(ident))
|
||||||
}
|
}
|
||||||
FormatArgumentKind::Normal => {}
|
FormatArgumentKind::Normal => {}
|
||||||
}
|
}
|
||||||
@ -1137,7 +1137,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
|
|||||||
}
|
}
|
||||||
ExprKind::Field(subexpression, ident) => {
|
ExprKind::Field(subexpression, ident) => {
|
||||||
try_visit!(visitor.visit_expr(subexpression));
|
try_visit!(visitor.visit_expr(subexpression));
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(ident));
|
||||||
}
|
}
|
||||||
ExprKind::Index(main_expression, index_expression, _span) => {
|
ExprKind::Index(main_expression, index_expression, _span) => {
|
||||||
try_visit!(visitor.visit_expr(main_expression));
|
try_visit!(visitor.visit_expr(main_expression));
|
||||||
@ -1172,7 +1172,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
|
|||||||
ExprKind::FormatArgs(f) => try_visit!(visitor.visit_format_args(f)),
|
ExprKind::FormatArgs(f) => try_visit!(visitor.visit_format_args(f)),
|
||||||
ExprKind::OffsetOf(container, fields) => {
|
ExprKind::OffsetOf(container, fields) => {
|
||||||
try_visit!(visitor.visit_ty(container));
|
try_visit!(visitor.visit_ty(container));
|
||||||
walk_list!(visitor, visit_ident, fields.iter().copied());
|
walk_list!(visitor, visit_ident, fields.iter());
|
||||||
}
|
}
|
||||||
ExprKind::Yield(optional_expression) => {
|
ExprKind::Yield(optional_expression) => {
|
||||||
visit_opt!(visitor, visit_expr, optional_expression);
|
visit_opt!(visitor, visit_expr, optional_expression);
|
||||||
|
@ -249,7 +249,7 @@ fn walk_ty(&mut self, t: &'a Ty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
|
fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
|
||||||
if let Some(ident) = field.ident
|
if let Some(ref ident) = field.ident
|
||||||
&& ident.name == kw::Underscore
|
&& ident.name == kw::Underscore
|
||||||
{
|
{
|
||||||
self.visit_vis(&field.vis);
|
self.visit_vis(&field.vis);
|
||||||
@ -899,7 +899,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.visit_vis(&item.vis);
|
this.visit_vis(&item.vis);
|
||||||
this.visit_ident(item.ident);
|
this.visit_ident(&item.ident);
|
||||||
let disallowed = matches!(constness, Const::No)
|
let disallowed = matches!(constness, Const::No)
|
||||||
.then(|| TildeConstReason::TraitImpl { span: item.span });
|
.then(|| TildeConstReason::TraitImpl { span: item.span });
|
||||||
this.with_tilde_const(disallowed, |this| this.visit_generics(generics));
|
this.with_tilde_const(disallowed, |this| this.visit_generics(generics));
|
||||||
@ -953,7 +953,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.visit_vis(&item.vis);
|
this.visit_vis(&item.vis);
|
||||||
this.visit_ident(item.ident);
|
this.visit_ident(&item.ident);
|
||||||
this.with_tilde_const(
|
this.with_tilde_const(
|
||||||
Some(TildeConstReason::Impl { span: item.span }),
|
Some(TildeConstReason::Impl { span: item.span }),
|
||||||
|this| this.visit_generics(generics),
|
|this| this.visit_generics(generics),
|
||||||
@ -991,7 +991,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(&item.ident);
|
||||||
let kind =
|
let kind =
|
||||||
FnKind::Fn(FnCtxt::Free, item.ident, sig, &item.vis, generics, body.as_deref());
|
FnKind::Fn(FnCtxt::Free, item.ident, sig, &item.vis, generics, body.as_deref());
|
||||||
self.visit_fn(kind, item.span, item.id);
|
self.visit_fn(kind, item.span, item.id);
|
||||||
@ -1058,7 +1058,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
// Equivalent of `visit::walk_item` for `ItemKind::Trait` that inserts a bound
|
// Equivalent of `visit::walk_item` for `ItemKind::Trait` that inserts a bound
|
||||||
// context for the supertraits.
|
// context for the supertraits.
|
||||||
this.visit_vis(&item.vis);
|
this.visit_vis(&item.vis);
|
||||||
this.visit_ident(item.ident);
|
this.visit_ident(&item.ident);
|
||||||
let disallowed = is_const_trait
|
let disallowed = is_const_trait
|
||||||
.is_none()
|
.is_none()
|
||||||
.then(|| TildeConstReason::Trait { span: item.span });
|
.then(|| TildeConstReason::Trait { span: item.span });
|
||||||
@ -1085,7 +1085,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
ItemKind::Struct(vdata, generics) => match vdata {
|
ItemKind::Struct(vdata, generics) => match vdata {
|
||||||
VariantData::Struct { fields, .. } => {
|
VariantData::Struct { fields, .. } => {
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(&item.ident);
|
||||||
self.visit_generics(generics);
|
self.visit_generics(generics);
|
||||||
// Permit `Anon{Struct,Union}` as field type.
|
// Permit `Anon{Struct,Union}` as field type.
|
||||||
walk_list!(self, visit_struct_field_def, fields);
|
walk_list!(self, visit_struct_field_def, fields);
|
||||||
@ -1101,7 +1101,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
match vdata {
|
match vdata {
|
||||||
VariantData::Struct { fields, .. } => {
|
VariantData::Struct { fields, .. } => {
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(&item.ident);
|
||||||
self.visit_generics(generics);
|
self.visit_generics(generics);
|
||||||
// Permit `Anon{Struct,Union}` as field type.
|
// Permit `Anon{Struct,Union}` as field type.
|
||||||
walk_list!(self, visit_struct_field_def, fields);
|
walk_list!(self, visit_struct_field_def, fields);
|
||||||
@ -1521,7 +1521,7 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
|
|||||||
|| matches!(sig.header.constness, Const::Yes(_)) =>
|
|| matches!(sig.header.constness, Const::Yes(_)) =>
|
||||||
{
|
{
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(&item.ident);
|
||||||
let kind = FnKind::Fn(
|
let kind = FnKind::Fn(
|
||||||
FnCtxt::Assoc(ctxt),
|
FnCtxt::Assoc(ctxt),
|
||||||
item.ident,
|
item.ident,
|
||||||
|
@ -16,7 +16,7 @@ pub fn new() -> NodeCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'ast> Visitor<'ast> for NodeCounter {
|
impl<'ast> Visitor<'ast> for NodeCounter {
|
||||||
fn visit_ident(&mut self, _ident: Ident) {
|
fn visit_ident(&mut self, _ident: &Ident) {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
}
|
}
|
||||||
fn visit_foreign_item(&mut self, i: &ForeignItem) {
|
fn visit_foreign_item(&mut self, i: &ForeignItem) {
|
||||||
|
@ -222,7 +222,7 @@ fn visit_attribute(&mut self, attr: &'a rustc_ast::Attribute) {
|
|||||||
rustc_ast::visit::walk_attribute(self, attr);
|
rustc_ast::visit::walk_attribute(self, attr);
|
||||||
}
|
}
|
||||||
fn visit_variant(&mut self, v: &'a rustc_ast::Variant) {
|
fn visit_variant(&mut self, v: &'a rustc_ast::Variant) {
|
||||||
self.visit_ident(v.ident);
|
self.visit_ident(&v.ident);
|
||||||
self.visit_vis(&v.vis);
|
self.visit_vis(&v.vis);
|
||||||
self.visit_variant_data(&v.data);
|
self.visit_variant_data(&v.data);
|
||||||
visit_opt!(self, visit_anon_const, &v.disr_expr);
|
visit_opt!(self, visit_anon_const, &v.disr_expr);
|
||||||
|
@ -1892,11 +1892,11 @@ fn check_mac_def(&mut self, cx: &EarlyContext<'_>, mac_def: &ast::MacroDef) {
|
|||||||
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::MacCall) {
|
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::MacCall) {
|
||||||
self.check_tokens(cx, &mac.args.tokens);
|
self.check_tokens(cx, &mac.args.tokens);
|
||||||
}
|
}
|
||||||
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) {
|
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: &Ident) {
|
||||||
if ident.name.as_str().starts_with('\'') {
|
if ident.name.as_str().starts_with('\'') {
|
||||||
self.check_ident_token(cx, UnderMacro(false), ident.without_first_quote(), "'");
|
self.check_ident_token(cx, UnderMacro(false), ident.without_first_quote(), "'");
|
||||||
} else {
|
} else {
|
||||||
self.check_ident_token(cx, UnderMacro(false), ident, "");
|
self.check_ident_token(cx, UnderMacro(false), *ident, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ fn visit_ty(&mut self, t: &'a ast::Ty) {
|
|||||||
ast_visit::walk_ty(self, t);
|
ast_visit::walk_ty(self, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ident(&mut self, ident: Ident) {
|
fn visit_ident(&mut self, ident: &Ident) {
|
||||||
lint_callback!(self, check_ident, ident);
|
lint_callback!(self, check_ident, ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ macro_rules! early_lint_methods {
|
|||||||
($macro:path, $args:tt) => (
|
($macro:path, $args:tt) => (
|
||||||
$macro!($args, [
|
$macro!($args, [
|
||||||
fn check_param(a: &rustc_ast::Param);
|
fn check_param(a: &rustc_ast::Param);
|
||||||
fn check_ident(a: rustc_span::symbol::Ident);
|
fn check_ident(a: &rustc_span::symbol::Ident);
|
||||||
fn check_crate(a: &rustc_ast::Crate);
|
fn check_crate(a: &rustc_ast::Crate);
|
||||||
fn check_crate_post(a: &rustc_ast::Crate);
|
fn check_crate_post(a: &rustc_ast::Crate);
|
||||||
fn check_item(a: &rustc_ast::Item);
|
fn check_item(a: &rustc_ast::Item);
|
||||||
|
@ -1321,7 +1321,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
|||||||
// Visit attributes after items for backward compatibility.
|
// Visit attributes after items for backward compatibility.
|
||||||
// This way they can use `macro_rules` defined later.
|
// This way they can use `macro_rules` defined later.
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(&item.ident);
|
||||||
item.kind.walk(item, AssocCtxt::Trait, self);
|
item.kind.walk(item, AssocCtxt::Trait, self);
|
||||||
visit::walk_list!(self, visit_attribute, &item.attrs);
|
visit::walk_list!(self, visit_attribute, &item.attrs);
|
||||||
}
|
}
|
||||||
|
@ -1205,7 +1205,7 @@ fn visit_generic_arg(&mut self, arg: &'ast GenericArg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_assoc_item_constraint(&mut self, constraint: &'ast AssocItemConstraint) {
|
fn visit_assoc_item_constraint(&mut self, constraint: &'ast AssocItemConstraint) {
|
||||||
self.visit_ident(constraint.ident);
|
self.visit_ident(&constraint.ident);
|
||||||
if let Some(ref gen_args) = constraint.gen_args {
|
if let Some(ref gen_args) = constraint.gen_args {
|
||||||
// Forbid anonymous lifetimes in GAT parameters until proper semantics are decided.
|
// Forbid anonymous lifetimes in GAT parameters until proper semantics are decided.
|
||||||
self.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| {
|
self.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| {
|
||||||
@ -4582,7 +4582,7 @@ fn resolve_anon_const_manual(
|
|||||||
|
|
||||||
fn resolve_expr_field(&mut self, f: &'ast ExprField, e: &'ast Expr) {
|
fn resolve_expr_field(&mut self, f: &'ast ExprField, e: &'ast Expr) {
|
||||||
self.resolve_expr(&f.expr, Some(e));
|
self.resolve_expr(&f.expr, Some(e));
|
||||||
self.visit_ident(f.ident);
|
self.visit_ident(&f.ident);
|
||||||
walk_list!(self, visit_attribute, f.attrs.iter());
|
walk_list!(self, visit_attribute, f.attrs.iter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ fn from(attr: &Attribute) -> Self {
|
|||||||
struct IdentCollector(Vec<Ident>);
|
struct IdentCollector(Vec<Ident>);
|
||||||
|
|
||||||
impl Visitor<'_> for IdentCollector {
|
impl Visitor<'_> for IdentCollector {
|
||||||
fn visit_ident(&mut self, ident: Ident) {
|
fn visit_ident(&mut self, ident: &Ident) {
|
||||||
self.0.push(ident);
|
self.0.push(*ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user