Skip to content

Commit

Permalink
fixup! Note numeric literals that can never fit in an expected type
Browse files Browse the repository at this point in the history
  • Loading branch information
ayazhafiz committed Jun 14, 2020
1 parent afbbd38 commit 2b936bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/demand.rs
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/numeric/numeric-cast-no-fix.stderr
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/repeat_count.stderr
Expand Up @@ -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];
Expand All @@ -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];
Expand Down

0 comments on commit 2b936bb

Please sign in to comment.