1
Fork 0

Rollup merge of #132106 - maxcabrajac:ident_ref, r=petrochenkov

Pass Ident by reference in ast Visitor

`MutVisitor`'s version of `visit_ident` passes around `&Ident`, but `Visitor` copies `Ident`. This PR changes that

r? `@petrochenkov`

related to #128974
This commit is contained in:
Matthias Krüger 2024-10-25 20:33:11 +02:00 committed by GitHub
commit 280790b9a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 41 additions and 41 deletions

View file

@ -1894,11 +1894,11 @@ impl EarlyLintPass for KeywordIdents {
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::MacCall) {
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('\'') {
self.check_ident_token(cx, UnderMacro(false), ident.without_first_quote(), "'");
} else {
self.check_ident_token(cx, UnderMacro(false), ident, "");
self.check_ident_token(cx, UnderMacro(false), *ident, "");
}
}
}

View file

@ -202,7 +202,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, 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);
}

View file

@ -133,7 +133,7 @@ macro_rules! early_lint_methods {
($macro:path, $args:tt) => (
$macro!($args, [
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_post(a: &rustc_ast::Crate);
fn check_item(a: &rustc_ast::Item);