summaryrefslogtreecommitdiffstats
path: root/src/librustc_mir/interpret/step.rs
diff options
context:
space:
mode:
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2018-04-13 17:56:45 +0200
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2018-04-13 17:56:45 +0200
commit4f6d11804893f5cfbb6bd0809985f9c77acd9969 (patch)
tree59eddd7e400194ab987616aeadf0b5678edfe068 /src/librustc_mir/interpret/step.rs
parentAuto merge of #49669 - SimonSapin:global-alloc, r=alexcrichton (diff)
downloadgrust-4f6d11804893f5cfbb6bd0809985f9c77acd9969.tar.gz
grust-4f6d11804893f5cfbb6bd0809985f9c77acd9969.tar.bz2
grust-4f6d11804893f5cfbb6bd0809985f9c77acd9969.tar.xz
Don't abort const eval due to long running evals, just warn
Diffstat (limited to 'src/librustc_mir/interpret/step.rs')
-rw-r--r--src/librustc_mir/interpret/step.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs
index a22572ec68..f891d2b8cc 100644
--- a/src/librustc_mir/interpret/step.rs
+++ b/src/librustc_mir/interpret/step.rs
@@ -8,12 +8,11 @@ use rustc::mir::interpret::EvalResult;
8use super::{EvalContext, Machine}; 8use super::{EvalContext, Machine};
9 9
10impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { 10impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
11 pub fn inc_step_counter_and_check_limit(&mut self, n: usize) -> EvalResult<'tcx> { 11 pub fn inc_step_counter_and_check_limit(&mut self, n: usize) {
12 self.steps_remaining = self.steps_remaining.saturating_sub(n); 12 self.terminators_remaining = self.terminators_remaining.saturating_sub(n);
13 if self.steps_remaining > 0 { 13 if self.terminators_remaining == 0 {
14 Ok(()) 14 self.tcx.sess.span_warn(self.frame().span, "Constant evaluating a complex constant, this might take some time");
15 } else { 15 self.terminators_remaining = 1_000_000;
16 err!(ExecutionTimeLimitReached)
17 } 16 }
18 } 17 }
19 18
@@ -36,7 +35,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
36 return Ok(true); 35 return Ok(true);
37 } 36 }
38 37
39 self.inc_step_counter_and_check_limit(1)?; 38 self.inc_step_counter_and_check_limit(1);
40 39
41 let terminator = basic_block.terminator(); 40 let terminator = basic_block.terminator();
42 assert_eq!(old_frames, self.cur_frame()); 41 assert_eq!(old_frames, self.cur_frame());