]> git.lizzy.rs Git - rust.git/commitdiff
fixup! Note numeric literals that can never fit in an expected type
authorAyaz Hafiz <ayaz.hafiz.1@gmail.com>
Sun, 14 Jun 2020 05:31:31 +0000 (22:31 -0700)
committerAyaz Hafiz <ayaz.hafiz.1@gmail.com>
Sun, 14 Jun 2020 05:31:31 +0000 (22:31 -0700)
src/librustc_typeck/check/demand.rs
src/test/ui/numeric/numeric-cast-no-fix.stderr
src/test/ui/repeat_count.stderr

index 7fc880b6c7c6c13de3a9dd8f0728805322600a29..79fc9772423fd7a75e73991bb229dd5406cfaa80 100644 (file)
@@ -833,7 +833,7 @@ pub fn check_for_cast(
                     // We now know that converting either the lhs or rhs is fallible. Before we
                     // suggest a fallible conversion, check if the value can never fit in the
                     // expected type.
-                    let msg = format!("`{}` can never fit into `{}`", src, expected_ty);
+                    let msg = format!("`{}` cannot fit into type `{}`", src, expected_ty);
                     err.span_note(expr.span, &msg);
                     return;
                 } else if in_const_context {
index 51e263d636f98564448163ce92650d402c4ee87f..63b563aafb6def8712bc138d9d48596ad1e4f182 100644 (file)
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     x_usize > -1_isize;
    |               ^^^^^^^^ expected `usize`, found `isize`
    |
-note: `-1_isize` can never fit into `usize`
+note: `-1_isize` cannot fit into type `usize`
   --> $DIR/numeric-cast-no-fix.rs:10:15
    |
 LL |     x_usize > -1_isize;
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
 LL |     x_u128 > -1_isize;
    |              ^^^^^^^^ expected `u128`, found `isize`
    |
-note: `-1_isize` can never fit into `u128`
+note: `-1_isize` cannot fit into type `u128`
   --> $DIR/numeric-cast-no-fix.rs:12:14
    |
 LL |     x_u128 > -1_isize;
@@ -28,7 +28,7 @@ error[E0308]: mismatched types
 LL |     x_u64 > -1_isize;
    |             ^^^^^^^^ expected `u64`, found `isize`
    |
-note: `-1_isize` can never fit into `u64`
+note: `-1_isize` cannot fit into type `u64`
   --> $DIR/numeric-cast-no-fix.rs:14:13
    |
 LL |     x_u64 > -1_isize;
@@ -40,7 +40,7 @@ error[E0308]: mismatched types
 LL |     x_u32 > -1_isize;
    |             ^^^^^^^^ expected `u32`, found `isize`
    |
-note: `-1_isize` can never fit into `u32`
+note: `-1_isize` cannot fit into type `u32`
   --> $DIR/numeric-cast-no-fix.rs:16:13
    |
 LL |     x_u32 > -1_isize;
@@ -52,7 +52,7 @@ error[E0308]: mismatched types
 LL |     x_u16 > -1_isize;
    |             ^^^^^^^^ expected `u16`, found `isize`
    |
-note: `-1_isize` can never fit into `u16`
+note: `-1_isize` cannot fit into type `u16`
   --> $DIR/numeric-cast-no-fix.rs:18:13
    |
 LL |     x_u16 > -1_isize;
index a1d5b36931dacebe06fa3326f5467097de0f25f2..34641be22150f247b2e3fdb743904b5dcd205402 100644 (file)
@@ -40,7 +40,7 @@ error[E0308]: mismatched types
 LL |     let f = [0; -4_isize];
    |                 ^^^^^^^^ expected `usize`, found `isize`
    |
-note: `-4_isize` can never fit into `usize`
+note: `-4_isize` cannot fit into type `usize`
   --> $DIR/repeat_count.rs:19:17
    |
 LL |     let f = [0; -4_isize];
@@ -52,7 +52,7 @@ error[E0308]: mismatched types
 LL |     let f = [0_usize; -1_isize];
    |                       ^^^^^^^^ expected `usize`, found `isize`
    |
-note: `-1_isize` can never fit into `usize`
+note: `-1_isize` cannot fit into type `usize`
   --> $DIR/repeat_count.rs:22:23
    |
 LL |     let f = [0_usize; -1_isize];