-
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
Expose try_destructure_mir_constant_for_diagnostics directly to clippy #115819
Expose try_destructure_mir_constant_for_diagnostics directly to clippy #115819
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
&& let Some(dc) = lcx.tcx.try_destructure_mir_constant_for_diagnostics((result, ty)) | ||
&& let Some(dc) = rustc_const_eval::const_eval::try_destructure_mir_constant_for_diagnostics(lcx.tcx, result, ty) |
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.
Hey @oli-obk , what intuition should a developer use to determine which of these two methods they are supposed to call in a given context? How can I know if the query-based lcx.tcx.$METHOD
is the appropriate thing to call?
Is it a matter of "If you see an ICE with 'forcing query with already existing DepNode
', then you are doing it wrong" ? Unfortunately the error output I see on #83085 doesn't clearly point one to this code, so I don't know how someone would track it down...
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 don't think anyone should be calling this query. It was wrong of me to implement the traits that allowed ConstValue
(an argument to the query), to be used in query arguments, as it can produce equal stable hashes for things that are not identical via PartialEq
(in fact, this is very easy to cause, just by allocating two different AllocId
s for the same Allocation
, as all AllocId
s are stable-hashed by the allocation they refer to).
But we have no way to avoid it from pretty printing at present, because that's implemented in rustc_middle
while the query provider is in rustc_const_eval
(which depends on rustc_middle
).
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.
But we have no way to avoid it from pretty printing at present, because that's implemented in
rustc_middle
while the query provider is inrustc_const_eval
(which depends onrustc_middle
).
Other cases like this are typically addressed by non-query dyn Trait
s or function pointers, rather than queries.
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.
We don't really have a good place/system to add such function pointers to TyCtxt
yet. I could look into making it part of the whole provider
scheme.
If that's desirable, I will do that, but this PR should be landed quickly so we can have a small patch to beta, instead of a larger change (even if benign)
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.
We don't really have a good place/system to add such function pointers to
TyCtxt
yet.
Well, lint_store
and formerly cstore
lived right in GlobalCtxt
.
This PR seems fine for backport, though.
r=me with a FIXME on |
☔ The latest upstream changes (presumably #116027) made this pull request unmergeable. Please resolve the merge conflicts. |
…affleLapkin Add a way to decouple the implementation and the declaration of a TyCtxt method. properly addresses rust-lang#115819 accepted MCP: rust-lang/compiler-team#395
Add a way to decouple the implementation and the declaration of a TyCtxt method. properly addresses rust-lang/rust#115819 accepted MCP: rust-lang/compiler-team#395
Add a way to decouple the implementation and the declaration of a TyCtxt method. properly addresses rust-lang/rust#115819 accepted MCP: rust-lang/compiler-team#395
aaa whoops, sorry y'all |
Otherwise clippy tries to use the query in ways that incremental caching will inevitably cause problems with.
bbb38ea
to
b76caa1
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
As discussed in the compiler team triage, we're landing this directly on beta, as it is a much simpler fix than backporting the more complex #116052 that fixes the issue on master. |
@bors r+ |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
…_for_diagnostics_strikes_again, r=oli-obk Expose try_destructure_mir_constant_for_diagnostics directly to clippy Otherwise clippy tries to use the query in ways that incremental caching will inevitably cause problems with. Hopefully gets rid of rust-lang#83085 for good
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
☀️ Test successful - checks-actions |
67: Automated pull from upstream `stable` r=pietroalbini a=github-actions[bot] This PR pulls the following changes from the upstream repository: * rust-lang/rust#116364 * rust-lang/rust#116279 * rust-lang/rust#115819 * rust-lang/rust#116044 * rust-lang/rust#115901 * rust-lang/rust#115722 * rust-lang/rust#115442 * rust-lang/rust#115282 * rust-lang/rust#115195 * rust-lang/rust#115056 Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com> Co-authored-by: bors <bors@rust-lang.org> Co-authored-by: Josh Stone <jistone@redhat.com> Co-authored-by: Jack Huey <31162821+jackh726@users.noreply.github.com> Co-authored-by: Weihang Lo <me@weihanglo.tw> Co-authored-by: Tomasz Miąsko <tomasz.miasko@gmail.com> Co-authored-by: David Tolnay <dtolnay@gmail.com> Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com> Co-authored-by: Camille GILLOT <gillot.camille@gmail.com> Co-authored-by: Michael Howell <michael@notriddle.com> Co-authored-by: lcnr <rust@lcnr.de> Co-authored-by: klensy <klensy@users.noreply.github.com> Co-authored-by: León Orell Valerian Liehr <me@fmease.dev> Co-authored-by: Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> Co-authored-by: bohan <bohan-zhang@foxmail.com> Co-authored-by: ouz-a <ouz.agz@gmail.com> Co-authored-by: Georgii Rylov <g0dj4n@gmail.com> Co-authored-by: Michael Goulet <michael@errs.io>
Otherwise clippy tries to use the query in ways that incremental caching will inevitably cause problems with.
Hopefully gets rid of #83085 for good