Skip to content
Permalink
Browse files

Prevent array length printing cycle with debug assertions

  • Loading branch information...
oli-obk committed May 26, 2019
1 parent 7385f21 commit d1f62b92eb60815840647d59132c7a737768a694
Showing with 6 additions and 1 deletion.
  1. +6 −1 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("_"));

0 comments on commit d1f62b9

Please sign in to comment.
You can’t perform that action at this time.