-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update intravisit docs #93815
Update intravisit docs #93815
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @camsteffen! Just a few nits.
compiler/rustc_hir/src/intravisit.rs
Outdated
/// fix it appropriately. | ||
/// `visit_nested_XXX` methods. If a new `visit_nested_XXX` variant is | ||
/// added in the future, we will see the panic in your code (from | ||
/// `nested_visit_map`) and fix it appropriately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is you
and who is we
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the question is rhetorical but...
you="well-meaning rustc contributer with much to learn" and we="the experts who keep the wheels turning"
compiler/rustc_hir/src/intravisit.rs
Outdated
/// `nested_visit_map` or use the "shallow" or "deep" visit | ||
/// Invoked when a nested item is encountered. By default does nothing | ||
/// unless you override `Self::NestedFilter` to a type other than | ||
/// `nested_filter::None`, in which case it will walk the item. **You |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say: "By default, when Self::NestedFilter
is nested_filter::None
, this method does nothing.
compiler/rustc_hir/src/intravisit.rs
Outdated
/// `nested_visit_map` to return other than `None`, in which case it will walk | ||
/// the body. | ||
/// `visit_nested_item`, does nothing by default unless you override | ||
/// `Self::NestedFilter` to a type other than `None`, in which case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// `Self::NestedFilter` to a type other than `None`, in which case | |
/// `Self::NestedFilter`. |
and stop the doc here. The description on visit_nested_item
should be enough.
/// - How: Implement `intravisit::Visitor` and override the `nested_visit_map()` method | ||
/// to return `NestedVisitorMap::OnlyBodies` and use | ||
/// - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to | ||
/// `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use | ||
/// `tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor())`. Within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// `tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor())`. Within | |
/// `tcx.hir().visit_all_item_likes(&mut visitor.as_deep_visitor())`. Within |
Addressed nits. Will squash if all is well. |
/// invoked on `tcx.hir().krate()`. | ||
/// - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to | ||
/// `nested_filter::All` (and implement `nested_visit_map`). Walk your crate with | ||
/// `intravisit::walk_crate()` invoked on `tcx.hir().krate()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
walk_crate
does not exist any more. The user should call tcx.hir().walk_toplevel_module(visitor)
.
Thanks! r=me with one nit + squashed. |
☔ The latest upstream changes (presumably #93921) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage: Can you please post the status of this PR? |
90e9d75
to
61ba32b
Compare
This should be ready now but, since some time has passed, I'll let @cjgillot review once more in case anything has changed. |
@rustbot ready |
@bors r+ |
📌 Commit 61ba32b has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (2c858a7): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Follow-up to #90986.
r? @cjgillot