about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-07 10:40:36 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-15 12:58:32 +0200
commit29b5844c2d7225936545ead6c25e13fc1e822b63 (patch)
tree457310e9ea126dd2f4000f9c3fadb7b0eb23e03b
parent9df03ccf622b96f23bc185019d9be464c308f3fe (diff)
downloadrust-29b5844c2d7225936545ead6c25e13fc1e822b63.tar.gz
rust-29b5844c2d7225936545ead6c25e13fc1e822b63.zip
only call `typeck_tables_of_const_arg` for const args
-rw-r--r--src/librustc_middle/query/mod.rs4
-rw-r--r--src/librustc_middle/ty/context.rs11
-rw-r--r--src/librustc_typeck/check/mod.rs4
3 files changed, 15 insertions, 4 deletions
diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs
index f1deb6388af..56cd93a509a 100644
--- a/src/librustc_middle/query/mod.rs
+++ b/src/librustc_middle/query/mod.rs
@@ -579,11 +579,11 @@ rustc_queries! {
             desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
             cache_on_disk_if { true }
         }
-        query typeck_tables_of_const_arg(
+        query _typeck_tables_of_const_arg(
             key: ty::WithOptParam<LocalDefId>
         ) -> &'tcx ty::TypeckTables<'tcx> {
             desc {
-                |tcx| "type-checking the potential const argument `{}`",
+                |tcx| "type-checking the const argument `{}`",
                 tcx.def_path_str(key.did.to_def_id()),
             }
         }
diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs
index d2bad6e90dd..f79297aeac6 100644
--- a/src/librustc_middle/ty/context.rs
+++ b/src/librustc_middle/ty/context.rs
@@ -980,6 +980,17 @@ pub struct GlobalCtxt<'tcx> {
 }
 
 impl<'tcx> TyCtxt<'tcx> {
+    pub fn typeck_tables_of_const_arg(
+        self,
+        def: ty::WithOptParam<LocalDefId>,
+    ) -> &'tcx TypeckTables<'tcx> {
+        if def.param_did.is_some() {
+            self._typeck_tables_of_const_arg(def)
+        } else {
+            self.typeck_tables_of(def.did)
+        }
+    }
+
     pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
         self.arena.alloc(Steal::new(mir))
     }
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 4f792a07cc6..fdeb01cc6b3 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -764,7 +764,7 @@ pub fn provide(providers: &mut Providers) {
     method::provide(providers);
     *providers = Providers {
         typeck_item_bodies,
-        typeck_tables_of_const_arg,
+        _typeck_tables_of_const_arg: typeck_tables_of_const_arg,
         typeck_tables_of,
         diagnostic_only_typeck_tables_of,
         has_typeck_tables,
@@ -964,7 +964,7 @@ fn typeck_tables_of_const_arg<'tcx>(
         let fallback = move || tcx.type_of(param_did);
         typeck_tables_of_with_fallback(tcx, def.did, fallback)
     } else {
-        tcx.typeck_tables_of(def.did)
+        bug!("missing param_did")
     }
 }