@@ -63,8 +63,7 @@ fn fixed_width_u8_overflow_add() {
6363 // U8 + U8: 255 + 255 = 510 > 255 -> overflow
6464 let checker = FixedWidthChecker :: new ( ) ;
6565 let err = checker. check_arithmetic_overflow ( & AstBinOp :: Add , & Type :: U8 , & Type :: U8 , & ( 0 ..1 ) ) ;
66- assert ! ( err. is_some( ) , "U8 + U8 should detect potential overflow" ) ;
67- let e = err. unwrap ( ) ;
66+ let e = err. expect ( "U8 + U8 should detect potential overflow" ) ;
6867 assert_eq ! ( e. code, "A10101" ) ;
6968 assert ! ( e. message. contains( "checked_add" ) ) ;
7069}
@@ -74,8 +73,10 @@ fn fixed_width_i8_overflow_add() {
7473 // I8 + I8: 127 + 127 = 254 > 127 -> overflow
7574 let checker = FixedWidthChecker :: new ( ) ;
7675 let err = checker. check_arithmetic_overflow ( & AstBinOp :: Add , & Type :: I8 , & Type :: I8 , & ( 0 ..1 ) ) ;
77- assert ! ( err. is_some( ) , "I8 + I8 should detect potential overflow" ) ;
78- assert_eq ! ( err. unwrap( ) . code, "A10101" ) ;
76+ assert_eq ! (
77+ err. expect( "I8 + I8 should detect potential overflow" ) . code,
78+ "A10101"
79+ ) ;
7980}
8081
8182#[ test]
@@ -92,17 +93,18 @@ fn fixed_width_mul_overflow() {
9293 // U8 * U8: 255 * 255 = 65025 > 255 -> overflow
9394 let checker = FixedWidthChecker :: new ( ) ;
9495 let err = checker. check_arithmetic_overflow ( & AstBinOp :: Mul , & Type :: U8 , & Type :: U8 , & ( 0 ..1 ) ) ;
95- assert ! ( err. is_some( ) , "U8 * U8 should detect potential overflow" ) ;
96- let e = err. unwrap ( ) ;
96+ let e = err. expect ( "U8 * U8 should detect potential overflow" ) ;
9797 assert ! ( e. message. contains( "checked_mul" ) ) ;
9898}
9999
100100#[ test]
101101fn fixed_width_narrowing_cast_u32_to_u16 ( ) {
102102 // U32 -> U16: max 4294967295 > 65535 -> unsafe
103103 let err = FixedWidthChecker :: check_cast_safety ( & Type :: U32 , & Type :: U16 , & ( 0 ..1 ) ) ;
104- assert ! ( err. is_some( ) , "U32 -> U16 should be unsafe narrowing" ) ;
105- assert_eq ! ( err. unwrap( ) . code, "A10102" ) ;
104+ assert_eq ! (
105+ err. expect( "U32 -> U16 should be unsafe narrowing" ) . code,
106+ "A10102"
107+ ) ;
106108}
107109
108110#[ test]
@@ -121,8 +123,10 @@ fn fixed_width_signed_unsigned_comparison() {
121123 & Type :: U32 ,
122124 & ( 0 ..1 ) ,
123125 ) ;
124- assert ! ( err. is_some( ) , "I32 vs U32 comparison should warn" ) ;
125- assert_eq ! ( err. unwrap( ) . code, "A10103" ) ;
126+ assert_eq ! (
127+ err. expect( "I32 vs U32 comparison should warn" ) . code,
128+ "A10103"
129+ ) ;
126130}
127131
128132#[ test]
@@ -141,8 +145,10 @@ fn fixed_width_same_signedness_ok() {
141145fn fixed_width_division_by_zero ( ) {
142146 let rhs = Spanned :: no_span ( AstExpr :: Literal ( AstLit :: Int ( "0" . into ( ) ) ) ) ;
143147 let err = FixedWidthChecker :: check_division_by_zero ( & AstBinOp :: Div , & rhs, & Type :: U32 , & ( 0 ..1 ) ) ;
144- assert ! ( err. is_some( ) , "division by literal 0 should be flagged" ) ;
145- assert_eq ! ( err. unwrap( ) . code, "A10104" ) ;
148+ assert_eq ! (
149+ err. expect( "division by literal 0 should be flagged" ) . code,
150+ "A10104"
151+ ) ;
146152}
147153
148154#[ test]
@@ -181,8 +187,10 @@ fn fixed_width_cast_i32_to_u32() {
181187 // I32 -> U32: signed-to-unsigned, range [-2^31, 2^31-1] does not
182188 // fit in [0, 2^32-1] because of negative values -> unsafe
183189 let err = FixedWidthChecker :: check_cast_safety ( & Type :: I32 , & Type :: U32 , & ( 0 ..1 ) ) ;
184- assert ! ( err. is_some( ) , "I32 -> U32 cast should be unsafe" ) ;
185- assert_eq ! ( err. unwrap( ) . code, "A10102" ) ;
190+ assert_eq ! (
191+ err. expect( "I32 -> U32 cast should be unsafe" ) . code,
192+ "A10102"
193+ ) ;
186194}
187195
188196#[ test]
@@ -222,8 +230,7 @@ fn fixed_width_check_binop_combined() {
222230fn fixed_width_modulo_by_zero ( ) {
223231 let rhs = Spanned :: no_span ( AstExpr :: Literal ( AstLit :: Int ( "0" . into ( ) ) ) ) ;
224232 let err = FixedWidthChecker :: check_division_by_zero ( & AstBinOp :: Mod , & rhs, & Type :: I32 , & ( 0 ..1 ) ) ;
225- assert ! ( err. is_some( ) , "modulo by zero should be flagged" ) ;
226- let e = err. unwrap ( ) ;
233+ let e = err. expect ( "modulo by zero should be flagged" ) ;
227234 assert_eq ! ( e. code, "A10104" ) ;
228235 assert ! ( e. message. contains( "modulo" ) ) ;
229236}
@@ -233,8 +240,10 @@ fn fixed_width_sub_overflow_unsigned() {
233240 // U8 - U8: 0 - 255 = -255 < 0 -> overflow (underflow)
234241 let checker = FixedWidthChecker :: new ( ) ;
235242 let err = checker. check_arithmetic_overflow ( & AstBinOp :: Sub , & Type :: U8 , & Type :: U8 , & ( 0 ..1 ) ) ;
236- assert ! ( err. is_some( ) , "U8 - U8 should detect potential underflow" ) ;
237- assert_eq ! ( err. unwrap( ) . code, "A10101" ) ;
243+ assert_eq ! (
244+ err. expect( "U8 - U8 should detect potential underflow" ) . code,
245+ "A10101"
246+ ) ;
238247}
239248
240249#[ test]
0 commit comments