Skip to content

Commit

Permalink
Reword casting message
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed May 3, 2019
1 parent ef9a876 commit 1e2af7d
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 115 deletions.
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/indexing-requires-a-uint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
36 changes: 18 additions & 18 deletions src/test/ui/integer-literal-suffix-inference.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-13359.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-31910.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mismatched_types/issue-26480.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/numeric/const-scope.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/numeric/len.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/numeric/numeric-cast-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading

0 comments on commit 1e2af7d

Please sign in to comment.