Skip to content

Commit 47339d0

Browse files
committed
Bless fixed cast_sign_loss false negatives
1 parent 28f247e commit 47339d0

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

tests/ui/cast.stderr

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,36 @@ error: casting `isize` to `usize` may lose the sign of the value
321321
LL | -1isize as usize;
322322
| ^^^^^^^^^^^^^^^^
323323

324+
error: casting `i8` to `u8` may lose the sign of the value
325+
--> tests/ui/cast.rs:119:5
326+
|
327+
LL | (-1i8).abs() as u8;
328+
| ^^^^^^^^^^^^^^^^^^
329+
330+
error: casting `i16` to `u16` may lose the sign of the value
331+
--> tests/ui/cast.rs:120:5
332+
|
333+
LL | (-1i16).abs() as u16;
334+
| ^^^^^^^^^^^^^^^^^^^^
335+
336+
error: casting `i32` to `u32` may lose the sign of the value
337+
--> tests/ui/cast.rs:121:5
338+
|
339+
LL | (-1i32).abs() as u32;
340+
| ^^^^^^^^^^^^^^^^^^^^
341+
342+
error: casting `i64` to `u64` may lose the sign of the value
343+
--> tests/ui/cast.rs:122:5
344+
|
345+
LL | (-1i64).abs() as u64;
346+
| ^^^^^^^^^^^^^^^^^^^^
347+
348+
error: casting `isize` to `usize` may lose the sign of the value
349+
--> tests/ui/cast.rs:123:5
350+
|
351+
LL | (-1isize).abs() as usize;
352+
| ^^^^^^^^^^^^^^^^^^^^^^^^
353+
324354
error: casting `i64` to `i8` may truncate the value
325355
--> tests/ui/cast.rs:179:5
326356
|
@@ -444,12 +474,36 @@ help: ... or use `try_from` and handle the error accordingly
444474
LL | let c = u8::try_from(q / 1000);
445475
| ~~~~~~~~~~~~~~~~~~~~~~
446476

477+
error: casting `i32` to `u32` may lose the sign of the value
478+
--> tests/ui/cast.rs:372:9
479+
|
480+
LL | (x * x) as u32;
481+
| ^^^^^^^^^^^^^^
482+
483+
error: casting `i32` to `u32` may lose the sign of the value
484+
--> tests/ui/cast.rs:373:9
485+
|
486+
LL | x.pow(2) as u32;
487+
| ^^^^^^^^^^^^^^^
488+
489+
error: casting `i32` to `u32` may lose the sign of the value
490+
--> tests/ui/cast.rs:377:32
491+
|
492+
LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 };
493+
| ^^^^^^^^^^^^^^^^^^^^^^
494+
447495
error: casting `i32` to `u32` may lose the sign of the value
448496
--> tests/ui/cast.rs:379:5
449497
|
450498
LL | (-2_i32).pow(3) as u32;
451499
| ^^^^^^^^^^^^^^^^^^^^^^
452500

501+
error: casting `i32` to `u32` may lose the sign of the value
502+
--> tests/ui/cast.rs:383:5
503+
|
504+
LL | (x * x) as u32;
505+
| ^^^^^^^^^^^^^^
506+
453507
error: casting `i32` to `u32` may lose the sign of the value
454508
--> tests/ui/cast.rs:384:5
455509
|
@@ -462,6 +516,12 @@ error: casting `i16` to `u16` may lose the sign of the value
462516
LL | (y * y * y * y * -2) as u16;
463517
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
464518

519+
error: casting `i16` to `u16` may lose the sign of the value
520+
--> tests/ui/cast.rs:390:5
521+
|
522+
LL | (y * y * y * y * 2) as u16;
523+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
524+
465525
error: casting `i16` to `u16` may lose the sign of the value
466526
--> tests/ui/cast.rs:391:5
467527
|
@@ -474,6 +534,12 @@ error: casting `i16` to `u16` may lose the sign of the value
474534
LL | (y * y * y * -2) as u16;
475535
| ^^^^^^^^^^^^^^^^^^^^^^^
476536

537+
error: casting `i32` to `u32` may lose the sign of the value
538+
--> tests/ui/cast.rs:397:9
539+
|
540+
LL | (a * a * b * b * c * c) as u32;
541+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
542+
477543
error: casting `i32` to `u32` may lose the sign of the value
478544
--> tests/ui/cast.rs:398:9
479545
|
@@ -486,6 +552,12 @@ error: casting `i32` to `u32` may lose the sign of the value
486552
LL | (a * -b * c) as u32;
487553
| ^^^^^^^^^^^^^^^^^^^
488554

555+
error: casting `i32` to `u32` may lose the sign of the value
556+
--> tests/ui/cast.rs:402:9
557+
|
558+
LL | (a * b * c * c) as u32;
559+
| ^^^^^^^^^^^^^^^^^^^^^^
560+
489561
error: casting `i32` to `u32` may lose the sign of the value
490562
--> tests/ui/cast.rs:403:9
491563
|
@@ -498,6 +570,12 @@ error: casting `i32` to `u32` may lose the sign of the value
498570
LL | (a * b * c * -2) as u32;
499571
| ^^^^^^^^^^^^^^^^^^^^^^^
500572

573+
error: casting `i32` to `u32` may lose the sign of the value
574+
--> tests/ui/cast.rs:407:9
575+
|
576+
LL | (a / b) as u32;
577+
| ^^^^^^^^^^^^^^
578+
501579
error: casting `i32` to `u32` may lose the sign of the value
502580
--> tests/ui/cast.rs:408:9
503581
|
@@ -516,5 +594,11 @@ error: casting `i32` to `u32` may lose the sign of the value
516594
LL | a.pow(3) as u32;
517595
| ^^^^^^^^^^^^^^^
518596

519-
error: aborting due to 63 previous errors
597+
error: casting `i32` to `u32` may lose the sign of the value
598+
--> tests/ui/cast.rs:414:9
599+
|
600+
LL | (a.abs() * b.pow(2) / c.abs()) as u32
601+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
602+
603+
error: aborting due to 77 previous errors
520604

0 commit comments

Comments
 (0)