about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-04-23 13:18:11 +0100
committervarkor <github@varkor.com>2019-05-01 23:11:19 +0100
commit16d6ee39523bbaa1fd38808cab30f284ce3f30f8 (patch)
treeb11e62bba3438a71e1cc4cd61b84e87e5ba8dee7
parentc7deb5bdc2dead50d728c71a18095f088398b7db (diff)
downloadrust-16d6ee39523bbaa1fd38808cab30f284ce3f30f8.tar.gz
rust-16d6ee39523bbaa1fd38808cab30f284ce3f30f8.zip
Fold const in writeback
-rw-r--r--src/librustc_typeck/check/writeback.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs
index 5d98cb568bd..e13651d253d 100644
--- a/src/librustc_typeck/check/writeback.rs
+++ b/src/librustc_typeck/check/writeback.rs
@@ -853,6 +853,21 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Resolver<'cx, 'gcx, 'tcx> {
     fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
         self.infcx.fully_resolve(&r).unwrap_or(self.tcx.lifetimes.re_static)
     }
+
+    fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
+        match self.infcx.fully_resolve(&ct) {
+            Ok(ct) => ct,
+            Err(_) => {
+                debug!(
+                    "Resolver::fold_const: input const `{:?}` not fully resolvable",
+                    ct
+                );
+                // FIXME: we'd like to use `self.report_error`, but it doesn't yet
+                // accept a &'tcx ty::Const.
+                self.tcx().types.ct_err
+            }
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////