-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Missing tcx query provider is hard to diagnose - error message is not intuitive #83122
Comments
Maybe something like "no provider available for local/external crate" (depending on whether it's local or not)? |
I think the reference to "crate" is what threw me off actually. To me, it implies the missing provider is missing in the code being compiled, but the problem was the provider should have been assigned in the compiler code itself. |
The distinction matters though - there can be a provider for local crates but not external ones, or vice versa. |
That's fine. I don't fully understand the significance of the crate, but if it helps others debug certain types of issues, it's fine to replace "unsupported by its crate" to "no provider available for local/external crate" (if the information is available). But the problem I had didn't have anything to do with the crate distinction, or at least, if it did, the message wouldn't have helped me diagnose the actual problem: In my case, there was a Removing that query assignment was a bug in the compiler code itself, regardless of what was happening with local vs. external crates. So how about just adding to either the current message or your revised message? I'm not sure how to tell what is local or external here, from just the
impl Default for Providers {
fn default() -> Self {
Providers {
$($name: |tcx, key| bug!(
"`tcx.{}({:?})` no provider available for {} crate; perhaps the `{}` query was never assigned a provider function",
stringify!($name),
key,
if tcx.is_local() { "local" } else { "external" },
stringify!($name),
),)*
}
}
} |
That looks good! Could you make a pr with that change? :) |
@jyn514 - Happy to submit a PR, but I don't think Is there a If not, I can just use the original message, and add the |
It's the other way around - there's only ever one rust/compiler/rustc_interface/src/passes.rs Lines 738 to 743 in 7a7bbdb
|
Hmm, that actually won't work because you have to have a function pointer, not a closure - you don't have access to the current state of the |
OK, will do then. Thanks! |
I inadvertently deleted a
rustc_middle::ty::query::Providers
assignment (which meant that anytcx.some_unassigned_query(def_id)
would not be resolved.Since
tcx
query functions are assigned at runtime, this is not a build-time error.The best that
rustc
can do is generate a runtime error, but the error message is non-intuitive, and it took quite a while for me to realize my mistake:Is there a better way to word this message to make it more obvious that there is a
query
defined, but a provider was never assigned?The text was updated successfully, but these errors were encountered: