From 647ba29b90155e07cf569060d344242b3ee474eb Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 26 Jun 2018 18:54:59 -0700 Subject: [PATCH] Explain reason behind error span We can't expand the span of the error reliably according to @oli-obk, so just mention why it points to this particular expression. --- src/librustc/mir/interpret/error.rs | 4 +++- src/test/ui/const-eval/infinite_loop.stderr | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 143b7b2069cc..68e1d6c65c06 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -399,7 +399,9 @@ impl<'tcx, O> EvalErrorKind<'tcx, O> { RemainderByZero => "attempt to calculate the remainder with a divisor of zero", GeneratorResumedAfterReturn => "generator resumed after completion", GeneratorResumedAfterPanic => "generator resumed after panicking", - InfiniteLoop => "program will never terminate", + InfiniteLoop => + "duplicate interpreter state observed while executing this expression, \ + const evaluation will never terminate", } } } diff --git a/src/test/ui/const-eval/infinite_loop.stderr b/src/test/ui/const-eval/infinite_loop.stderr index 904fbcb07e4b..95c15c3e4e25 100644 --- a/src/test/ui/const-eval/infinite_loop.stderr +++ b/src/test/ui/const-eval/infinite_loop.stderr @@ -29,7 +29,7 @@ LL | | //~| ERROR could not evaluate repeat length LL | | let mut n = 113383; // #20 in A006884 LL | | while n != 0 { //~ ERROR constant contains unimplemented expression type LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; - | | ---------- program will never terminate + | | ---------- duplicate interpreter state observed while executing this expression, const evaluation will never terminate LL | | } LL | | n LL | | }];