From dddfb7db24e66891fec9f2abf2ac1477985f36ad Mon Sep 17 00:00:00 2001 From: hanar3 Date: Wed, 14 Sep 2022 12:19:42 -0300 Subject: [PATCH 1/2] Improve error message for unsupported crate --- compiler/rustc_middle/src/ty/query.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 5665bb866d4..d69c28cfda2 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -275,10 +275,11 @@ macro_rules! define_callbacks { fn default() -> Self { Providers { $($name: |_, key| bug!( - "`tcx.{}({:?})` unsupported by its crate; \ - perhaps the `{}` query was never assigned a provider function", + "`tcx.{}({:?})` unsupported for {} crate; \ + perhaps the `{}` query was never assigned a provider function. 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.", stringify!($name), key, + if key.query_crate_is_local() { "local" } : { "external" } , stringify!($name), ),)* } From 0405a5d4e9aca1f1f22d94abca84c281bf1a97ea Mon Sep 17 00:00:00 2001 From: hanar3 Date: Sat, 17 Sep 2022 20:25:37 -0300 Subject: [PATCH 2/2] improve error message for when a query isn't supported --- compiler/rustc_middle/src/ty/query.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index d69c28cfda2..69a54cbc928 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -275,11 +275,11 @@ macro_rules! define_callbacks { fn default() -> Self { Providers { $($name: |_, key| bug!( - "`tcx.{}({:?})` unsupported for {} crate; \ - perhaps the `{}` query was never assigned a provider function. 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.", + "`tcx.{}({:?})` is not supported for external or local crate;\n + 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 + If that's not the case, {} was likely never assigned to a provider function.\n", stringify!($name), key, - if key.query_crate_is_local() { "local" } : { "external" } , stringify!($name), ),)* }