Skip to content
Permalink
Browse files

Reword casting message

  • Loading branch information...
estebank committed May 3, 2019
1 parent ef9a876 commit 1e2af7d9353eef2115210bfe296744373e70e3a4
@@ -523,7 +523,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let msg = format!("you can convert an `{}` to `{}`", checked_ty, expected_ty);
let cast_msg = format!("you can cast an `{} to `{}`", checked_ty, expected_ty);
let try_msg = format!("{} or panic if it the converted value wouldn't fit", msg);
let try_msg = format!("{} and panic if the converted value wouldn't fit", msg);
let lit_msg = format!(
"change the type of the numeric literal from `{}` to `{}`",
checked_ty,
@@ -49,7 +49,7 @@ error[E0308]: mismatched types
|
LL | let _: i32 = f2(2i32);
| ^^^^^^^^ expected i32, found u32
help: you can convert an `u32` to `i32` or panic if it the converted value wouldn't fit
help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit
|
LL | let _: i32 = f2(2i32).try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ error[E0308]: mismatched types
|
LL | bar::<isize>(i); // i should not be re-coerced back to an isize
| ^ expected isize, found usize
help: you can convert an `usize` to `isize` or panic if it the converted value wouldn't fit
help: you can convert an `usize` to `isize` and panic if the converted value wouldn't fit
|
LL | bar::<isize>(i.try_into().unwrap()); // i should not be re-coerced back to an isize
| ^^^^^^^^^^^^^^^^^^^^^
@@ -3,7 +3,7 @@ error[E0308]: mismatched types
|
LL | id_i8(a16);
| ^^^ expected i8, found i16
help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit
|
LL | id_i8(a16.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
|
LL | id_i8(a32);
| ^^^ expected i8, found i32
help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit
|
LL | id_i8(a32.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ error[E0308]: mismatched types
|
LL | id_i8(a64);
| ^^^ expected i8, found i64
help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit
|
LL | id_i8(a64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -42,7 +42,7 @@ error[E0308]: mismatched types
|
LL | id_i16(a32);
| ^^^ expected i16, found i32
help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit
|
LL | id_i16(a32.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -52,7 +52,7 @@ error[E0308]: mismatched types
|
LL | id_i16(a64);
| ^^^ expected i16, found i64
help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit
help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit
|
LL | id_i16(a64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -80,7 +80,7 @@ error[E0308]: mismatched types
|
LL | id_i32(a64);
| ^^^ expected i32, found i64
help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit
help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit
|
LL | id_i32(a64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -117,7 +117,7 @@ error[E0308]: mismatched types
|
LL | id_i8(c16);
| ^^^ expected i8, found i16
help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit
|
LL | id_i8(c16.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -127,7 +127,7 @@ error[E0308]: mismatched types
|
LL | id_i8(c32);
| ^^^ expected i8, found i32
help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit
|
LL | id_i8(c32.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -137,7 +137,7 @@ error[E0308]: mismatched types
|
LL | id_i8(c64);
| ^^^ expected i8, found i64
help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit
|
LL | id_i8(c64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -156,7 +156,7 @@ error[E0308]: mismatched types
|
LL | id_i16(c32);
| ^^^ expected i16, found i32
help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit
|
LL | id_i16(c32.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -166,7 +166,7 @@ error[E0308]: mismatched types
|
LL | id_i16(c64);
| ^^^ expected i16, found i64
help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit
help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit
|
LL | id_i16(c64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -194,7 +194,7 @@ error[E0308]: mismatched types
|
LL | id_i32(c64);
| ^^^ expected i32, found i64
help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit
help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit
|
LL | id_i32(c64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -231,7 +231,7 @@ error[E0308]: mismatched types
|
LL | id_u8(b16);
| ^^^ expected u8, found u16
help: you can convert an `u16` to `u8` or panic if it the converted value wouldn't fit
help: you can convert an `u16` to `u8` and panic if the converted value wouldn't fit
|
LL | id_u8(b16.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -241,7 +241,7 @@ error[E0308]: mismatched types
|
LL | id_u8(b32);
| ^^^ expected u8, found u32
help: you can convert an `u32` to `u8` or panic if it the converted value wouldn't fit
help: you can convert an `u32` to `u8` and panic if the converted value wouldn't fit
|
LL | id_u8(b32.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -251,7 +251,7 @@ error[E0308]: mismatched types
|
LL | id_u8(b64);
| ^^^ expected u8, found u64
help: you can convert an `u64` to `u8` or panic if it the converted value wouldn't fit
help: you can convert an `u64` to `u8` and panic if the converted value wouldn't fit
|
LL | id_u8(b64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -270,7 +270,7 @@ error[E0308]: mismatched types
|
LL | id_u16(b32);
| ^^^ expected u16, found u32
help: you can convert an `u32` to `u16` or panic if it the converted value wouldn't fit
help: you can convert an `u32` to `u16` and panic if the converted value wouldn't fit
|
LL | id_u16(b32.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -280,7 +280,7 @@ error[E0308]: mismatched types
|
LL | id_u16(b64);
| ^^^ expected u16, found u64
help: you can convert an `u64` to `u16` or panic if it the converted value wouldn't fit
help: you can convert an `u64` to `u16` and panic if the converted value wouldn't fit
|
LL | id_u16(b64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -308,7 +308,7 @@ error[E0308]: mismatched types
|
LL | id_u32(b64);
| ^^^ expected u32, found u64
help: you can convert an `u64` to `u32` or panic if it the converted value wouldn't fit
help: you can convert an `u64` to `u32` and panic if the converted value wouldn't fit
|
LL | id_u32(b64.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -3,7 +3,7 @@ error[E0308]: mismatched types
|
LL | foo(1*(1 as isize));
| ^^^^^^^^^^^^^^ expected i16, found isize
help: you can convert an `isize` to `i16` or panic if it the converted value wouldn't fit
help: you can convert an `isize` to `i16` and panic if the converted value wouldn't fit
|
LL | foo((1*(1 as isize)).try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
|
LL | bar(1*(1 as usize));
| ^^^^^^^^^^^^^^ expected u32, found usize
help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit
help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit
|
LL | bar((1*(1 as usize)).try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -3,7 +3,7 @@ error[E0308]: mismatched types
|
LL | X = Trait::Number,
| ^^^^^^^^^^^^^ expected isize, found i32
help: you can convert an `i32` to `isize` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit
|
LL | X = Trait::Number.try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -11,7 +11,7 @@ error[E0308]: mismatched types
|
LL | let y: usize = x.foo();
| ^^^^^^^ expected usize, found isize
help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit
help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit
|
LL | let y: usize = x.foo().try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -6,7 +6,7 @@ LL | $arr.len() * size_of($arr[0]));
...
LL | write!(hello);
| -------------- in this macro invocation
help: you can convert an `usize` to `u64` or panic if it the converted value wouldn't fit
help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit
|
LL | ($arr.len() * size_of($arr[0])).try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -37,7 +37,7 @@ error[E0308]: mismatched types
|
LL | let d: i8 = c;
| ^ expected i8, found i32
help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit
|
LL | let d: i8 = c.try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^
@@ -3,7 +3,7 @@ error[E0308]: mismatched types
|
LL | test(array.len());
| ^^^^^^^^^^^ expected u32, found usize
help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit
help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit
|
LL | test(array.len().try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -3,7 +3,7 @@ error[E0308]: mismatched types
|
LL | let x: u16 = foo();
| ^^^^^ expected u16, found i32
help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit
help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit
|
LL | let x: u16 = foo().try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
|
LL | let y: i64 = x + x;
| ^^^^^ expected i64, found u16
help: you can convert an `u16` to `i64` or panic if it the converted value wouldn't fit
help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit
|
LL | let y: i64 = (x + x).try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ error[E0308]: mismatched types
|
LL | let z: i32 = x + x;
| ^^^^^ expected i32, found u16
help: you can convert an `u16` to `i32` or panic if it the converted value wouldn't fit
help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit
|
LL | let z: i32 = (x + x).try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oops, something went wrong.

0 comments on commit 1e2af7d

Please sign in to comment.
You can’t perform that action at this time.