Skip to content

Commit 29b5844

Browse files
committed
only call typeck_tables_of_const_arg for const args
1 parent 9df03cc commit 29b5844

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/librustc_middle/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,11 @@ rustc_queries! {
579579
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
580580
cache_on_disk_if { true }
581581
}
582-
query typeck_tables_of_const_arg(
582+
query _typeck_tables_of_const_arg(
583583
key: ty::WithOptParam<LocalDefId>
584584
) -> &'tcx ty::TypeckTables<'tcx> {
585585
desc {
586-
|tcx| "type-checking the potential const argument `{}`",
586+
|tcx| "type-checking the const argument `{}`",
587587
tcx.def_path_str(key.did.to_def_id()),
588588
}
589589
}

src/librustc_middle/ty/context.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,17 @@ pub struct GlobalCtxt<'tcx> {
980980
}
981981

982982
impl<'tcx> TyCtxt<'tcx> {
983+
pub fn typeck_tables_of_const_arg(
984+
self,
985+
def: ty::WithOptParam<LocalDefId>,
986+
) -> &'tcx TypeckTables<'tcx> {
987+
if def.param_did.is_some() {
988+
self._typeck_tables_of_const_arg(def)
989+
} else {
990+
self.typeck_tables_of(def.did)
991+
}
992+
}
993+
983994
pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
984995
self.arena.alloc(Steal::new(mir))
985996
}

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ pub fn provide(providers: &mut Providers) {
764764
method::provide(providers);
765765
*providers = Providers {
766766
typeck_item_bodies,
767-
typeck_tables_of_const_arg,
767+
_typeck_tables_of_const_arg: typeck_tables_of_const_arg,
768768
typeck_tables_of,
769769
diagnostic_only_typeck_tables_of,
770770
has_typeck_tables,
@@ -964,7 +964,7 @@ fn typeck_tables_of_const_arg<'tcx>(
964964
let fallback = move || tcx.type_of(param_did);
965965
typeck_tables_of_with_fallback(tcx, def.did, fallback)
966966
} else {
967-
tcx.typeck_tables_of(def.did)
967+
bug!("missing param_did")
968968
}
969969
}
970970

0 commit comments

Comments
 (0)