-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Cleanup query macros #152424
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
base: main
Are you sure you want to change the base?
Cleanup query macros #152424
Conversation
It's just an unnecessary level of additional nesting. rust-lang#151893 did the same thing for the `define_callbacks` macro.
Specifically `define_callbacks` and `define_queries`. These are big, complicated macros. If the top-level `$(..)*` repetitions are obvious it helps enormously with readability.
It's a unit type used for trait stuff, it doesn't need a lifetime. (Unless there's some weird variance thing I'm unaware of, but it compiles fine, so I think it should be ok.)
|
|
I find that the
In #151893 it’s less necessary because |
|
I agree with giving The exception I sometimes make is for relatively simple struct field declarations and struct/slice initialisation. If the whole thing can clearly and comfortably fit on one line, then I tend to prefer this more compact style: Struct {
$( $name: FieldType<$name::Thing>, )*
}(Take this as a suggestion rather than a request for changes; use it if you agree it’s an improvement in particular places, but otherwise the fully-indented style is fine.) |
| pub(crate) struct QueryType<'tcx> { | ||
| data: PhantomData<&'tcx ()> | ||
| } | ||
| pub(crate) struct QueryType; |
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.
Remark: I intend to dismantle and remove QueryDispatcherUnerased (and therefore QueryType) at some point, but no harm in simplifying this now.
|
☔ The latest upstream changes (presumably #152437) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I have filed #152459 as an alternative to the first commit in this PR. It aims to make |
Some readability improvements.
r? @Zalathar