Skip to content

Commit d1f62b9

Browse files
committed
Prevent array length printing cycle with debug assertions
1 parent 7385f21 commit d1f62b9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: src/librustc/ty/print/pretty.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,12 @@ pub trait PrettyPrinter<'tcx>:
696696
},
697697
ty::Array(ty, sz) => {
698698
p!(write("["), print(ty), write("; "));
699-
if let Some(n) = sz.try_eval_usize(self.tcx(), ty::ParamEnv::empty()) {
699+
if let ConstValue::Unevaluated(..) = sz.val {
700+
// do not try to evalute unevaluated constants. If we are const evaluating an
701+
// array length anon const, rustc will (with debug assertions) print the
702+
// constant's path. Which will end up here again.
703+
p!(write("_"));
704+
} else if let Some(n) = sz.try_eval_usize(self.tcx(), ty::ParamEnv::empty()) {
700705
p!(write("{}", n));
701706
} else {
702707
p!(write("_"));

0 commit comments

Comments
 (0)