diff options
| author | Ayaz Hafiz <ayaz.hafiz.1@gmail.com> | 2020-06-13 22:31:31 -0700 |
|---|---|---|
| committer | Ayaz Hafiz <ayaz.hafiz.1@gmail.com> | 2020-06-13 22:31:31 -0700 |
| commit | 2b936bb5a26f1f10daa5a6c5ed546dd274995942 (patch) | |
| tree | 920a57289fac87c7a82168d25f15fce0951b3268 | |
| parent | afbbd383ccee8b91b1d1bbdcfb0f7a906bba71f7 (diff) | |
| download | rust-2b936bb5a26f1f10daa5a6c5ed546dd274995942.tar.gz rust-2b936bb5a26f1f10daa5a6c5ed546dd274995942.zip | |
fixup! Note numeric literals that can never fit in an expected type
| -rw-r--r-- | src/librustc_typeck/check/demand.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/numeric/numeric-cast-no-fix.stderr | 10 | ||||
| -rw-r--r-- | src/test/ui/repeat_count.stderr | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 7fc880b6c7c..79fc9772423 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -833,7 +833,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // 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 { diff --git a/src/test/ui/numeric/numeric-cast-no-fix.stderr b/src/test/ui/numeric/numeric-cast-no-fix.stderr index 51e263d636f..63b563aafb6 100644 --- a/src/test/ui/numeric/numeric-cast-no-fix.stderr +++ b/src/test/ui/numeric/numeric-cast-no-fix.stderr @@ -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; diff --git a/src/test/ui/repeat_count.stderr b/src/test/ui/repeat_count.stderr index a1d5b36931d..34641be2215 100644 --- a/src/test/ui/repeat_count.stderr +++ b/src/test/ui/repeat_count.stderr @@ -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]; |
