You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/ui/cast.stderr
+42-42Lines changed: 42 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -194,7 +194,7 @@ error: casting `u8` to `i8` may wrap around the value
194
194
--> tests/ui/cast.rs:88:5
195
195
|
196
196
LL | 1u8 as i8;
197
-
| ^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1u8.cast_signed()`
197
+
| ^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `1u8.cast_signed()`
198
198
|
199
199
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
200
200
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
@@ -203,25 +203,25 @@ error: casting `u16` to `i16` may wrap around the value
203
203
--> tests/ui/cast.rs:91:5
204
204
|
205
205
LL | 1u16 as i16;
206
-
| ^^^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1u16.cast_signed()`
206
+
| ^^^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `1u16.cast_signed()`
207
207
208
208
error: casting `u32` to `i32` may wrap around the value
209
209
--> tests/ui/cast.rs:94:5
210
210
|
211
211
LL | 1u32 as i32;
212
-
| ^^^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1u32.cast_signed()`
212
+
| ^^^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `1u32.cast_signed()`
213
213
214
214
error: casting `u64` to `i64` may wrap around the value
215
215
--> tests/ui/cast.rs:97:5
216
216
|
217
217
LL | 1u64 as i64;
218
-
| ^^^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1u64.cast_signed()`
218
+
| ^^^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `1u64.cast_signed()`
219
219
220
220
error: casting `usize` to `isize` may wrap around the value
221
221
--> tests/ui/cast.rs:100:5
222
222
|
223
223
LL | 1usize as isize;
224
-
| ^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1usize.cast_signed()`
224
+
| ^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `1usize.cast_signed()`
225
225
226
226
error: casting `usize` to `i8` may truncate the value
227
227
--> tests/ui/cast.rs:104:5
@@ -321,43 +321,43 @@ error: casting `i32` to `u32` may lose the sign of the value
321
321
--> tests/ui/cast.rs:138:5
322
322
|
323
323
LL | -1i32 as u32;
324
-
| ^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-1i32).cast_unsigned()`
324
+
| ^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-1i32).cast_unsigned()`
325
325
326
326
error: casting `isize` to `usize` may lose the sign of the value
327
327
--> tests/ui/cast.rs:142:5
328
328
|
329
329
LL | -1isize as usize;
330
-
| ^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-1isize).cast_unsigned()`
330
+
| ^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-1isize).cast_unsigned()`
331
331
332
332
error: casting `i8` to `u8` may lose the sign of the value
333
333
--> tests/ui/cast.rs:154:5
334
334
|
335
335
LL | (i8::MIN).abs() as u8;
336
-
| ^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(i8::MIN).abs().cast_unsigned()`
336
+
| ^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(i8::MIN).abs().cast_unsigned()`
337
337
338
338
error: casting `i64` to `u64` may lose the sign of the value
339
339
--> tests/ui/cast.rs:159:5
340
340
|
341
341
LL | (-1i64).abs() as u64;
342
-
| ^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-1i64).abs().cast_unsigned()`
342
+
| ^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-1i64).abs().cast_unsigned()`
343
343
344
344
error: casting `isize` to `usize` may lose the sign of the value
345
345
--> tests/ui/cast.rs:161:5
346
346
|
347
347
LL | (-1isize).abs() as usize;
348
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-1isize).abs().cast_unsigned()`
348
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-1isize).abs().cast_unsigned()`
349
349
350
350
error: casting `i64` to `u64` may lose the sign of the value
351
351
--> tests/ui/cast.rs:169:5
352
352
|
353
353
LL | (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64;
354
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(unsafe { (-1i64).checked_abs().unwrap_unchecked() }).cast_unsigned()`
354
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(unsafe { (-1i64).checked_abs().unwrap_unchecked() }).cast_unsigned()`
355
355
356
356
error: casting `i64` to `u64` may lose the sign of the value
357
357
--> tests/ui/cast.rs:185:5
358
358
|
359
359
LL | (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64;
360
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }).cast_unsigned()`
360
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }).cast_unsigned()`
361
361
362
362
error: casting `i64` to `i8` may truncate the value
363
363
--> tests/ui/cast.rs:237:5
@@ -495,79 +495,79 @@ error: casting `i32` to `u32` may lose the sign of the value
495
495
--> tests/ui/cast.rs:438:9
496
496
|
497
497
LL | (x * x) as u32;
498
-
| ^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(x * x).cast_unsigned()`
498
+
| ^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(x * x).cast_unsigned()`
499
499
500
500
error: casting `i32` to `u32` may lose the sign of the value
501
501
--> tests/ui/cast.rs:444:32
502
502
|
503
503
LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 };
504
-
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(x * x * x * x).cast_unsigned()`
504
+
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(x * x * x * x).cast_unsigned()`
505
505
506
506
error: casting `i32` to `u32` may lose the sign of the value
507
507
--> tests/ui/cast.rs:447:5
508
508
|
509
509
LL | (2_i32).checked_pow(3).unwrap() as u32;
510
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(2_i32).checked_pow(3).unwrap().cast_unsigned()`
510
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(2_i32).checked_pow(3).unwrap().cast_unsigned()`
511
511
512
512
error: casting `i32` to `u32` may lose the sign of the value
513
513
--> tests/ui/cast.rs:449:5
514
514
|
515
515
LL | (-2_i32).pow(3) as u32;
516
-
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-2_i32).pow(3).cast_unsigned()`
516
+
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-2_i32).pow(3).cast_unsigned()`
517
517
518
518
error: casting `i32` to `u32` may lose the sign of the value
519
519
--> tests/ui/cast.rs:454:5
520
520
|
521
521
LL | (-5_i32 % 2) as u32;
522
-
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-5_i32 % 2).cast_unsigned()`
522
+
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-5_i32 % 2).cast_unsigned()`
523
523
524
524
error: casting `i32` to `u32` may lose the sign of the value
525
525
--> tests/ui/cast.rs:457:5
526
526
|
527
527
LL | (-5_i32 % -2) as u32;
528
-
| ^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-5_i32 % -2).cast_unsigned()`
528
+
| ^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-5_i32 % -2).cast_unsigned()`
529
529
530
530
error: casting `i32` to `u32` may lose the sign of the value
531
531
--> tests/ui/cast.rs:461:5
532
532
|
533
533
LL | (-2_i32 >> 1) as u32;
534
-
| ^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(-2_i32 >> 1).cast_unsigned()`
534
+
| ^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(-2_i32 >> 1).cast_unsigned()`
535
535
536
536
error: casting `i32` to `u32` may lose the sign of the value
537
537
--> tests/ui/cast.rs:465:5
538
538
|
539
539
LL | (x * x) as u32;
540
-
| ^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(x * x).cast_unsigned()`
540
+
| ^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(x * x).cast_unsigned()`
541
541
542
542
error: casting `i32` to `u32` may lose the sign of the value
543
543
--> tests/ui/cast.rs:467:5
544
544
|
545
545
LL | (x * x * x) as u32;
546
-
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(x * x * x).cast_unsigned()`
546
+
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(x * x * x).cast_unsigned()`
547
547
548
548
error: casting `i16` to `u16` may lose the sign of the value
549
549
--> tests/ui/cast.rs:471:5
550
550
|
551
551
LL | (y * y * y * y * -2) as u16;
552
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(y * y * y * y * -2).cast_unsigned()`
552
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(y * y * y * y * -2).cast_unsigned()`
553
553
554
554
error: casting `i16` to `u16` may lose the sign of the value
555
555
--> tests/ui/cast.rs:474:5
556
556
|
557
557
LL | (y * y * y / y * 2) as u16;
558
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(y * y * y / y * 2).cast_unsigned()`
558
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(y * y * y / y * 2).cast_unsigned()`
559
559
560
560
error: casting `i16` to `u16` may lose the sign of the value
561
561
--> tests/ui/cast.rs:476:5
562
562
|
563
563
LL | (y * y / y * 2) as u16;
564
-
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(y * y / y * 2).cast_unsigned()`
564
+
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(y * y / y * 2).cast_unsigned()`
565
565
566
566
error: casting `i16` to `u16` may lose the sign of the value
567
567
--> tests/ui/cast.rs:479:5
568
568
|
569
569
LL | (y / y * y * -2) as u16;
570
-
| ^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(y / y * y * -2).cast_unsigned()`
570
+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(y / y * y * -2).cast_unsigned()`
571
571
572
572
error: equal expressions as operands to `/`
573
573
--> tests/ui/cast.rs:479:6
@@ -581,97 +581,97 @@ error: casting `i16` to `u16` may lose the sign of the value
581
581
--> tests/ui/cast.rs:483:5
582
582
|
583
583
LL | (y + y + y + -2) as u16;
584
-
| ^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(y + y + y + -2).cast_unsigned()`
584
+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(y + y + y + -2).cast_unsigned()`
585
585
586
586
error: casting `i16` to `u16` may lose the sign of the value
587
587
--> tests/ui/cast.rs:486:5
588
588
|
589
589
LL | (y + y + y + 2) as u16;
590
-
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(y + y + y + 2).cast_unsigned()`
590
+
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(y + y + y + 2).cast_unsigned()`
591
591
592
592
error: casting `i16` to `u16` may lose the sign of the value
593
593
--> tests/ui/cast.rs:490:5
594
594
|
595
595
LL | (z + -2) as u16;
596
-
| ^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(z + -2).cast_unsigned()`
596
+
| ^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(z + -2).cast_unsigned()`
597
597
598
598
error: casting `i16` to `u16` may lose the sign of the value
599
599
--> tests/ui/cast.rs:493:5
600
600
|
601
601
LL | (z + z + 2) as u16;
602
-
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(z + z + 2).cast_unsigned()`
602
+
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(z + z + 2).cast_unsigned()`
603
603
604
604
error: casting `i32` to `u32` may lose the sign of the value
605
605
--> tests/ui/cast.rs:497:9
606
606
|
607
607
LL | (a * a * b * b * c * c) as u32;
608
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a * a * b * b * c * c).cast_unsigned()`
608
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a * a * b * b * c * c).cast_unsigned()`
609
609
610
610
error: casting `i32` to `u32` may lose the sign of the value
611
611
--> tests/ui/cast.rs:499:9
612
612
|
613
613
LL | (a * b * c) as u32;
614
-
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a * b * c).cast_unsigned()`
614
+
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a * b * c).cast_unsigned()`
615
615
616
616
error: casting `i32` to `u32` may lose the sign of the value
617
617
--> tests/ui/cast.rs:502:9
618
618
|
619
619
LL | (a * -b * c) as u32;
620
-
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a * -b * c).cast_unsigned()`
620
+
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a * -b * c).cast_unsigned()`
621
621
622
622
error: casting `i32` to `u32` may lose the sign of the value
623
623
--> tests/ui/cast.rs:505:9
624
624
|
625
625
LL | (a * b * c * c) as u32;
626
-
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a * b * c * c).cast_unsigned()`
626
+
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a * b * c * c).cast_unsigned()`
627
627
628
628
error: casting `i32` to `u32` may lose the sign of the value
629
629
--> tests/ui/cast.rs:507:9
630
630
|
631
631
LL | (a * -2) as u32;
632
-
| ^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a * -2).cast_unsigned()`
632
+
| ^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a * -2).cast_unsigned()`
633
633
634
634
error: casting `i32` to `u32` may lose the sign of the value
635
635
--> tests/ui/cast.rs:510:9
636
636
|
637
637
LL | (a * b * c * -2) as u32;
638
-
| ^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a * b * c * -2).cast_unsigned()`
638
+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a * b * c * -2).cast_unsigned()`
639
639
640
640
error: casting `i32` to `u32` may lose the sign of the value
641
641
--> tests/ui/cast.rs:513:9
642
642
|
643
643
LL | (a / b) as u32;
644
-
| ^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a / b).cast_unsigned()`
644
+
| ^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a / b).cast_unsigned()`
645
645
646
646
error: casting `i32` to `u32` may lose the sign of the value
647
647
--> tests/ui/cast.rs:515:9
648
648
|
649
649
LL | (a / b * c) as u32;
650
-
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a / b * c).cast_unsigned()`
650
+
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a / b * c).cast_unsigned()`
651
651
652
652
error: casting `i32` to `u32` may lose the sign of the value
653
653
--> tests/ui/cast.rs:518:9
654
654
|
655
655
LL | (a / b + b * c) as u32;
656
-
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a / b + b * c).cast_unsigned()`
656
+
| ^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a / b + b * c).cast_unsigned()`
657
657
658
658
error: casting `i32` to `u32` may lose the sign of the value
659
659
--> tests/ui/cast.rs:521:9
660
660
|
661
661
LL | a.saturating_pow(3) as u32;
662
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `a.saturating_pow(3).cast_unsigned()`
662
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `a.saturating_pow(3).cast_unsigned()`
663
663
664
664
error: casting `i32` to `u32` may lose the sign of the value
665
665
--> tests/ui/cast.rs:524:9
666
666
|
667
667
LL | (a.abs() * b.pow(2) / c.abs()) as u32
668
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `(a.abs() * b.pow(2) / c.abs()).cast_unsigned()`
668
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `(a.abs() * b.pow(2) / c.abs()).cast_unsigned()`
669
669
670
670
error: casting `i32` to `u32` may lose the sign of the value
671
671
--> tests/ui/cast.rs:532:21
672
672
|
673
673
LL | let _ = i32::MIN as u32; // cast_sign_loss
674
-
| ^^^^^^^^^^^^^^^ help: if this is intentional, consider using `cast_unsigned()` instead: `i32::MIN.cast_unsigned()`
674
+
| ^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_unsigned()` instead: `i32::MIN.cast_unsigned()`
675
675
...
676
676
LL | m!();
677
677
| ---- in this macro invocation
@@ -756,7 +756,7 @@ error: casting `u8` to `i8` may wrap around the value
756
756
--> tests/ui/cast.rs:576:13
757
757
|
758
758
LL | _ = 1u8 as i8;
759
-
| ^^^^^^^^^ help: if this is intentional, consider using `cast_signed()` instead: `1u8.cast_signed()`
759
+
| ^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `1u8.cast_signed()`
760
760
761
761
error: casting `u8` to `i8` may wrap around the value
0 commit comments