about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-05-26 17:33:32 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-08-05 17:48:05 +0200
commitd1f62b92eb60815840647d59132c7a737768a694 (patch)
tree6b410c10778c6c4e5065d8c46a6cb22e6d028a36
parent7385f2177f8e3b66ec8f506ed8ec9689460a9b85 (diff)
downloadrust-d1f62b92eb60815840647d59132c7a737768a694.tar.gz
rust-d1f62b92eb60815840647d59132c7a737768a694.zip
Prevent array length printing cycle with debug assertions
-rw-r--r--src/librustc/ty/print/pretty.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs
index f14ab1d4441..017f67463c3 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -696,7 +696,12 @@ pub trait PrettyPrinter<'tcx>:
             },
             ty::Array(ty, sz) => {
                 p!(write("["), print(ty), write("; "));
-                if let Some(n) = sz.try_eval_usize(self.tcx(), ty::ParamEnv::empty()) {
+                if let ConstValue::Unevaluated(..) = sz.val {
+                    // do not try to evalute unevaluated constants. If we are const evaluating an
+                    // array length anon const, rustc will (with debug assertions) print the
+                    // constant's path. Which will end up here again.
+                    p!(write("_"));
+                } else if let Some(n) = sz.try_eval_usize(self.tcx(), ty::ParamEnv::empty()) {
                     p!(write("{}", n));
                 } else {
                     p!(write("_"));