From 2b936bb5a26f1f10daa5a6c5ed546dd274995942 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Sat, 13 Jun 2020 22:31:31 -0700 Subject: [PATCH] fixup! Note numeric literals that can never fit in an expected type --- src/librustc_typeck/check/demand.rs | 2 +- src/test/ui/numeric/numeric-cast-no-fix.stderr | 10 +++++----- 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 7fc880b6c7c6c..79fc9772423fd 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 51e263d636f98..63b563aafb6de 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 a1d5b36931dac..34641be22150f 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];