Skip to content

Allow visits from both visitor and VisitorMut at the same time without using trait disambiguation - #2389

Open
docteurklein wants to merge 1 commit into
apache:mainfrom
docteurklein:visit-and-visit_mut
Open

Allow visits from both visitor and VisitorMut at the same time without using trait disambiguation#2389
docteurklein wants to merge 1 commit into
apache:mainfrom
docteurklein:visit-and-visit_mut

Conversation

@docteurklein

Copy link
Copy Markdown

Closes #2067 .

Hello! I just now realize that I could have used overlapping trait Disambiguation:

let _ = Visit::visit(&statements, &mut whitelist);
let _ = VisitMut::visit(&mut statements, &mut VisitOrderBy(order));

But here I am with this proposition anyway.

@LucaCappelletti94 LucaCappelletti94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a maintainer, just fellow contributor.

Consider rebasing on main, so the branch is up to speed. It is current some 20+ commits behind.

Comment thread src/ast/visitor.rs
#[cfg(test)]
mod visit_mut_tests {
use crate::ast::{Ident, Statement, Value, ValueWithSpan, VisitMut, VisitorMut};
use crate::ast::{Ident, Statement, Value, ValueWithSpan, Visit, VisitMut, Visitor, VisitorMut};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just eyeballing, but I would wager you need to run a cargo fmt --all -- --check.

Comment thread src/ast/visitor.rs
}

struct DummyVisitor;
impl Visitor for DummyVisitor {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you have the dummy visitor do something, like count nodes

Comment thread src/ast/visitor.rs
}

struct DummyVisitorMut;
impl VisitorMut for DummyVisitorMut {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the dummy visitor mut to edit the nodes it visits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename VisitorMut::visit to VisitorMut::visit_mut

2 participants