Skip to content

Commit

Permalink
Accept duplicate on const_errs (for now).
Browse files Browse the repository at this point in the history
  • Loading branch information
jumbatm committed Mar 29, 2020
1 parent d95a610 commit 6d33a18
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/test/ui/associated-const/lints-used-unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ struct S;
impl Foo for S {
const N: i32 = 1 << 42;
//~^ ERROR this arithmetic operation will overflow
//~| ERROR any use of this value will cause an error
}

impl<T: Foo> Foo for Vec<T> {
const N: i32 = --T::N + (-i32::MIN); //~ ERROR this arithmetic operation will overflow
const N: i32 = --T::N + (-i32::MIN);
//~^ ERROR this arithmetic operation will overflow
}

fn main() {
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/associated-const/lints-used-unused.unused.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ LL | const N: i32 = 1 << 42;
|
= note: `#[deny(const_err)]` on by default

error: aborting due to 2 previous errors
error: this arithmetic operation will overflow
--> $DIR/lints-used-unused.rs:22:29
|
LL | const N: i32 = --T::N + (-i32::MIN);
| ^^^^^^^^^^^ attempt to negate with overflow

error: aborting due to 3 previous errors

8 changes: 7 additions & 1 deletion src/test/ui/associated-const/lints-used-unused.used.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ LL | const N: i32 = 1 << 42;
|
= note: `#[deny(const_err)]` on by default

error: aborting due to 2 previous errors
error: this arithmetic operation will overflow
--> $DIR/lints-used-unused.rs:22:29
|
LL | const N: i32 = --T::N + (-i32::MIN);
| ^^^^^^^^^^^ attempt to negate with overflow

error: aborting due to 3 previous errors

12 changes: 6 additions & 6 deletions src/test/ui/consts/issue-69020.noopt.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,43 @@ LL | const NEG: i32 = -i32::MIN + T::NEG;
= note: `#[deny(const_err)]` on by default

error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:23:22
--> $DIR/issue-69020.rs:24:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:23:22
--> $DIR/issue-69020.rs:24:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| -----------------^^^^^^^^^^^^----------
| |
| attempt to add with overflow

error: this operation will panic at runtime
--> $DIR/issue-69020.rs:25:22
--> $DIR/issue-69020.rs:27:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:25:22
--> $DIR/issue-69020.rs:27:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| -----------------^^^^^----------
| |
| attempt to divide by zero

error: this operation will panic at runtime
--> $DIR/issue-69020.rs:27:22
--> $DIR/issue-69020.rs:30:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the len is 1 but the index is 1

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:27:22
--> $DIR/issue-69020.rs:30:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| -----------------^^^^^^----------
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/consts/issue-69020.opt.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,43 @@ LL | const NEG: i32 = -i32::MIN + T::NEG;
= note: `#[deny(const_err)]` on by default

error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:23:22
--> $DIR/issue-69020.rs:24:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:23:22
--> $DIR/issue-69020.rs:24:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| -----------------^^^^^^^^^^^^----------
| |
| attempt to add with overflow

error: this operation will panic at runtime
--> $DIR/issue-69020.rs:25:22
--> $DIR/issue-69020.rs:27:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:25:22
--> $DIR/issue-69020.rs:27:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| -----------------^^^^^----------
| |
| attempt to divide by zero

error: this operation will panic at runtime
--> $DIR/issue-69020.rs:27:22
--> $DIR/issue-69020.rs:30:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the len is 1 but the index is 1

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:27:22
--> $DIR/issue-69020.rs:30:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| -----------------^^^^^^----------
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/consts/issue-69020.opt_with_overflow_checks.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,43 @@ LL | const NEG: i32 = -i32::MIN + T::NEG;
= note: `#[deny(const_err)]` on by default

error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:23:22
--> $DIR/issue-69020.rs:24:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:23:22
--> $DIR/issue-69020.rs:24:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| -----------------^^^^^^^^^^^^----------
| |
| attempt to add with overflow

error: this operation will panic at runtime
--> $DIR/issue-69020.rs:25:22
--> $DIR/issue-69020.rs:27:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:25:22
--> $DIR/issue-69020.rs:27:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| -----------------^^^^^----------
| |
| attempt to divide by zero

error: this operation will panic at runtime
--> $DIR/issue-69020.rs:27:22
--> $DIR/issue-69020.rs:30:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the len is 1 but the index is 1

error: any use of this value will cause an error
--> $DIR/issue-69020.rs:27:22
--> $DIR/issue-69020.rs:30:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| -----------------^^^^^^----------
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/consts/issue-69020.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ pub trait Foo {
impl<T: Foo> Foo for Vec<T> {
const NEG: i32 = -i32::MIN + T::NEG;
//~^ ERROR arithmetic operation will overflow
//~| ERROR any use of this value will cause an error
const ADD: i32 = (i32::MAX+1) + T::ADD;
//~^ ERROR arithmetic operation will overflow
//~| ERROR any use of this value will cause an error
const DIV: i32 = (1/0) + T::DIV;
//~^ ERROR operation will panic
//~| ERROR any use of this value will cause an error
const OOB: i32 = [1][1] + T::OOB;
//~^ ERROR operation will panic
//~| ERROR any use of this value will cause an error
}

0 comments on commit 6d33a18

Please sign in to comment.