Skip to content

Commit 4b8c784

Browse files
committed
add test for issue 69020
1 parent 9c76394 commit 4b8c784

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: this arithmetic operation will overflow
2+
--> $DIR/issue-69020.rs:15:20
3+
|
4+
LL | const N: i32 = -i32::MIN + T::N;
5+
| ^^^^^^^^^ attempt to negate with overflow
6+
|
7+
= note: `#[deny(overflow)]` on by default
8+
9+
error: aborting due to previous error
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: this arithmetic operation will overflow
2+
--> $DIR/issue-69020.rs:15:20
3+
|
4+
LL | const N: i32 = -i32::MIN + T::N;
5+
| ^^^^^^^^^ attempt to negate with overflow
6+
|
7+
= note: `#[deny(overflow)]` on by default
8+
9+
error: aborting due to previous error
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: this arithmetic operation will overflow
2+
--> $DIR/issue-69020.rs:15:20
3+
|
4+
LL | const N: i32 = -i32::MIN + T::N;
5+
| ^^^^^^^^^ attempt to negate with overflow
6+
|
7+
= note: `#[deny(overflow)]` on by default
8+
9+
error: aborting due to previous error
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: this arithmetic operation will overflow
2+
--> $DIR/issue-69020.rs:15:20
3+
|
4+
LL | const N: i32 = -i32::MIN + T::N;
5+
| ^^^^^^^^^ attempt to negate with overflow
6+
|
7+
= note: `#[deny(overflow)]` on by default
8+
9+
error: aborting due to previous error
10+

src/test/ui/consts/issue-69020.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// revisions: default noopt opt opt_with_overflow_checks
2+
//[noopt]compile-flags: -C opt-level=0
3+
//[opt]compile-flags: -O
4+
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
5+
6+
#![crate_type="lib"]
7+
8+
use std::i32;
9+
10+
pub trait Foo {
11+
const N: i32;
12+
}
13+
14+
impl<T: Foo> Foo for Vec<T> {
15+
const N: i32 = -i32::MIN + T::N;
16+
//~^ ERROR arithmetic operation will overflow
17+
}

0 commit comments

Comments
 (0)