Skip to content

Commit 6d33a18

Browse files
committed
Accept duplicate on const_errs (for now).
1 parent d95a610 commit 6d33a18

7 files changed

+39
-21
lines changed

src/test/ui/associated-const/lints-used-unused.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ struct S;
1515
impl Foo for S {
1616
const N: i32 = 1 << 42;
1717
//~^ ERROR this arithmetic operation will overflow
18+
//~| ERROR any use of this value will cause an error
1819
}
1920

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

2426
fn main() {

src/test/ui/associated-const/lints-used-unused.unused.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ LL | const N: i32 = 1 << 42;
2020
|
2121
= note: `#[deny(const_err)]` on by default
2222

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

src/test/ui/associated-const/lints-used-unused.used.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ LL | const N: i32 = 1 << 42;
2020
|
2121
= note: `#[deny(const_err)]` on by default
2222

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

src/test/ui/consts/issue-69020.noopt.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,43 @@ LL | const NEG: i32 = -i32::MIN + T::NEG;
1717
= note: `#[deny(const_err)]` on by default
1818

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

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

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

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

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

5555
error: any use of this value will cause an error
56-
--> $DIR/issue-69020.rs:27:22
56+
--> $DIR/issue-69020.rs:30:22
5757
|
5858
LL | const OOB: i32 = [1][1] + T::OOB;
5959
| -----------------^^^^^^----------

src/test/ui/consts/issue-69020.opt.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,43 @@ LL | const NEG: i32 = -i32::MIN + T::NEG;
1717
= note: `#[deny(const_err)]` on by default
1818

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

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

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

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

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

5555
error: any use of this value will cause an error
56-
--> $DIR/issue-69020.rs:27:22
56+
--> $DIR/issue-69020.rs:30:22
5757
|
5858
LL | const OOB: i32 = [1][1] + T::OOB;
5959
| -----------------^^^^^^----------

src/test/ui/consts/issue-69020.opt_with_overflow_checks.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,43 @@ LL | const NEG: i32 = -i32::MIN + T::NEG;
1717
= note: `#[deny(const_err)]` on by default
1818

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

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

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

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

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

5555
error: any use of this value will cause an error
56-
--> $DIR/issue-69020.rs:27:22
56+
--> $DIR/issue-69020.rs:30:22
5757
|
5858
LL | const OOB: i32 = [1][1] + T::OOB;
5959
| -----------------^^^^^^----------

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

+4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ pub trait Foo {
2020
impl<T: Foo> Foo for Vec<T> {
2121
const NEG: i32 = -i32::MIN + T::NEG;
2222
//~^ ERROR arithmetic operation will overflow
23+
//~| ERROR any use of this value will cause an error
2324
const ADD: i32 = (i32::MAX+1) + T::ADD;
2425
//~^ ERROR arithmetic operation will overflow
26+
//~| ERROR any use of this value will cause an error
2527
const DIV: i32 = (1/0) + T::DIV;
2628
//~^ ERROR operation will panic
29+
//~| ERROR any use of this value will cause an error
2730
const OOB: i32 = [1][1] + T::OOB;
2831
//~^ ERROR operation will panic
32+
//~| ERROR any use of this value will cause an error
2933
}

0 commit comments

Comments
 (0)