Skip to content

Commit

Permalink
Prevent array length printing cycle with debug assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Aug 5, 2019
1 parent 7385f21 commit d1f62b9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc/ty/print/pretty.rs
Expand Up @@ -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("_"));
Expand Down

0 comments on commit d1f62b9

Please sign in to comment.