diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2018-06-24 01:44:23 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2018-07-04 14:36:07 -0700 |
| commit | f7e9d2ac3edf91403f2bd4879e0e8f6b9248adb2 (patch) | |
| tree | a6b9efec8d79c3353455e09f724a4505606b8259 | |
| parent | 0f1c61cb7f20d8600e334bdd13e39c0eeb313d15 (diff) | |
| download | rust-f7e9d2ac3edf91403f2bd4879e0e8f6b9248adb2.tar.gz rust-f7e9d2ac3edf91403f2bd4879e0e8f6b9248adb2.zip | |
Add an `InfiniteLoop` variant to `EvalErrorKind`
| -rw-r--r-- | src/librustc/ich/impls_ty.rs | 3 | ||||
| -rw-r--r-- | src/librustc/mir/interpret/error.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/structural_impls.rs | 1 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 6 |
4 files changed, 8 insertions, 4 deletions
diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 5753557a102..a3600c04800 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -549,7 +549,8 @@ for ::mir::interpret::EvalErrorKind<'gcx, O> { RemainderByZero | DivisionByZero | GeneratorResumedAfterReturn | - GeneratorResumedAfterPanic => {} + GeneratorResumedAfterPanic | + InfiniteLoop => {} ReferencedConstant(ref err) => err.hash_stable(hcx, hasher), MachineError(ref err) => err.hash_stable(hcx, hasher), FunctionPointerTyMismatch(a, b) => { diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 7e2c144e0a7..143b7b2069c 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -264,6 +264,7 @@ pub enum EvalErrorKind<'tcx, O> { ReferencedConstant(Lrc<ConstEvalErr<'tcx>>), GeneratorResumedAfterReturn, GeneratorResumedAfterPanic, + InfiniteLoop, } pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>; @@ -398,6 +399,7 @@ 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", } } } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index c84999a7e59..874dabaf1c9 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -587,6 +587,7 @@ impl<'a, 'tcx, O: Lift<'tcx>> Lift<'tcx> for interpret::EvalErrorKind<'a, O> { RemainderByZero => RemainderByZero, GeneratorResumedAfterReturn => GeneratorResumedAfterReturn, GeneratorResumedAfterPanic => GeneratorResumedAfterPanic, + InfiniteLoop => InfiniteLoop, }) } } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index e3024e069d9..10fd97365f9 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -180,7 +180,7 @@ impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M> machine: &M, stack: &Vec<Frame<'mir, 'tcx>>, memory: &Memory<'a, 'mir, 'tcx, M>, - ) -> Result<(), (/*TODO*/)> { + ) -> EvalResult<'_, ()> { let snapshot = (machine, stack, memory); let mut fx = FxHasher::default(); @@ -197,8 +197,8 @@ impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M> return Ok(()) } - // Second cycle, - Err(()) + // Second cycle + Err(EvalErrorKind::InfiniteLoop.into()) } } |
