Skip to content

Comments

Remove impl IntoQueryParam<P> for &'a P.#152879

Open
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:rm-impl-IntoQueryParam-ref-P
Open

Remove impl IntoQueryParam<P> for &'a P.#152879
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:rm-impl-IntoQueryParam-ref-P

Conversation

@nnethercote
Copy link
Contributor

IntoQueryParam is a trait that lets query callers be a bit sloppy with the passed-in key.

  • Types similar to DefId will be auto-converted to DefId. Likewise for LocalDefId.
  • Reference types will be auto-derefed.

The auto-conversion is genuinely useful; the auto-derefing much less so. In practice it's only used for passing &DefId to queries that accept DefId, which is an anti-pattern because DefId is marked with #[rustc_pass_by_value].

This commit removes the auto-deref impl and makes the necessary sigil adjustments. (I generally avoid using * to deref manually at call sites, preferring to deref via & in patterns or via * in match expressions. Mostly because that way a single deref often covers multiple call sites.)

r? @cjgillot

@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to constck

cc @fee1-dead

The Miri subtree was changed

cc @rust-lang/miri

HIR ty lowering was modified

cc @fmease

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 20, 2026
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

I don't feel like the motivation is strong, it's a nice convenience feature, but considering all the other dereffing we do not really important

View changes since this review

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 20, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 20, 2026
@rust-bors

This comment has been minimized.

@nnethercote nnethercote force-pushed the rm-impl-IntoQueryParam-ref-P branch from 89a8e28 to 5e3d666 Compare February 20, 2026 21:47
@nnethercote
Copy link
Contributor Author

Thanks for the review! I have fixed the two nits.

I don't feel like the motivation is strong

Let me explain why I did this. I'm on a ruthless drive to reduce complexity in the query system because I think it's a big problem. IntoQueryParam isn't like a lot of other traits because of its location. To understand it you also need some understanding of the rustc_queries! proc macro and the define_callbacks! declarative macro. That's two layers of complex macros. I think removing anything from within those two layers of macros has outsized positive effects.

I would actually like to remove IntoQueryParam entirely. (Pop quiz: do you know why define_callbacks! uses $($K:tt)* instead of the more obvious $K:ty? It's related.) But that would be a much more invasive change. Removing the auto-derefing eliminates a non-trivial wrinkle from within the two layers of macros, at the cost of some sigil fiddling of the variety we are all familiar with. I think that's worthwhile.

@nnethercote nnethercote force-pushed the rm-impl-IntoQueryParam-ref-P branch from 5e3d666 to fb4258c Compare February 20, 2026 22:05
@rustbot

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 21, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 21, 2026

📌 Commit fb4258c has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 21, 2026
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2026
…-ref-P, r=oli-obk

Remove `impl IntoQueryParam<P> for &'a P`.

`IntoQueryParam` is a trait that lets query callers be a bit sloppy with the passed-in key.
- Types similar to `DefId` will be auto-converted to `DefId`. Likewise for `LocalDefId`.
- Reference types will be auto-derefed.

The auto-conversion is genuinely useful; the auto-derefing much less so. In practice it's only used for passing `&DefId` to queries that accept `DefId`, which is an anti-pattern because `DefId` is marked with `#[rustc_pass_by_value]`.

This commit removes the auto-deref impl and makes the necessary sigil adjustments. (I generally avoid using `*` to deref manually at call sites, preferring to deref via `&` in patterns or via `*` in match expressions. Mostly because that way a single deref often covers multiple call sites.)

r? @cjgillot
@matthiaskrgr
Copy link
Member

@bors r-
may neeed rebase #152932 (comment)

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 21, 2026
`IntoQueryParam` is a trait that lets query callers be a bit sloppy with
the passed-in key.
- Types similar to `DefId` will be auto-converted to `DefId`. Likewise
  for `LocalDefId`.
- Reference types will be auto-derefed.

The auto-conversion is genuinely useful; the auto-derefing much less so.
In practice it's only used for passing `&DefId` to queries that accept
`DefId`, which is an anti-pattern because `DefId` is marked with
`#[rustc_pass_by_value]`.

This commit removes the auto-deref impl and makes the necessary sigil
adjustments. (I generally avoid using `*` to deref manually at call
sites, preferring to deref via `&` in patterns or via `*` in match
expressions. Mostly because that way a single deref often covers
multiple call sites.)
@nnethercote nnethercote force-pushed the rm-impl-IntoQueryParam-ref-P branch from fb4258c to a3d5908 Compare February 22, 2026 06:59
@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@nnethercote
Copy link
Contributor Author

I rebased.

@bors r=oli-obk rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 22, 2026

📌 Commit a3d5908 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 22, 2026
@rust-bors rust-bors bot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 22, 2026
@nnethercote

This comment was marked as off-topic.

@nnethercote

This comment was marked as off-topic.

@nnethercote
Copy link
Contributor Author

(Apologies: I wrote a couple of comments here that were intended for #152958.)

jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 22, 2026
…-ref-P, r=oli-obk

Remove `impl IntoQueryParam<P> for &'a P`.

`IntoQueryParam` is a trait that lets query callers be a bit sloppy with the passed-in key.
- Types similar to `DefId` will be auto-converted to `DefId`. Likewise for `LocalDefId`.
- Reference types will be auto-derefed.

The auto-conversion is genuinely useful; the auto-derefing much less so. In practice it's only used for passing `&DefId` to queries that accept `DefId`, which is an anti-pattern because `DefId` is marked with `#[rustc_pass_by_value]`.

This commit removes the auto-deref impl and makes the necessary sigil adjustments. (I generally avoid using `*` to deref manually at call sites, preferring to deref via `&` in patterns or via `*` in match expressions. Mostly because that way a single deref often covers multiple call sites.)

r? @cjgillot
rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
Rollup of 15 pull requests

Successful merges:

 - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - #151871 (don't use env with infer vars)
 - #152591 (Simplify internals of `{Rc,Arc}::default`)
 - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - #152908 (Enable rust.remap-debuginfo in the dist profile)
 - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls)
 - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - #152767 (fix typo in `carryless_mul` macro invocation)
 - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - #152871 (Fix warnings in rs{begin,end}.rs files)
 - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.)
 - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - #152937 (remove unneeded reboxing)
 - #152953 (Fix typo in armv7a-vex-v5.md)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants