-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add walk_generic_arg
#103692
Add walk_generic_arg
#103692
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
pub fn walk_generic_arg<'v, V: Visitor<'v>>(visitor: &mut V, generic_arg: &'v GenericArg<'v>) { | ||
match generic_arg { | ||
GenericArg::Lifetime(lt) => visitor.visit_lifetime(lt), | ||
GenericArg::Type(ty) => visitor.visit_ty(ty), | ||
GenericArg::Const(ct) => visitor.visit_anon_const(&ct.value), | ||
GenericArg::Infer(inf) => visitor.visit_infer(inf), | ||
} | ||
} | ||
|
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.
This should probably be after walk_inf
instead of here.
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 would be happy to make that change.
But here are the visit_
methods in the order they appear in intravisit.rs
:
visit_ methods
nested_item nested_trait_item nested_impl_item nested_foreign_item nested_body param item body id name ident mod foreign_item local block stmt arm pat pat_field array_length anon_const expr let_expr expr_field ty generic_param const_param_default generics where_predicate fn_decl fn use trait_item trait_item_ref impl_item foreign_item_ref impl_item_ref trait_ref param_bound poly_trait_ref variant_data field_def enum_def variant label infer generic_arg lifetime qpath path path_segment generic_args assoc_type_binding attribute associated_item_kind defaultness inline_asm
And here are the walk_
functions in the order they appear in intravisit.rs
:
walk_ functions
mod body local ident label generic_arg lifetime poly_trait_ref trait_ref param item inline_asm use enum_def variant ty inf qpath path path_segment generic_args assoc_type_binding pat pat_field foreign_item param_bound generic_param const_param_default generics where_predicate fn_ret_ty fn_decl fn_kind fn trait_item trait_item_ref impl_item foreign_item_ref impl_item_ref struct_def field_def block stmt array_len anon_const let_expr expr_field expr arm associated_item_kind defaultness
Would it be better if I reordered the walk_
functions to match the order of the visit_
functions?
Yeah, that would be desirable. But that seems okay as a followup. @bors r+ rollup |
Rollup of 10 pull requests Successful merges: - rust-lang#103007 (Add better python discovery) - rust-lang#103674 (Update note about unstable split-debuginfo flag.) - rust-lang#103692 (Add `walk_generic_arg`) - rust-lang#103749 (Reduce span of let else irrefutable_let_patterns warning) - rust-lang#103772 (better error for `rustc_strict_coherence` misuse) - rust-lang#103788 (Fix ICE in checking transmutability of NaughtyLenArray) - rust-lang#103793 (rustdoc: add margins to all impl-item toggles, not just methods) - rust-lang#103798 (interpret: move type_name implementation to an interpreter-independent helper file) - rust-lang#103799 (Remove generation of tuple struct fields in the search index) - rust-lang#103805 (Enable RUSTC_BOOTSTRAP for a few steps) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…=fee1-dead Reorder `walk_` functions in intravisit.rs Reorder the `walk_` functions to match the order of the `visit_` methods. This is a follow up to rust-lang#103692. Note that there are some oddballs. I put them where I thought made the most sense: ```diff $ diff \ <(sed -n 's/^.*\<fn visit_\([^(]*\).*$/\1/;T;p' compiler/rustc_hir/src/intravisit.rs) \ <(sed -n 's/^.*\<fn walk_\([^<]*\).*$/\1/;T;p' compiler/rustc_hir/src/intravisit.rs) 1,5d0 < nested_item < nested_trait_item < nested_impl_item < nested_foreign_item < nested_body 9,10d3 < id < name 20c13 < array_length --- > array_len 30a24 > fn_ret_ty 31a26 > fn_kind 41c36 < variant_data --- > struct_def 46c41 < infer --- > inf 54d48 < attribute ``` Also, as some weak evidence that i did things correctly, I get the following before and after the change: ```sh $ sort compiler/rustc_hir/src/intravisit.rs | openssl sha256 SHA256(stdin)= cac13d2545731ef442f318e2b4286490d7ac5494f4ad10c4cf4c5d4f50d21641 ``` r? `@fee1-dead`
Use `walk_generic_arg` This is a tiny followup to to #9743, now that rust-lang/rust#103692 has landed. r? `@Alexendoo` changelog: none
Could this please be added?
I could use it for a Clippy lint.