Skip to content

Commit b43b942

Browse files
committed
Remove query_helper_param_ty.
The query key sloppiness mentioned in the previous commit has another component: `query_helper_param_ty` only uses `IntoQueryParam` when the key type is `DefId` or `LocalDefId`. But thanks to the previous commit, `DefId` and `LocalDefId` are the only `T`s for which `IntoQueryParam<T>` is implemented. So we can just get rid of `query_helper_param_ty` and always use `IntoQueryParam` for every type. The net effect is the same, and makes the code simpler. Furthermore, `query_helper_param_ty`'s special cases required that the key in the macro be `$($K:tt)*` for the literal `DefId`/`LocalDefId` matches to work. With those gone, the next commit will change the key to the simpler `$K:ty`.
1 parent b996d80 commit b43b942

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl<'tcx> MonoItem<'tcx> {
277277
MonoItem::GlobalAsm(..) => return true,
278278
};
279279

280-
!tcx.instantiate_and_check_impossible_predicates((def_id, &args))
280+
!tcx.instantiate_and_check_impossible_predicates((def_id, args))
281281
}
282282

283283
pub fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option<Span> {

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,6 @@ impl<'tcx> TyCtxt<'tcx> {
262262
}
263263
}
264264

265-
macro_rules! query_helper_param_ty {
266-
(DefId) => { impl $crate::query::IntoQueryParam<DefId> };
267-
(LocalDefId) => { impl $crate::query::IntoQueryParam<LocalDefId> };
268-
($K:ty) => { $K };
269-
}
270-
271265
// Expands to `$then` if the `arena_cache` modifier is present, `$else` otherwise.
272266
macro_rules! if_arena_cache {
273267
([] $_then:tt $else:tt) => { $else };
@@ -416,7 +410,7 @@ macro_rules! define_callbacks {
416410
#[inline(always)]
417411
pub fn $name(
418412
self,
419-
key: query_helper_param_ty!($($K)*),
413+
key: impl $crate::query::IntoQueryParam<$($K)*>,
420414
) -> if_return_result_from_ensure_ok!(
421415
[$($modifiers)*]
422416
(Result<(), ErrorGuaranteed>)
@@ -447,7 +441,7 @@ macro_rules! define_callbacks {
447441
$(
448442
$(#[$attr])*
449443
#[inline(always)]
450-
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
444+
pub fn $name(self, key: impl $crate::query::IntoQueryParam<$($K)*>) {
451445
crate::query::inner::query_ensure(
452446
self.tcx,
453447
self.tcx.query_system.fns.engine.$name,
@@ -464,7 +458,7 @@ macro_rules! define_callbacks {
464458
$(#[$attr])*
465459
#[inline(always)]
466460
#[must_use]
467-
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V {
461+
pub fn $name(self, key: impl $crate::query::IntoQueryParam<$($K)*>) -> $V {
468462
self.at(DUMMY_SP).$name(key)
469463
}
470464
)*
@@ -474,7 +468,7 @@ macro_rules! define_callbacks {
474468
$(
475469
$(#[$attr])*
476470
#[inline(always)]
477-
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V {
471+
pub fn $name(self, key: impl $crate::query::IntoQueryParam<$($K)*>) -> $V {
478472
use $crate::query::{erase, inner};
479473

480474
erase::restore_val::<$V>(inner::query_get_at(

0 commit comments

Comments
 (0)