Skip to content

Commit 42010a2

Browse files
authored
Rollup merge of #104675 - SarthakSingh31:issue-101666, r=jyn514
Unsupported query error now specifies if its unsupported for local or external crate Fixes #101666. I had to move `keys.rs` from `rustc_query_impl` to `rustc_middle`. I don't know if that is problematic. I couldn't think of any other way to get the needed information inside `rustc_middle`. r? ```@jyn514```
2 parents 4733312 + 1767f9f commit 42010a2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

compiler/rustc_middle/src/ty/query.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,16 @@ macro_rules! define_callbacks {
276276

277277
impl Default for Providers {
278278
fn default() -> Self {
279+
use crate::query::Key;
280+
279281
Providers {
280282
$($name: |_, key| bug!(
281-
"`tcx.{}({:?})` is not supported for external or local crate;\n
282-
hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported (likely the local crate).\n
283+
"`tcx.{}({:?})` is not supported for {} crate;\n
284+
hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported.\n
283285
If that's not the case, {} was likely never assigned to a provider function.\n",
284286
stringify!($name),
285287
key,
288+
if key.query_crate_is_local() { "local" } else { "external" },
286289
stringify!($name),
287290
),)*
288291
}

compiler/rustc_query_impl/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern crate rustc_middle;
2020
use rustc_data_structures::sync::AtomicU64;
2121
use rustc_middle::arena::Arena;
2222
use rustc_middle::dep_graph::{self, DepKindStruct};
23+
use rustc_middle::query::Key;
2324
use rustc_middle::ty::query::{query_keys, query_storage, query_stored, query_values};
2425
use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine};
2526
use rustc_middle::ty::TyCtxt;
@@ -32,8 +33,6 @@ use rustc_query_system::query::*;
3233
#[cfg(parallel_compiler)]
3334
pub use rustc_query_system::query::{deadlock, QueryContext};
3435

35-
use rustc_middle::query::Key;
36-
3736
pub use rustc_query_system::query::QueryConfig;
3837
pub(crate) use rustc_query_system::query::QueryVTable;
3938

0 commit comments

Comments
 (0)