File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed
src/test/ui/consts/const-eval Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,10 @@ const X: u32 = 5;
14
14
const Y : u32 = 6 ;
15
15
const FOO : u32 = [ X - Y , Y - X ] [ ( X < Y ) as usize ] ;
16
16
//~^ WARN this constant cannot be used
17
+ //~| ERROR
17
18
18
19
fn main ( ) {
19
20
println ! ( "{}" , FOO ) ;
20
- //~^ ERROR erroneous constant used
21
- //~| E0080
21
+ //~^ ERROR
22
+ //~| ERROR
22
23
}
Original file line number Diff line number Diff line change @@ -13,20 +13,28 @@ LL | #![warn(const_err)]
13
13
| ^^^^^^^^^
14
14
15
15
error[E0080]: referenced constant has errors
16
- --> $DIR/conditional_array_execution.rs:19 :20
16
+ --> $DIR/conditional_array_execution.rs:20 :20
17
17
|
18
18
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
19
19
| ----- attempt to subtract with overflow
20
20
...
21
21
LL | println!("{}", FOO);
22
22
| ^^^
23
23
24
- error[E0080]: erroneous constant used
25
- --> $DIR/conditional_array_execution.rs:19 :20
24
+ error[E0080]: could not evaluate constant
25
+ --> $DIR/conditional_array_execution.rs:20 :20
26
26
|
27
27
LL | println!("{}", FOO);
28
28
| ^^^ referenced constant has errors
29
29
30
- error: aborting due to 2 previous errors
30
+ error[E0080]: constant evaluation error
31
+ --> $DIR/conditional_array_execution.rs:15:1
32
+ |
33
+ LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
34
+ | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^
35
+ | |
36
+ | attempt to subtract with overflow
37
+
38
+ error: aborting due to 3 previous errors
31
39
32
40
For more information about this error, try `rustc --explain E0080`.
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ warning: attempt to divide by zero
34
34
LL | println!("{}", 1/(false as u32));
35
35
| ^^^^^^^^^^^^^^^^
36
36
37
+ warning: this expression will panic at runtime
38
+ --> $DIR/promoted_errors.rs:24:20
39
+ |
40
+ LL | println!("{}", 1/(false as u32));
41
+ | ^^^^^^^^^^^^^^^^ attempt to divide by zero
42
+
37
43
warning: attempt to divide by zero
38
44
--> $DIR/promoted_errors.rs:26:14
39
45
|
You can’t perform that action at this time.
0 commit comments