File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,16 @@ use std::i32;
9
9
10
10
pub trait Foo {
11
11
const NEG : i32 ;
12
+ const GEN : i32 ;
13
+
12
14
const ADD : i32 ;
15
+ const DDA : i32 ;
16
+
13
17
const DIV : i32 ;
18
+ const VID : i32 ;
19
+
14
20
const OOB : i32 ;
21
+ const BOO : i32 ;
15
22
}
16
23
17
24
// These constants cannot be evaluated already (they depend on `T::N`), so
@@ -20,10 +27,21 @@ pub trait Foo {
20
27
impl < T : Foo > Foo for Vec < T > {
21
28
const NEG : i32 = -i32:: MIN + T :: NEG ;
22
29
//~^ ERROR arithmetic operation will overflow
30
+ const GEN : i32 = T :: NEG + ( -i32:: MIN ) ;
31
+ //~^ ERROR arithmetic operation will overflow
32
+
23
33
const ADD : i32 = ( i32:: MAX +1 ) + T :: ADD ;
24
34
//~^ ERROR arithmetic operation will overflow
35
+ const DDA : i32 = T :: ADD + ( i32:: MAX +1 ) ;
36
+ //~^ ERROR arithmetic operation will overflow
37
+
25
38
const DIV : i32 = ( 1 /0 ) + T :: DIV ;
26
39
//~^ ERROR operation will panic
40
+ const VID : i32 = T :: DIV + ( 1 /0 ) ;
41
+ //~^ ERROR operation will panic
42
+
27
43
const OOB : i32 = [ 1 ] [ 1 ] + T :: OOB ;
28
44
//~^ ERROR operation will panic
45
+ const BOO : i32 = T :: OOB + [ 1 ] [ 1 ] ;
46
+ //~^ ERROR operation will panic
29
47
}
You can’t perform that action at this time.
0 commit comments