Skip to content

Commit 4394720

Browse files
committed
Fix the overflowing tests in run-fail.
* The error patterns had a typo. * Our current constant evaluation would silently allow the overflow (filed as Issue 22531). * The overflowing-mul test was accidentally doing addition instead of multiplication.
1 parent e7c9861 commit 4394720

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/test/run-fail/overflowing-add.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:thread '<main>' panicked at 'arithmatic operation overflowed'
11+
// error-pattern:thread '<main>' panicked at 'arithmetic operation overflowed'
12+
13+
// (Work around constant-evaluation)
14+
fn value() -> u8 { 200 }
1215

1316
fn main() {
14-
let x = 200u8 + 200u8 + 200u8;
17+
let _x = value() + value() + value();
1518
}

src/test/run-fail/overflowing-mul.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:thread '<main>' panicked at 'arithmatic operation overflowed'
11+
// error-pattern:thread '<main>' panicked at 'arithmetic operation overflowed'
12+
13+
// (Work around constant-evaluation)
14+
fn value() -> u8 { 200 }
1215

1316
fn main() {
14-
let x = 200u8 + 4u8;
17+
let x = value() * 4;
1518
}

src/test/run-fail/overflowing-sub.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:thread '<main>' panicked at 'arithmatic operation overflowed'
11+
// error-pattern:thread '<main>' panicked at 'arithmetic operation overflowed'
12+
13+
// (Work around constant-evaluation)
14+
fn value() -> u8 { 42 }
1215

1316
fn main() {
14-
let x = 42u8 - 43u8;
17+
let _x = value() - (value() + 1);
1518
}

0 commit comments

Comments
 (0)