From d1f62b92eb60815840647d59132c7a737768a694 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sun, 26 May 2019 17:33:32 +0200 Subject: [PATCH] Prevent array length printing cycle with debug assertions --- src/librustc/ty/print/pretty.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index f14ab1d44418..017f67463c31 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("_"));