Skip to content

Commit 6f16b45

Browse files
committed
Immutable visitor
1 parent 6295686 commit 6f16b45

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

compiler/rustc_ast/src/visit.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl BoundKind {
6666
#[derive(Copy, Clone, Debug)]
6767
pub enum FnKind<'a> {
6868
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
69-
Fn(FnCtxt, Ident, &'a FnSig, &'a Visibility, &'a Generics, Option<&'a Block>),
69+
Fn(FnCtxt, &'a Ident, &'a FnSig, &'a Visibility, &'a Generics, &'a Option<P<Block>>),
7070

7171
/// E.g., `|x, y| body`.
7272
Closure(&'a ClosureBinder, &'a Option<CoroutineKind>, &'a FnDecl, &'a Expr),
@@ -357,7 +357,7 @@ impl WalkItemKind for ItemKind {
357357
visit_opt!(visitor, visit_expr, expr);
358358
}
359359
ItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
360-
let kind = FnKind::Fn(FnCtxt::Free, *ident, sig, vis, generics, body.as_deref());
360+
let kind = FnKind::Fn(FnCtxt::Free, ident, sig, vis, generics, body);
361361
try_visit!(visitor.visit_fn(kind, *span, *id));
362362
}
363363
ItemKind::Mod(_unsafety, mod_kind) => match mod_kind {
@@ -687,15 +687,15 @@ impl WalkItemKind for ForeignItemKind {
687687
_ctxt: AssocCtxt,
688688
visitor: &mut V,
689689
) -> V::Result {
690-
let &Item { id, span, ident, ref vis, .. } = item;
690+
let Item { id, span, ident, vis, .. } = item;
691691
match self {
692692
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
693693
try_visit!(visitor.visit_ty(ty));
694694
visit_opt!(visitor, visit_expr, expr);
695695
}
696696
ForeignItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
697-
let kind = FnKind::Fn(FnCtxt::Foreign, ident, sig, vis, generics, body.as_deref());
698-
try_visit!(visitor.visit_fn(kind, span, id));
697+
let kind = FnKind::Fn(FnCtxt::Foreign, ident, sig, vis, generics, body);
698+
try_visit!(visitor.visit_fn(kind, *span, *id));
699699
}
700700
ForeignItemKind::TyAlias(box TyAlias {
701701
generics,
@@ -850,7 +850,7 @@ impl WalkItemKind for AssocItemKind {
850850
ctxt: AssocCtxt,
851851
visitor: &mut V,
852852
) -> V::Result {
853-
let &Item { id, span, ident, ref vis, .. } = item;
853+
let Item { id, span, ident, vis, .. } = item;
854854
match self {
855855
AssocItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => {
856856
try_visit!(visitor.visit_generics(generics));
@@ -859,8 +859,8 @@ impl WalkItemKind for AssocItemKind {
859859
}
860860
AssocItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
861861
let kind =
862-
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref());
863-
try_visit!(visitor.visit_fn(kind, span, id));
862+
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body);
863+
try_visit!(visitor.visit_fn(kind, *span, *id));
864864
}
865865
AssocItemKind::Type(box TyAlias {
866866
generics,
@@ -891,7 +891,7 @@ impl WalkItemKind for AssocItemKind {
891891
}
892892
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
893893
try_visit!(walk_qself(visitor, qself));
894-
try_visit!(visitor.visit_path(prefix, id));
894+
try_visit!(visitor.visit_path(prefix, *id));
895895
if let Some(suffixes) = suffixes {
896896
for (ident, rename) in suffixes {
897897
visitor.visit_ident(ident);

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
947947
self.visit_vis(&item.vis);
948948
self.visit_ident(&item.ident);
949949
let kind =
950-
FnKind::Fn(FnCtxt::Free, item.ident, sig, &item.vis, generics, body.as_deref());
950+
FnKind::Fn(FnCtxt::Free, &item.ident, sig, &item.vis, generics, body);
951951
self.visit_fn(kind, item.span, item.id);
952952
walk_list!(self, visit_attribute, &item.attrs);
953953
return; // Avoid visiting again.
@@ -1478,11 +1478,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14781478
self.visit_ident(&item.ident);
14791479
let kind = FnKind::Fn(
14801480
FnCtxt::Assoc(ctxt),
1481-
item.ident,
1481+
&item.ident,
14821482
sig,
14831483
&item.vis,
14841484
generics,
1485-
body.as_deref(),
1485+
body,
14861486
);
14871487
walk_list!(self, visit_attribute, &item.attrs);
14881488
self.visit_fn(kind, item.span, item.id);

0 commit comments

Comments
 (0)