Skip to content

Commit b1a957b

Browse files
query_keys_local is conditional on separate_provide_if_extern
1 parent d213114 commit b1a957b

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

compiler/rustc_middle/src/ty/query.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,17 @@ macro_rules! query_if_arena {
151151
};
152152
}
153153

154-
macro_rules! separate_provide_local_decl {
155-
([][$name:ident]) => {
156-
for<'tcx> fn(
157-
TyCtxt<'tcx>,
158-
query_keys::$name<'tcx>,
159-
) -> query_provided::$name<'tcx>
154+
/// If `separate_provide_if_extern`, then the key can be projected to its
155+
/// local key via `<$K as AsLocalKey>::LocalKey`.
156+
macro_rules! local_key_if_separate_extern {
157+
([] $($K:tt)*) => {
158+
$($K)*
160159
};
161-
([(separate_provide_extern) $($rest:tt)*][$name:ident]) => {
162-
for<'tcx> fn(
163-
TyCtxt<'tcx>,
164-
query_keys_local::$name<'tcx>,
165-
) -> query_provided::$name<'tcx>
160+
([(separate_provide_extern) $($rest:tt)*] $($K:tt)*) => {
161+
<$($K)* as AsLocalKey>::LocalKey
166162
};
167-
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
168-
separate_provide_local_decl!([$($modifiers)*][$($args)*])
163+
([$other:tt $($modifiers:tt)*] $($K:tt)*) => {
164+
local_key_if_separate_extern!([$($modifiers)*] $($K)*)
169165
};
170166
}
171167

@@ -233,7 +229,7 @@ macro_rules! define_callbacks {
233229
pub mod query_keys_local {
234230
use super::*;
235231

236-
$(pub type $name<'tcx> = <$($K)* as AsLocalKey>::LocalKey;)*
232+
$(pub type $name<'tcx> = local_key_if_separate_extern!([$($modifiers)*] $($K)*);)*
237233
}
238234
#[allow(nonstandard_style, unused_lifetimes)]
239235
pub mod query_values {
@@ -407,7 +403,10 @@ macro_rules! define_callbacks {
407403
}
408404

409405
pub struct Providers {
410-
$(pub $name: separate_provide_local_decl!([$($modifiers)*][$name]),)*
406+
$(pub $name: for<'tcx> fn(
407+
TyCtxt<'tcx>,
408+
query_keys_local::$name<'tcx>,
409+
) -> query_provided::$name<'tcx>,)*
411410
}
412411

413412
pub struct ExternProviders {

0 commit comments

Comments
 (0)