File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,16 @@ use std::i32;
99
1010pub trait Foo {
1111 const NEG : i32 ;
12+ const GEN : i32 ;
13+
1214 const ADD : i32 ;
15+ const DDA : i32 ;
16+
1317 const DIV : i32 ;
18+ const VID : i32 ;
19+
1420 const OOB : i32 ;
21+ const BOO : i32 ;
1522}
1623
1724// These constants cannot be evaluated already (they depend on `T::N`), so
@@ -20,10 +27,21 @@ pub trait Foo {
2027impl < T : Foo > Foo for Vec < T > {
2128 const NEG : i32 = -i32:: MIN + T :: NEG ;
2229 //~^ ERROR arithmetic operation will overflow
30+ const GEN : i32 = T :: NEG + ( -i32:: MIN ) ;
31+ //~^ ERROR arithmetic operation will overflow
32+
2333 const ADD : i32 = ( i32:: MAX +1 ) + T :: ADD ;
2434 //~^ ERROR arithmetic operation will overflow
35+ const DDA : i32 = T :: ADD + ( i32:: MAX +1 ) ;
36+ //~^ ERROR arithmetic operation will overflow
37+
2538 const DIV : i32 = ( 1 /0 ) + T :: DIV ;
2639 //~^ ERROR operation will panic
40+ const VID : i32 = T :: DIV + ( 1 /0 ) ;
41+ //~^ ERROR operation will panic
42+
2743 const OOB : i32 = [ 1 ] [ 1 ] + T :: OOB ;
2844 //~^ ERROR operation will panic
45+ const BOO : i32 = T :: OOB + [ 1 ] [ 1 ] ;
46+ //~^ ERROR operation will panic
2947}
You can’t perform that action at this time.
0 commit comments