diff options
| author | DaniPopes <57450786+DaniPopes@users.noreply.github.com> | 2024-04-16 15:20:12 +0200 |
|---|---|---|
| committer | DaniPopes <57450786+DaniPopes@users.noreply.github.com> | 2024-04-16 15:41:02 +0200 |
| commit | 780dfb803fe1b0ad139bac9736ce847c75ab1c81 (patch) | |
| tree | 78a0c835fd429792b69947a93fc4354861edc63b /compiler/rustc_middle/src/hooks/mod.rs | |
| parent | ad18fe08de03fbb459c05475bddee22707b4f0ec (diff) | |
| download | rust-780dfb803fe1b0ad139bac9736ce847c75ab1c81.tar.gz rust-780dfb803fe1b0ad139bac9736ce847c75ab1c81.zip | |
Outline default query and hook provider function implementations
Diffstat (limited to 'compiler/rustc_middle/src/hooks/mod.rs')
| -rw-r--r-- | compiler/rustc_middle/src/hooks/mod.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/hooks/mod.rs b/compiler/rustc_middle/src/hooks/mod.rs index f7ce15d0a8d..669265c86f5 100644 --- a/compiler/rustc_middle/src/hooks/mod.rs +++ b/compiler/rustc_middle/src/hooks/mod.rs @@ -47,12 +47,7 @@ macro_rules! declare_hooks { impl Default for Providers { fn default() -> Self { Providers { - $($name: |_, $($arg,)*| bug!( - "`tcx.{}{:?}` cannot be called as `{}` was never assigned to a provider function.\n", - stringify!($name), - ($($arg,)*), - stringify!($name), - ),)* + $($name: |_, $($arg,)*| default_hook(stringify!($name), &($($arg,)*))),* } } } @@ -84,7 +79,6 @@ declare_hooks! { /// via `mir_built` hook build_mir(key: LocalDefId) -> mir::Body<'tcx>; - /// Imports all `SourceFile`s from the given crate into the current session. /// This normally happens automatically when we decode a `Span` from /// that crate's metadata - however, the incr comp cache needs @@ -103,3 +97,10 @@ declare_hooks! { /// Will fetch a DefId from a DefPathHash for a foreign crate. hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> DefId; } + +#[cold] +fn default_hook(name: &str, args: &dyn std::fmt::Debug) -> ! { + bug!( + "`tcx.{name}{args:?}` cannot be called as `{name}` was never assigned to a provider function" + ) +} |
