]> git.lizzy.rs Git - rust.git/commitdiff
Suggest try_into when possible
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 21 Apr 2019 22:44:23 +0000 (15:44 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Mon, 29 Apr 2019 21:38:26 +0000 (14:38 -0700)
36 files changed:
src/librustc_typeck/check/demand.rs
src/test/ui/associated-types/associated-types-path-2.stderr
src/test/ui/discrim/discrim-ill-typed.stderr
src/test/ui/float-literal-inference-restrictions.stderr
src/test/ui/indexing-requires-a-uint.stderr
src/test/ui/integer-literal-suffix-inference.stderr
src/test/ui/issues/issue-13359.stderr
src/test/ui/issues/issue-1362.stderr
src/test/ui/issues/issue-1448-2.stderr
src/test/ui/issues/issue-31910.stderr
src/test/ui/issues/issue-8761.stderr
src/test/ui/meta-expected-error-correct-rev.a.stderr
src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
src/test/ui/mismatched_types/issue-26480.stderr
src/test/ui/numeric/numeric-cast-2.stderr
src/test/ui/numeric/numeric-cast-without-suggestion.rs [new file with mode: 0644]
src/test/ui/numeric/numeric-cast-without-suggestion.stderr [new file with mode: 0644]
src/test/ui/numeric/numeric-cast.fixed [new file with mode: 0644]
src/test/ui/numeric/numeric-cast.rs
src/test/ui/numeric/numeric-cast.stderr
src/test/ui/numeric/numeric-suffix.fixed [new file with mode: 0644]
src/test/ui/numeric/numeric-suffix.rs [new file with mode: 0644]
src/test/ui/numeric/numeric-suffix.stderr [new file with mode: 0644]
src/test/ui/pptypedef.stderr
src/test/ui/repeat_count.stderr
src/test/ui/shift-various-bad-types.stderr
src/test/ui/suggestions/recover-invalid-float.fixed [new file with mode: 0644]
src/test/ui/suggestions/recover-invalid-float.rs
src/test/ui/suggestions/recover-invalid-float.stderr
src/test/ui/suggestions/type-mismatch-struct-field-shorthand-2.stderr
src/test/ui/suggestions/type-mismatch-struct-field-shorthand.stderr
src/test/ui/traits/traits-multidispatch-bad.stderr
src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr
src/test/ui/tutorial-suffix-inference-test.stderr
src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr
src/test/ui/unboxed-closures/unboxed-closures-type-mismatch.stderr

index 6ce03025bf23cd769d556cc4cc77b89ebad8a3ec..6249d6e56af684e32cbfa0de4f128ce6c8d26598 100644 (file)
@@ -559,14 +559,6 @@ pub fn check_for_cast(
             }
         };
 
-        let will_truncate = "will truncate the source value";
-        let depending_on_isize = "will truncate or zero-extend depending on the bit width of \
-                                  `isize`";
-        let depending_on_usize = "will truncate or zero-extend depending on the bit width of \
-                                  `usize`";
-        let will_sign_extend = "will sign-extend the source value";
-        let will_zero_extend = "will zero-extend the source value";
-
         // If casting this expression to a given numeric type would be appropriate in case of a type
         // mismatch.
         //
@@ -596,10 +588,18 @@ pub fn check_for_cast(
             }
         }
 
+        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 lit_msg = format!(
+            "change the type of the numeric literal from `{}` to `{}`",
+            checked_ty,
+            expected_ty,
+        );
+
         let needs_paren = expr.precedence().order() < (PREC_POSTFIX as i8);
 
         if let Ok(src) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
-            let msg = format!("you can cast an `{}` to `{}`", checked_ty, expected_ty);
             let cast_suggestion = format!(
                 "{}{}{}{} as {}",
                 prefix,
@@ -608,6 +608,13 @@ pub fn check_for_cast(
                 if needs_paren { ")" } else { "" },
                 expected_ty,
             );
+            let try_into_suggestion = format!(
+                "{}{}{}{}.try_into().unwrap()",
+                prefix,
+                if needs_paren { "(" } else { "" },
+                src,
+                if needs_paren { ")" } else { "" },
+            );
             let into_suggestion = format!(
                 "{}{}{}{}.into()",
                 prefix,
@@ -615,6 +622,22 @@ pub fn check_for_cast(
                 src,
                 if needs_paren { ")" } else { "" },
             );
+            let suffix_suggestion = format!(
+                "{}{}{}{}",
+                if needs_paren { "(" } else { "" },
+                if let (ty::Int(_), ty::Float(_)) | (ty::Uint(_), ty::Float(_)) = (
+                    &expected_ty.sty,
+                    &checked_ty.sty,
+                ) {
+                    // Remove fractional part from literal, for example `42.0f32` into `42`
+                    let src = src.trim_end_matches(&checked_ty.to_string());
+                    src.split(".").next().unwrap()
+                } else {
+                    src.trim_end_matches(&checked_ty.to_string())
+                },
+                expected_ty,
+                if needs_paren { ")" } else { "" },
+            );
             let literal_is_ty_suffixed = |expr: &hir::Expr| {
                 if let hir::ExprKind::Lit(lit) = &expr.node {
                     lit.node.is_suffixed()
@@ -623,35 +646,24 @@ pub fn check_for_cast(
                 }
             };
 
-            let into_sugg = into_suggestion.clone();
-            let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder<'_>,
-                                                    note: Option<&str>| {
-                let suggest_msg = if literal_is_ty_suffixed(expr) {
-                    format!(
-                        "change the type of the numeric literal from `{}` to `{}`",
-                        checked_ty,
-                        expected_ty,
-                    )
-                } else {
-                    match note {
-                        Some(note) => format!("{}, which {}", msg, note),
-                        _ => format!("{} in a lossless way", msg),
-                    }
-                };
-
-                let suffix_suggestion = format!(
-                    "{}{}{}{}",
-                    if needs_paren { "(" } else { "" },
-                    src.trim_end_matches(&checked_ty.to_string()),
-                    expected_ty,
-                    if needs_paren { ")" } else { "" },
-                );
-
+            let suggest_to_change_suffix_or_into = |
+                err: &mut DiagnosticBuilder<'_>,
+                is_fallible: bool,
+            | {
+                let into_sugg = into_suggestion.clone();
                 err.span_suggestion(
                     expr.span,
-                    &suggest_msg,
                     if literal_is_ty_suffixed(expr) {
-                        suffix_suggestion
+                        &lit_msg
+                    } else if is_fallible {
+                        &try_msg
+                    } else {
+                        &msg
+                    },
+                    if literal_is_ty_suffixed(expr) {
+                        suffix_suggestion.clone()
+                    } else if is_fallible {
+                        try_into_suggestion
                     } else {
                         into_sugg
                     },
@@ -661,188 +673,67 @@ pub fn check_for_cast(
 
             match (&expected_ty.sty, &checked_ty.sty) {
                 (&ty::Int(ref exp), &ty::Int(ref found)) => {
-                    match (found.bit_width(), exp.bit_width()) {
-                        (Some(found), Some(exp)) if found > exp => {
-                            if can_cast {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_truncate),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect // lossy conversion
-                                );
-                            }
-                        }
-                        (None, _) | (_, None) => {
-                            if can_cast {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, depending_on_isize),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect // lossy conversion
-                                );
-                            }
-                        }
-                        _ => {
-                            suggest_to_change_suffix_or_into(
-                                err,
-                                Some(will_sign_extend),
-                            );
-                        }
-                    }
+                    let is_fallible = match (found.bit_width(), exp.bit_width()) {
+                        (Some(found), Some(exp)) if found > exp => true,
+                        (None, _) | (_, None) => true,
+                        _ => false,
+                    };
+                    suggest_to_change_suffix_or_into(err, is_fallible);
                     true
                 }
                 (&ty::Uint(ref exp), &ty::Uint(ref found)) => {
-                    match (found.bit_width(), exp.bit_width()) {
-                        (Some(found), Some(exp)) if found > exp => {
-                            if can_cast {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_truncate),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                        }
-                        (None, _) | (_, None) => {
-                            if can_cast {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, depending_on_usize),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                        }
-                        _ => {
-                           suggest_to_change_suffix_or_into(
-                               err,
-                               Some(will_zero_extend),
-                           );
-                        }
-                    }
+                    let is_fallible = match (found.bit_width(), exp.bit_width()) {
+                        (Some(found), Some(exp)) if found > exp => true,
+                        (None, _) | (_, None) => true,
+                        _ => false,
+                    };
+                    suggest_to_change_suffix_or_into(err, is_fallible);
                     true
                 }
-                (&ty::Int(ref exp), &ty::Uint(ref found)) => {
-                    if can_cast {
-                        match (found.bit_width(), exp.bit_width()) {
-                            (Some(found), Some(exp)) if found > exp - 1 => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_truncate),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            (None, None) => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_truncate),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            (None, _) => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, depending_on_isize),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            (_, None) => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, depending_on_usize),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            _ => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_zero_extend),
-                                    cast_suggestion,
-                                    Applicability::MachineApplicable
-                                );
-                            }
-                        }
-                    }
-                    true
-                }
-                (&ty::Uint(ref exp), &ty::Int(ref found)) => {
-                    if can_cast {
-                        match (found.bit_width(), exp.bit_width()) {
-                            (Some(found), Some(exp)) if found - 1 > exp => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_truncate),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            (None, None) => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_sign_extend),
-                                    cast_suggestion,
-                                    Applicability::MachineApplicable  // lossy conversion
-                                );
-                            }
-                            (None, _) => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, depending_on_usize),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            (_, None) => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, depending_on_isize),
-                                    cast_suggestion,
-                                    Applicability::MaybeIncorrect  // lossy conversion
-                                );
-                            }
-                            _ => {
-                                err.span_suggestion(
-                                    expr.span,
-                                    &format!("{}, which {}", msg, will_sign_extend),
-                                    cast_suggestion,
-                                    Applicability::MachineApplicable
-                                );
-                            }
-                        }
-                    }
+                (&ty::Int(_), &ty::Uint(_)) | (&ty::Uint(_), &ty::Int(_)) => {
+                    suggest_to_change_suffix_or_into(err, true);
                     true
                 }
                 (&ty::Float(ref exp), &ty::Float(ref found)) => {
                     if found.bit_width() < exp.bit_width() {
-                       suggest_to_change_suffix_or_into(
-                           err,
-                           None,
-                       );
-                    } else if can_cast {
+                        suggest_to_change_suffix_or_into(err, false);
+                    } else if literal_is_ty_suffixed(expr) {
                         err.span_suggestion(
                             expr.span,
-                            &format!("{}, producing the closest possible value", msg),
+                            &lit_msg,
+                            suffix_suggestion,
+                            Applicability::MachineApplicable,
+                        );
+                    } else if can_cast { // Missing try_into implementation for `f64` to `f32`
+                        err.span_suggestion(
+                            expr.span,
+                            &format!("{}, producing the closest possible value", cast_msg),
                             cast_suggestion,
-                            Applicability::MaybeIncorrect  // lossy conversion
+                            Applicability::MaybeIncorrect,  // lossy conversion
                         );
                     }
                     true
                 }
                 (&ty::Uint(_), &ty::Float(_)) | (&ty::Int(_), &ty::Float(_)) => {
-                    if can_cast {
+                    if literal_is_ty_suffixed(expr) {
+                        err.span_suggestion(
+                            expr.span,
+                            &lit_msg,
+                            suffix_suggestion,
+                            Applicability::MachineApplicable,
+                        );
+                    } else if can_cast {
+                        // Missing try_into implementation for `{float}` to `{integer}`
                         err.span_suggestion(
                             expr.span,
                             &format!("{}, rounding the float towards zero", msg),
                             cast_suggestion,
                             Applicability::MaybeIncorrect  // lossy conversion
                         );
-                        err.warn("casting here will cause undefined behavior if the rounded value \
-                                  cannot be represented by the target integer type, including \
-                                  `Inf` and `NaN` (this is a bug and will be fixed)");
+                        err.warn("if the rounded value cannot be represented by the target \
+                                  integer type, including `Inf` and `NaN`, casting will cause \
+                                  undefined behavior \
+                                  (https://github.com/rust-lang/rust/issues/10184)");
                     }
                     true
                 }
@@ -851,18 +742,29 @@ pub fn check_for_cast(
                     if exp.bit_width() > found.bit_width().unwrap_or(256) {
                         err.span_suggestion(
                             expr.span,
-                            &format!("{}, producing the floating point representation of the \
-                                      integer",
-                                     msg),
+                            &format!(
+                                "{}, producing the floating point representation of the integer",
+                                msg,
+                            ),
                             into_suggestion,
                             Applicability::MachineApplicable
                         );
-                    } else if can_cast {
+                    } else if literal_is_ty_suffixed(expr) {
+                        err.span_suggestion(
+                            expr.span,
+                            &lit_msg,
+                            suffix_suggestion,
+                            Applicability::MachineApplicable,
+                        );
+                    } else {
+                        // Missing try_into implementation for `{integer}` to `{float}`
                         err.span_suggestion(
                             expr.span,
-                            &format!("{}, producing the floating point representation of the \
-                                      integer, rounded if necessary",
-                                     msg),
+                            &format!(
+                                "{}, producing the floating point representation of the integer,
+                                 rounded if necessary",
+                                cast_msg,
+                            ),
                             cast_suggestion,
                             Applicability::MaybeIncorrect  // lossy conversion
                         );
@@ -874,18 +776,29 @@ pub fn check_for_cast(
                     if exp.bit_width() > found.bit_width().unwrap_or(256) {
                         err.span_suggestion(
                             expr.span,
-                            &format!("{}, producing the floating point representation of the \
-                                      integer",
-                                     msg),
+                            &format!(
+                                "{}, producing the floating point representation of the integer",
+                                &msg,
+                            ),
                             into_suggestion,
                             Applicability::MachineApplicable
                         );
-                    } else if can_cast {
+                    } else if literal_is_ty_suffixed(expr) {
                         err.span_suggestion(
                             expr.span,
-                            &format!("{}, producing the floating point representation of the \
-                                      integer, rounded if necessary",
-                                     msg),
+                            &lit_msg,
+                            suffix_suggestion,
+                            Applicability::MachineApplicable,
+                        );
+                    } else {
+                        // Missing try_into implementation for `{integer}` to `{float}`
+                        err.span_suggestion(
+                            expr.span,
+                            &format!(
+                                "{}, producing the floating point representation of the integer, \
+                                 rounded if necessary",
+                                &msg,
+                            ),
                             cast_suggestion,
                             Applicability::MaybeIncorrect  // lossy conversion
                         );
index 13d874bdb574d56e6987023081824757fa5dbaad..c25f12d008703c997b0e191b48d05f5af4e304a6 100644 (file)
@@ -3,6 +3,10 @@ error[E0308]: mismatched types
    |
 LL |     f1(2i32, 4i32);
    |              ^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |     f1(2i32, 4u32);
+   |              ^^^^
 
 error[E0277]: the trait bound `u32: Foo` is not satisfied
   --> $DIR/associated-types-path-2.rs:29:5
@@ -45,6 +49,10 @@ 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
+   |
+LL |     let _: i32 = f2(2i32).try_into().unwrap();
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 6 previous errors
 
index 14cdb9e07f902acb4f882f29bd8a7a88ac5c01c9..543fecb249f988cb31e15dd6f3a24f9935004917 100644 (file)
@@ -3,48 +3,80 @@ error[E0308]: mismatched types
    |
 LL |         OhNo = 0_u8,
    |                ^^^^ expected i8, found u8
+help: change the type of the numeric literal from `u8` to `i8`
+   |
+LL |         OhNo = 0_i8,
+   |                ^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:30:16
    |
 LL |         OhNo = 0_i8,
    |                ^^^^ expected u8, found i8
+help: change the type of the numeric literal from `i8` to `u8`
+   |
+LL |         OhNo = 0_u8,
+   |                ^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:43:16
    |
 LL |         OhNo = 0_u16,
    |                ^^^^^ expected i16, found u16
+help: change the type of the numeric literal from `u16` to `i16`
+   |
+LL |         OhNo = 0_i16,
+   |                ^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:56:16
    |
 LL |         OhNo = 0_i16,
    |                ^^^^^ expected u16, found i16
+help: change the type of the numeric literal from `i16` to `u16`
+   |
+LL |         OhNo = 0_u16,
+   |                ^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:69:16
    |
 LL |         OhNo = 0_u32,
    |                ^^^^^ expected i32, found u32
+help: change the type of the numeric literal from `u32` to `i32`
+   |
+LL |         OhNo = 0_i32,
+   |                ^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:82:16
    |
 LL |         OhNo = 0_i32,
    |                ^^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |         OhNo = 0_u32,
+   |                ^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:95:16
    |
 LL |         OhNo = 0_u64,
    |                ^^^^^ expected i64, found u64
+help: change the type of the numeric literal from `u64` to `i64`
+   |
+LL |         OhNo = 0_i64,
+   |                ^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/discrim-ill-typed.rs:108:16
    |
 LL |         OhNo = 0_i64,
    |                ^^^^^ expected u64, found i64
+help: change the type of the numeric literal from `i64` to `u64`
+   |
+LL |         OhNo = 0_u64,
+   |                ^^^^^
 
 error: aborting due to 8 previous errors
 
index 6ac49b7ccd13a12eb93503f82e18fa10a09bab4e..839ca57ce55628e786932b8ada470def70eda033 100644 (file)
@@ -15,6 +15,10 @@ error[E0308]: mismatched types
    |
 LL |     let y: f32 = 1f64;
    |                  ^^^^ expected f32, found f64
+help: change the type of the numeric literal from `f64` to `f32`
+   |
+LL |     let y: f32 = 1f32;
+   |                  ^^^^
 
 error: aborting due to 2 previous errors
 
index a2f8a7cf2a68fa512618f6d154f6e25e37039dd5..9dafe1c24f1c254cee5845602ae36edd012c2bbd 100644 (file)
@@ -12,6 +12,10 @@ 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
+   |
+LL |     bar::<isize>(i.try_into().unwrap());  // i should not be re-coerced back to an isize
+   |                  ^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
index 04c8633c8b5d874547c38b4835c26a56e17e949a..b5b3f27f0e6cd886eda277685f189e85f80fda45 100644 (file)
@@ -3,288 +3,342 @@ 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
+   |
+LL |     id_i8(a16.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:35:11
    |
 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
+   |
+LL |     id_i8(a32.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:38:11
    |
 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
+   |
+LL |     id_i8(a64.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:42:12
    |
 LL |     id_i16(a8);
-   |            ^^ expected i16, found i8
-help: you can cast an `i8` to `i16`, which will sign-extend the source value
-   |
-LL |     id_i16(a8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected i16, found i8
+   |            help: you can convert an `i8` to `i16`: `a8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:46:12
    |
 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
+   |
+LL |     id_i16(a32.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:49:12
    |
 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
+   |
+LL |     id_i16(a64.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:53:12
    |
 LL |     id_i32(a8);
-   |            ^^ expected i32, found i8
-help: you can cast an `i8` to `i32`, which will sign-extend the source value
-   |
-LL |     id_i32(a8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected i32, found i8
+   |            help: you can convert an `i8` to `i32`: `a8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:56:12
    |
 LL |     id_i32(a16);
-   |            ^^^ expected i32, found i16
-help: you can cast an `i16` to `i32`, which will sign-extend the source value
-   |
-LL |     id_i32(a16.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected i32, found i16
+   |            help: you can convert an `i16` to `i32`: `a16.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:60:12
    |
 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
+   |
+LL |     id_i32(a64.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:64:12
    |
 LL |     id_i64(a8);
-   |            ^^ expected i64, found i8
-help: you can cast an `i8` to `i64`, which will sign-extend the source value
-   |
-LL |     id_i64(a8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected i64, found i8
+   |            help: you can convert an `i8` to `i64`: `a8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:67:12
    |
 LL |     id_i64(a16);
-   |            ^^^ expected i64, found i16
-help: you can cast an `i16` to `i64`, which will sign-extend the source value
-   |
-LL |     id_i64(a16.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected i64, found i16
+   |            help: you can convert an `i16` to `i64`: `a16.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:70:12
    |
 LL |     id_i64(a32);
-   |            ^^^ expected i64, found i32
-help: you can cast an `i32` to `i64`, which will sign-extend the source value
-   |
-LL |     id_i64(a32.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected i64, found i32
+   |            help: you can convert an `i32` to `i64`: `a32.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:76:11
    |
 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
+   |
+LL |     id_i8(c16.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:79:11
    |
 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
+   |
+LL |     id_i8(c32.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:82:11
    |
 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
+   |
+LL |     id_i8(c64.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:86:12
    |
 LL |     id_i16(c8);
-   |            ^^ expected i16, found i8
-help: you can cast an `i8` to `i16`, which will sign-extend the source value
-   |
-LL |     id_i16(c8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected i16, found i8
+   |            help: you can convert an `i8` to `i16`: `c8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:90:12
    |
 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
+   |
+LL |     id_i16(c32.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:93:12
    |
 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
+   |
+LL |     id_i16(c64.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:97:12
    |
 LL |     id_i32(c8);
-   |            ^^ expected i32, found i8
-help: you can cast an `i8` to `i32`, which will sign-extend the source value
-   |
-LL |     id_i32(c8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected i32, found i8
+   |            help: you can convert an `i8` to `i32`: `c8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:100:12
    |
 LL |     id_i32(c16);
-   |            ^^^ expected i32, found i16
-help: you can cast an `i16` to `i32`, which will sign-extend the source value
-   |
-LL |     id_i32(c16.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected i32, found i16
+   |            help: you can convert an `i16` to `i32`: `c16.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:104:12
    |
 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
+   |
+LL |     id_i32(c64.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:108:12
    |
 LL |     id_i64(a8);
-   |            ^^ expected i64, found i8
-help: you can cast an `i8` to `i64`, which will sign-extend the source value
-   |
-LL |     id_i64(a8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected i64, found i8
+   |            help: you can convert an `i8` to `i64`: `a8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:111:12
    |
 LL |     id_i64(a16);
-   |            ^^^ expected i64, found i16
-help: you can cast an `i16` to `i64`, which will sign-extend the source value
-   |
-LL |     id_i64(a16.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected i64, found i16
+   |            help: you can convert an `i16` to `i64`: `a16.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:114:12
    |
 LL |     id_i64(a32);
-   |            ^^^ expected i64, found i32
-help: you can cast an `i32` to `i64`, which will sign-extend the source value
-   |
-LL |     id_i64(a32.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected i64, found i32
+   |            help: you can convert an `i32` to `i64`: `a32.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:120:11
    |
 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
+   |
+LL |     id_u8(b16.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:123:11
    |
 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
+   |
+LL |     id_u8(b32.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:126:11
    |
 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
+   |
+LL |     id_u8(b64.try_into().unwrap());
+   |           ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:130:12
    |
 LL |     id_u16(b8);
-   |            ^^ expected u16, found u8
-help: you can cast an `u8` to `u16`, which will zero-extend the source value
-   |
-LL |     id_u16(b8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected u16, found u8
+   |            help: you can convert an `u8` to `u16`: `b8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:134:12
    |
 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
+   |
+LL |     id_u16(b32.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:137:12
    |
 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
+   |
+LL |     id_u16(b64.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:141:12
    |
 LL |     id_u32(b8);
-   |            ^^ expected u32, found u8
-help: you can cast an `u8` to `u32`, which will zero-extend the source value
-   |
-LL |     id_u32(b8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected u32, found u8
+   |            help: you can convert an `u8` to `u32`: `b8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:144:12
    |
 LL |     id_u32(b16);
-   |            ^^^ expected u32, found u16
-help: you can cast an `u16` to `u32`, which will zero-extend the source value
-   |
-LL |     id_u32(b16.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected u32, found u16
+   |            help: you can convert an `u16` to `u32`: `b16.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:148:12
    |
 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
+   |
+LL |     id_u32(b64.try_into().unwrap());
+   |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:152:12
    |
 LL |     id_u64(b8);
-   |            ^^ expected u64, found u8
-help: you can cast an `u8` to `u64`, which will zero-extend the source value
-   |
-LL |     id_u64(b8.into());
-   |            ^^^^^^^^^
+   |            ^^
+   |            |
+   |            expected u64, found u8
+   |            help: you can convert an `u8` to `u64`: `b8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:155:12
    |
 LL |     id_u64(b16);
-   |            ^^^ expected u64, found u16
-help: you can cast an `u16` to `u64`, which will zero-extend the source value
-   |
-LL |     id_u64(b16.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected u64, found u16
+   |            help: you can convert an `u16` to `u64`: `b16.into()`
 
 error[E0308]: mismatched types
   --> $DIR/integer-literal-suffix-inference.rs:158:12
    |
 LL |     id_u64(b32);
-   |            ^^^ expected u64, found u32
-help: you can cast an `u32` to `u64`, which will zero-extend the source value
-   |
-LL |     id_u64(b32.into());
-   |            ^^^^^^^^^^
+   |            ^^^
+   |            |
+   |            expected u64, found u32
+   |            help: you can convert an `u32` to `u64`: `b32.into()`
 
 error: aborting due to 36 previous errors
 
index 00b7fbd4564904dccad309f08c4bebb2b0a8940a..b16b7a5b2cf0462e7384f64bdc0c237977f65092 100644 (file)
@@ -3,12 +3,20 @@ 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
+   |
+LL |     foo((1*(1 as isize)).try_into().unwrap());
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-13359.rs:10:9
    |
 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
+   |
+LL |     bar((1*(1 as usize)).try_into().unwrap());
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
index 5fef8497cde54652dd312f76a3654c012de1b2e9..3f4fdee50fddeaed672d38840df980b6c2f9c53a 100644 (file)
@@ -3,6 +3,10 @@ error[E0308]: mismatched types
    |
 LL |   let x: u32 = 20i32;
    |                ^^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |   let x: u32 = 20u32;
+   |                ^^^^^
 
 error: aborting due to previous error
 
index 487b061eba133b7e0bc7bf207d59d37b203e816a..a9fabca50a683c1dd9867b6399cddf4257301063 100644 (file)
@@ -3,6 +3,10 @@ error[E0308]: mismatched types
    |
 LL |     println!("{}", foo(10i32));
    |                        ^^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |     println!("{}", foo(10u32));
+   |                        ^^^^^
 
 error: aborting due to previous error
 
index c58702da97bc6c90c46b55d3662a4b4cc91e3efe..8dd9287ffec79030e60c6de8d20cc43f85d01f97 100644 (file)
@@ -3,6 +3,10 @@ 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
+   |
+LL |     X = Trait::Number.try_into().unwrap(),
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index fc0c14076019ff471da83d46ce002f07ec38e19a..28847c5a82a07b3bb0bfc71ae3c823869fecdf57 100644 (file)
@@ -3,12 +3,20 @@ error[E0308]: mismatched types
    |
 LL |     A = 1i64,
    |         ^^^^ expected isize, found i64
+help: change the type of the numeric literal from `i64` to `isize`
+   |
+LL |     A = 1isize,
+   |         ^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-8761.rs:5:9
    |
 LL |     B = 2u8
    |         ^^^ expected isize, found u8
+help: change the type of the numeric literal from `u8` to `isize`
+   |
+LL |     B = 2isize
+   |         ^^^^^^
 
 error: aborting due to 2 previous errors
 
index 901bdcd8e4a7e75a5f635cad742daa90309a6302..db1d5070e7fa18ca449978c8cbd658133b1a607b 100644 (file)
@@ -3,6 +3,10 @@ error[E0308]: mismatched types
    |
 LL |     let x: u32 = 22_usize;
    |                  ^^^^^^^^ expected u32, found usize
+help: change the type of the numeric literal from `usize` to `u32`
+   |
+LL |     let x: u32 = 22_u32;
+   |                  ^^^^^^
 
 error: aborting due to previous error
 
index 8a63aed60d58de17db592fe71bd346c24966d2c1..be701b2bb3973e9b85a26597e79a72334effb4a3 100644 (file)
@@ -11,6 +11,10 @@ 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
+   |
+LL |     let y: usize = x.foo().try_into().unwrap();
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
index 59326fc1dd26a09aa10bb1d30fec0cca58454c58..1a81df8e2c464c7fafa27f31a168c151a81c9a3c 100644 (file)
@@ -6,6 +6,10 @@ 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
+   |
+LL |                   ($arr.len() * size_of($arr[0])).try_into().unwrap());
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0605]: non-primitive cast: `{integer}` as `()`
   --> $DIR/issue-26480.rs:22:19
index 79088f0e2ca2f224c3453a48f764b932e712ee34..be4411e630becfdbfec6b2ce31d0dbcb8dfd62e4 100644 (file)
@@ -3,18 +3,30 @@ 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
+   |
+LL |     let x: u16 = foo().try_into().unwrap();
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/numeric-cast-2.rs:7:18
    |
 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
+   |
+LL |     let y: i64 = (x + x).try_into().unwrap();
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/numeric-cast-2.rs:9:18
    |
 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
+   |
+LL |     let z: i32 = (x + x).try_into().unwrap();
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/numeric/numeric-cast-without-suggestion.rs b/src/test/ui/numeric/numeric-cast-without-suggestion.rs
new file mode 100644 (file)
index 0000000..faf24a8
--- /dev/null
@@ -0,0 +1,38 @@
+fn foo<N>(_x: N) {}
+
+fn main() {
+    let x_usize: usize = 1;
+    let x_u64: u64 = 2;
+    let x_u32: u32 = 3;
+    let x_u16: u16 = 4;
+    let x_u8: u8 = 5;
+    let x_isize: isize = 6;
+    let x_i64: i64 = 7;
+    let x_i32: i32 = 8;
+    let x_i16: i16 = 9;
+    let x_i8: i8 = 10;
+    let x_f64: f64 = 11.0;
+    let x_f32: f32 = 12.0;
+
+    foo::<usize>(x_f64); //~ ERROR mismatched types
+    foo::<usize>(x_f32); //~ ERROR mismatched types
+    foo::<isize>(x_f64); //~ ERROR mismatched types
+    foo::<isize>(x_f32); //~ ERROR mismatched types
+    foo::<u64>(x_f64); //~ ERROR mismatched types
+    foo::<u64>(x_f32); //~ ERROR mismatched types
+    foo::<i64>(x_f64); //~ ERROR mismatched types
+    foo::<i64>(x_f32); //~ ERROR mismatched types
+    foo::<u32>(x_f64); //~ ERROR mismatched types
+    foo::<u32>(x_f32); //~ ERROR mismatched types
+    foo::<i32>(x_f64); //~ ERROR mismatched types
+    foo::<i32>(x_f32); //~ ERROR mismatched types
+    foo::<u16>(x_f64); //~ ERROR mismatched types
+    foo::<u16>(x_f32); //~ ERROR mismatched types
+    foo::<i16>(x_f64); //~ ERROR mismatched types
+    foo::<i16>(x_f32); //~ ERROR mismatched types
+    foo::<u8>(x_f64); //~ ERROR mismatched types
+    foo::<u8>(x_f32); //~ ERROR mismatched types
+    foo::<i8>(x_f64); //~ ERROR mismatched types
+    foo::<i8>(x_f32); //~ ERROR mismatched types
+    foo::<f32>(x_f64); //~ ERROR mismatched types
+}
diff --git a/src/test/ui/numeric/numeric-cast-without-suggestion.stderr b/src/test/ui/numeric/numeric-cast-without-suggestion.stderr
new file mode 100644 (file)
index 0000000..a79eaea
--- /dev/null
@@ -0,0 +1,129 @@
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:17:18
+   |
+LL |     foo::<usize>(x_f64);
+   |                  ^^^^^ expected usize, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:18:18
+   |
+LL |     foo::<usize>(x_f32);
+   |                  ^^^^^ expected usize, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:19:18
+   |
+LL |     foo::<isize>(x_f64);
+   |                  ^^^^^ expected isize, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:20:18
+   |
+LL |     foo::<isize>(x_f32);
+   |                  ^^^^^ expected isize, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:21:16
+   |
+LL |     foo::<u64>(x_f64);
+   |                ^^^^^ expected u64, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:22:16
+   |
+LL |     foo::<u64>(x_f32);
+   |                ^^^^^ expected u64, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:23:16
+   |
+LL |     foo::<i64>(x_f64);
+   |                ^^^^^ expected i64, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:24:16
+   |
+LL |     foo::<i64>(x_f32);
+   |                ^^^^^ expected i64, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:25:16
+   |
+LL |     foo::<u32>(x_f64);
+   |                ^^^^^ expected u32, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:26:16
+   |
+LL |     foo::<u32>(x_f32);
+   |                ^^^^^ expected u32, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:27:16
+   |
+LL |     foo::<i32>(x_f64);
+   |                ^^^^^ expected i32, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:28:16
+   |
+LL |     foo::<i32>(x_f32);
+   |                ^^^^^ expected i32, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:29:16
+   |
+LL |     foo::<u16>(x_f64);
+   |                ^^^^^ expected u16, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:30:16
+   |
+LL |     foo::<u16>(x_f32);
+   |                ^^^^^ expected u16, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:31:16
+   |
+LL |     foo::<i16>(x_f64);
+   |                ^^^^^ expected i16, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:32:16
+   |
+LL |     foo::<i16>(x_f32);
+   |                ^^^^^ expected i16, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:33:15
+   |
+LL |     foo::<u8>(x_f64);
+   |               ^^^^^ expected u8, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:34:15
+   |
+LL |     foo::<u8>(x_f32);
+   |               ^^^^^ expected u8, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:35:15
+   |
+LL |     foo::<i8>(x_f64);
+   |               ^^^^^ expected i8, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:36:15
+   |
+LL |     foo::<i8>(x_f32);
+   |               ^^^^^ expected i8, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-without-suggestion.rs:37:16
+   |
+LL |     foo::<f32>(x_f64);
+   |                ^^^^^ expected f32, found f64
+
+error: aborting due to 21 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/numeric/numeric-cast.fixed b/src/test/ui/numeric/numeric-cast.fixed
new file mode 100644 (file)
index 0000000..6f78228
--- /dev/null
@@ -0,0 +1,293 @@
+// run-rustfix
+
+// The `try_into` suggestion doesn't include this, but we do suggest it after applying it
+use std::convert::TryInto;
+
+fn foo<N>(_x: N) {}
+
+fn main() {
+    let x_usize: usize = 1;
+    let x_u64: u64 = 2;
+    let x_u32: u32 = 3;
+    let x_u16: u16 = 4;
+    let x_u8: u8 = 5;
+    let x_isize: isize = 6;
+    let x_i64: i64 = 7;
+    let x_i32: i32 = 8;
+    let x_i16: i16 = 9;
+    let x_i8: i8 = 10;
+    let x_f64: f64 = 11.0;
+    let x_f32: f32 = 12.0;
+
+    foo::<usize>(x_usize);
+    foo::<usize>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_u8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    // foo::<usize>(x_f64);
+    // foo::<usize>(x_f32);
+
+    foo::<isize>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_isize);
+    foo::<isize>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<isize>(x_i8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    // foo::<isize>(x_f64);
+    // foo::<isize>(x_f32);
+
+    foo::<u64>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_u64);
+    foo::<u64>(x_u32.into());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_u16.into());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_u8.into());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    // foo::<u64>(x_f64);
+    // foo::<u64>(x_f32);
+
+    foo::<i64>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_i64);
+    foo::<i64>(x_i32.into());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_i16.into());
+    //~^ ERROR mismatched types
+    foo::<i64>(x_i8.into());
+    //~^ ERROR mismatched types
+    // foo::<i64>(x_f64);
+    // foo::<i64>(x_f32);
+
+    foo::<u32>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_u32);
+    foo::<u32>(x_u16.into());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_u8.into());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    // foo::<u32>(x_f64);
+    // foo::<u32>(x_f32);
+
+    foo::<i32>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_i32);
+    foo::<i32>(x_i16.into());
+    //~^ ERROR mismatched types
+    foo::<i32>(x_i8.into());
+    //~^ ERROR mismatched types
+    // foo::<i32>(x_f64);
+    // foo::<i32>(x_f32);
+
+    foo::<u16>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_u16);
+    foo::<u16>(x_u8.into());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    // foo::<u16>(x_f64);
+    // foo::<u16>(x_f32);
+
+    foo::<i16>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i16>(x_i16);
+    foo::<i16>(x_i8.into());
+    //~^ ERROR mismatched types
+    // foo::<i16>(x_f64);
+    // foo::<i16>(x_f32);
+
+    foo::<u8>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u8);
+    foo::<u8>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    // foo::<u8>(x_f64);
+    // foo::<u8>(x_f32);
+
+    foo::<i8>(x_usize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u8.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_isize.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i64.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i32.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i16.try_into().unwrap());
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i8);
+    // foo::<i8>(x_f64);
+    // foo::<i8>(x_f32);
+
+    foo::<f64>(x_usize as f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u64 as f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u32.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u16.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u8.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(x_isize as f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i64 as f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i32.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i16.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i8.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(x_f64);
+    foo::<f64>(x_f32.into());
+    //~^ ERROR mismatched types
+
+    foo::<f32>(x_usize as f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u64 as f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u32 as f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u16.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u8.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(x_isize as f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i64 as f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i32 as f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i16.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i8.into());
+    //~^ ERROR mismatched types
+    // foo::<f32>(x_f64);
+    foo::<f32>(x_f32);
+
+    foo::<u32>((x_u8 as u16).into());
+    //~^ ERROR mismatched types
+    foo::<i32>((-x_i8).into());
+    //~^ ERROR mismatched types
+}
index 39378c288fe5646dbdf31dd57fbd6b6aba780db4..7bddfc50905357e062e90709c93e525c743cd08e 100644 (file)
@@ -1,3 +1,8 @@
+// run-rustfix
+
+// The `try_into` suggestion doesn't include this, but we do suggest it after applying it
+use std::convert::TryInto;
+
 fn foo<N>(_x: N) {}
 
 fn main() {
@@ -33,10 +38,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<usize>(x_i8);
     //~^ ERROR mismatched types
-    foo::<usize>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<usize>(x_f64);
+    // foo::<usize>(x_f32);
 
     foo::<isize>(x_usize);
     //~^ ERROR mismatched types
@@ -57,10 +60,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<isize>(x_i8);
     //~^ ERROR mismatched types
-    foo::<isize>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<isize>(x_f64);
+    // foo::<isize>(x_f32);
 
     foo::<u64>(x_usize);
     //~^ ERROR mismatched types
@@ -81,10 +82,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<u64>(x_i8);
     //~^ ERROR mismatched types
-    foo::<u64>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<u64>(x_f64);
+    // foo::<u64>(x_f32);
 
     foo::<i64>(x_usize);
     //~^ ERROR mismatched types
@@ -105,10 +104,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<i64>(x_i8);
     //~^ ERROR mismatched types
-    foo::<i64>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<i64>(x_f64);
+    // foo::<i64>(x_f32);
 
     foo::<u32>(x_usize);
     //~^ ERROR mismatched types
@@ -129,10 +126,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<u32>(x_i8);
     //~^ ERROR mismatched types
-    foo::<u32>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<u32>(x_f64);
+    // foo::<u32>(x_f32);
 
     foo::<i32>(x_usize);
     //~^ ERROR mismatched types
@@ -153,10 +148,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<i32>(x_i8);
     //~^ ERROR mismatched types
-    foo::<i32>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<i32>(x_f64);
+    // foo::<i32>(x_f32);
 
     foo::<u16>(x_usize);
     //~^ ERROR mismatched types
@@ -177,10 +170,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<u16>(x_i8);
     //~^ ERROR mismatched types
-    foo::<u16>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<u16>(x_f64);
+    // foo::<u16>(x_f32);
 
     foo::<i16>(x_usize);
     //~^ ERROR mismatched types
@@ -201,10 +192,8 @@ fn main() {
     foo::<i16>(x_i16);
     foo::<i16>(x_i8);
     //~^ ERROR mismatched types
-    foo::<i16>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<i16>(x_f64);
+    // foo::<i16>(x_f32);
 
     foo::<u8>(x_usize);
     //~^ ERROR mismatched types
@@ -225,10 +214,8 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<u8>(x_i8);
     //~^ ERROR mismatched types
-    foo::<u8>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<u8>(x_f64);
+    // foo::<u8>(x_f32);
 
     foo::<i8>(x_usize);
     //~^ ERROR mismatched types
@@ -249,10 +236,8 @@ fn main() {
     foo::<i8>(x_i16);
     //~^ ERROR mismatched types
     foo::<i8>(x_i8);
-    foo::<i8>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_f32);
-    //~^ ERROR mismatched types
+    // foo::<i8>(x_f64);
+    // foo::<i8>(x_f32);
 
     foo::<f64>(x_usize);
     //~^ ERROR mismatched types
@@ -298,8 +283,7 @@ fn main() {
     //~^ ERROR mismatched types
     foo::<f32>(x_i8);
     //~^ ERROR mismatched types
-    foo::<f32>(x_f64);
-    //~^ ERROR mismatched types
+    // foo::<f32>(x_f64);
     foo::<f32>(x_f32);
 
     foo::<u32>(x_u8 as u16);
index 2c4f6e20f1f0a304030734ffc4292bea55558b0e..9e7dcf7e41b555165dc1596d979ccb0675699964 100644 (file)
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:18:18
+  --> $DIR/numeric-cast.rs:23:18
    |
 LL |     foo::<usize>(x_u64);
    |                  ^^^^^ expected usize, found u64
+help: you can convert an `u64` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_u64.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:20:18
+  --> $DIR/numeric-cast.rs:25:18
    |
 LL |     foo::<usize>(x_u32);
    |                  ^^^^^ expected usize, found u32
+help: you can convert an `u32` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_u32.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:22:18
+  --> $DIR/numeric-cast.rs:27:18
    |
 LL |     foo::<usize>(x_u16);
    |                  ^^^^^ expected usize, found u16
+help: you can convert an `u16` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_u16.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:24:18
+  --> $DIR/numeric-cast.rs:29:18
    |
 LL |     foo::<usize>(x_u8);
    |                  ^^^^ expected usize, found u8
+help: you can convert an `u8` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_u8.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:26:18
+  --> $DIR/numeric-cast.rs:31:18
    |
 LL |     foo::<usize>(x_isize);
    |                  ^^^^^^^ expected usize, found isize
+help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_isize.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:28:18
+  --> $DIR/numeric-cast.rs:33:18
    |
 LL |     foo::<usize>(x_i64);
    |                  ^^^^^ expected usize, found i64
+help: you can convert an `i64` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_i64.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:30:18
+  --> $DIR/numeric-cast.rs:35:18
    |
 LL |     foo::<usize>(x_i32);
    |                  ^^^^^ expected usize, found i32
+help: you can convert an `i32` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_i32.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:32:18
+  --> $DIR/numeric-cast.rs:37:18
    |
 LL |     foo::<usize>(x_i16);
    |                  ^^^^^ expected usize, found i16
+help: you can convert an `i16` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<usize>(x_i16.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:34:18
+  --> $DIR/numeric-cast.rs:39:18
    |
 LL |     foo::<usize>(x_i8);
    |                  ^^^^ expected usize, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:36:18
+help: you can convert an `i8` to `usize` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<usize>(x_f64);
-   |                  ^^^^^ expected usize, found f64
+LL |     foo::<usize>(x_i8.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:38:18
-   |
-LL |     foo::<usize>(x_f32);
-   |                  ^^^^^ expected usize, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:41:18
+  --> $DIR/numeric-cast.rs:44:18
    |
 LL |     foo::<isize>(x_usize);
    |                  ^^^^^^^ expected isize, found usize
+help: you can convert an `usize` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_usize.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:43:18
+  --> $DIR/numeric-cast.rs:46:18
    |
 LL |     foo::<isize>(x_u64);
    |                  ^^^^^ expected isize, found u64
+help: you can convert an `u64` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_u64.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:45:18
+  --> $DIR/numeric-cast.rs:48:18
    |
 LL |     foo::<isize>(x_u32);
    |                  ^^^^^ expected isize, found u32
+help: you can convert an `u32` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_u32.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:47:18
+  --> $DIR/numeric-cast.rs:50:18
    |
 LL |     foo::<isize>(x_u16);
    |                  ^^^^^ expected isize, found u16
+help: you can convert an `u16` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_u16.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:49:18
+  --> $DIR/numeric-cast.rs:52:18
    |
 LL |     foo::<isize>(x_u8);
    |                  ^^^^ expected isize, found u8
+help: you can convert an `u8` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_u8.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:52:18
+  --> $DIR/numeric-cast.rs:55:18
    |
 LL |     foo::<isize>(x_i64);
    |                  ^^^^^ expected isize, found i64
+help: you can convert an `i64` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_i64.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:54:18
+  --> $DIR/numeric-cast.rs:57:18
    |
 LL |     foo::<isize>(x_i32);
    |                  ^^^^^ expected isize, found i32
+help: you can convert an `i32` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_i32.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:56:18
+  --> $DIR/numeric-cast.rs:59:18
    |
 LL |     foo::<isize>(x_i16);
    |                  ^^^^^ expected isize, found i16
+help: you can convert an `i16` to `isize` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<isize>(x_i16.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:58:18
+  --> $DIR/numeric-cast.rs:61:18
    |
 LL |     foo::<isize>(x_i8);
    |                  ^^^^ expected isize, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:60:18
+help: you can convert an `i8` to `isize` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<isize>(x_f64);
-   |                  ^^^^^ expected isize, found f64
+LL |     foo::<isize>(x_i8.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:62:18
-   |
-LL |     foo::<isize>(x_f32);
-   |                  ^^^^^ expected isize, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:65:16
+  --> $DIR/numeric-cast.rs:66:16
    |
 LL |     foo::<u64>(x_usize);
    |                ^^^^^^^ expected u64, found usize
+help: you can convert an `usize` to `u64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u64>(x_usize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:68:16
+  --> $DIR/numeric-cast.rs:69:16
    |
 LL |     foo::<u64>(x_u32);
-   |                ^^^^^ expected u64, found u32
-help: you can cast an `u32` to `u64`, which will zero-extend the source value
-   |
-LL |     foo::<u64>(x_u32.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected u64, found u32
+   |                help: you can convert an `u32` to `u64`: `x_u32.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:70:16
+  --> $DIR/numeric-cast.rs:71:16
    |
 LL |     foo::<u64>(x_u16);
-   |                ^^^^^ expected u64, found u16
-help: you can cast an `u16` to `u64`, which will zero-extend the source value
-   |
-LL |     foo::<u64>(x_u16.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected u64, found u16
+   |                help: you can convert an `u16` to `u64`: `x_u16.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:72:16
+  --> $DIR/numeric-cast.rs:73:16
    |
 LL |     foo::<u64>(x_u8);
-   |                ^^^^ expected u64, found u8
-help: you can cast an `u8` to `u64`, which will zero-extend the source value
-   |
-LL |     foo::<u64>(x_u8.into());
-   |                ^^^^^^^^^^^
+   |                ^^^^
+   |                |
+   |                expected u64, found u8
+   |                help: you can convert an `u8` to `u64`: `x_u8.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:74:16
+  --> $DIR/numeric-cast.rs:75:16
    |
 LL |     foo::<u64>(x_isize);
    |                ^^^^^^^ expected u64, found isize
+help: you can convert an `isize` to `u64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u64>(x_isize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:76:16
+  --> $DIR/numeric-cast.rs:77:16
    |
 LL |     foo::<u64>(x_i64);
    |                ^^^^^ expected u64, found i64
+help: you can convert an `i64` to `u64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u64>(x_i64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:78:16
+  --> $DIR/numeric-cast.rs:79:16
    |
 LL |     foo::<u64>(x_i32);
    |                ^^^^^ expected u64, found i32
+help: you can convert an `i32` to `u64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u64>(x_i32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:80:16
+  --> $DIR/numeric-cast.rs:81:16
    |
 LL |     foo::<u64>(x_i16);
    |                ^^^^^ expected u64, found i16
+help: you can convert an `i16` to `u64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u64>(x_i16.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:82:16
+  --> $DIR/numeric-cast.rs:83:16
    |
 LL |     foo::<u64>(x_i8);
    |                ^^^^ expected u64, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:84:16
+help: you can convert an `i8` to `u64` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<u64>(x_f64);
-   |                ^^^^^ expected u64, found f64
+LL |     foo::<u64>(x_i8.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:86:16
-   |
-LL |     foo::<u64>(x_f32);
-   |                ^^^^^ expected u64, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:89:16
+  --> $DIR/numeric-cast.rs:88:16
    |
 LL |     foo::<i64>(x_usize);
    |                ^^^^^^^ expected i64, found usize
+help: you can convert an `usize` to `i64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i64>(x_usize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:91:16
+  --> $DIR/numeric-cast.rs:90:16
    |
 LL |     foo::<i64>(x_u64);
    |                ^^^^^ expected i64, found u64
+help: you can convert an `u64` to `i64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i64>(x_u64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:93:16
+  --> $DIR/numeric-cast.rs:92:16
    |
 LL |     foo::<i64>(x_u32);
    |                ^^^^^ expected i64, found u32
+help: you can convert an `u32` to `i64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i64>(x_u32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:95:16
+  --> $DIR/numeric-cast.rs:94:16
    |
 LL |     foo::<i64>(x_u16);
    |                ^^^^^ expected i64, found u16
+help: you can convert an `u16` to `i64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i64>(x_u16.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:97:16
+  --> $DIR/numeric-cast.rs:96:16
    |
 LL |     foo::<i64>(x_u8);
    |                ^^^^ expected i64, found u8
+help: you can convert an `u8` to `i64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i64>(x_u8.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:99:16
+  --> $DIR/numeric-cast.rs:98:16
    |
 LL |     foo::<i64>(x_isize);
    |                ^^^^^^^ expected i64, found isize
+help: you can convert an `isize` to `i64` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i64>(x_isize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:102:16
+  --> $DIR/numeric-cast.rs:101:16
    |
 LL |     foo::<i64>(x_i32);
-   |                ^^^^^ expected i64, found i32
-help: you can cast an `i32` to `i64`, which will sign-extend the source value
-   |
-LL |     foo::<i64>(x_i32.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected i64, found i32
+   |                help: you can convert an `i32` to `i64`: `x_i32.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:104:16
+  --> $DIR/numeric-cast.rs:103:16
    |
 LL |     foo::<i64>(x_i16);
-   |                ^^^^^ expected i64, found i16
-help: you can cast an `i16` to `i64`, which will sign-extend the source value
-   |
-LL |     foo::<i64>(x_i16.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected i64, found i16
+   |                help: you can convert an `i16` to `i64`: `x_i16.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:106:16
+  --> $DIR/numeric-cast.rs:105:16
    |
 LL |     foo::<i64>(x_i8);
-   |                ^^^^ expected i64, found i8
-help: you can cast an `i8` to `i64`, which will sign-extend the source value
-   |
-LL |     foo::<i64>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:108:16
-   |
-LL |     foo::<i64>(x_f64);
-   |                ^^^^^ expected i64, found f64
+   |                ^^^^
+   |                |
+   |                expected i64, found i8
+   |                help: you can convert an `i8` to `i64`: `x_i8.into()`
 
 error[E0308]: mismatched types
   --> $DIR/numeric-cast.rs:110:16
    |
-LL |     foo::<i64>(x_f32);
-   |                ^^^^^ expected i64, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:113:16
-   |
 LL |     foo::<u32>(x_usize);
    |                ^^^^^^^ expected u32, found usize
+help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u32>(x_usize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:115:16
+  --> $DIR/numeric-cast.rs:112:16
    |
 LL |     foo::<u32>(x_u64);
    |                ^^^^^ expected u32, found u64
+help: you can convert an `u64` to `u32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u32>(x_u64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:118:16
+  --> $DIR/numeric-cast.rs:115:16
    |
 LL |     foo::<u32>(x_u16);
-   |                ^^^^^ expected u32, found u16
-help: you can cast an `u16` to `u32`, which will zero-extend the source value
-   |
-LL |     foo::<u32>(x_u16.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected u32, found u16
+   |                help: you can convert an `u16` to `u32`: `x_u16.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:120:16
+  --> $DIR/numeric-cast.rs:117:16
    |
 LL |     foo::<u32>(x_u8);
-   |                ^^^^ expected u32, found u8
-help: you can cast an `u8` to `u32`, which will zero-extend the source value
-   |
-LL |     foo::<u32>(x_u8.into());
-   |                ^^^^^^^^^^^
+   |                ^^^^
+   |                |
+   |                expected u32, found u8
+   |                help: you can convert an `u8` to `u32`: `x_u8.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:122:16
+  --> $DIR/numeric-cast.rs:119:16
    |
 LL |     foo::<u32>(x_isize);
    |                ^^^^^^^ expected u32, found isize
+help: you can convert an `isize` to `u32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u32>(x_isize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:124:16
+  --> $DIR/numeric-cast.rs:121:16
    |
 LL |     foo::<u32>(x_i64);
    |                ^^^^^ expected u32, found i64
+help: you can convert an `i64` to `u32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u32>(x_i64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:126:16
+  --> $DIR/numeric-cast.rs:123:16
    |
 LL |     foo::<u32>(x_i32);
    |                ^^^^^ expected u32, found i32
+help: you can convert an `i32` to `u32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u32>(x_i32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:128:16
+  --> $DIR/numeric-cast.rs:125:16
    |
 LL |     foo::<u32>(x_i16);
    |                ^^^^^ expected u32, found i16
+help: you can convert an `i16` to `u32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u32>(x_i16.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:130:16
+  --> $DIR/numeric-cast.rs:127:16
    |
 LL |     foo::<u32>(x_i8);
    |                ^^^^ expected u32, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:132:16
-   |
-LL |     foo::<u32>(x_f64);
-   |                ^^^^^ expected u32, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:134:16
+help: you can convert an `i8` to `u32` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<u32>(x_f32);
-   |                ^^^^^ expected u32, found f32
+LL |     foo::<u32>(x_i8.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:137:16
+  --> $DIR/numeric-cast.rs:132:16
    |
 LL |     foo::<i32>(x_usize);
    |                ^^^^^^^ expected i32, found usize
+help: you can convert an `usize` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_usize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:139:16
+  --> $DIR/numeric-cast.rs:134:16
    |
 LL |     foo::<i32>(x_u64);
    |                ^^^^^ expected i32, found u64
+help: you can convert an `u64` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_u64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:141:16
+  --> $DIR/numeric-cast.rs:136:16
    |
 LL |     foo::<i32>(x_u32);
    |                ^^^^^ expected i32, found u32
+help: you can convert an `u32` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_u32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:143:16
+  --> $DIR/numeric-cast.rs:138:16
    |
 LL |     foo::<i32>(x_u16);
    |                ^^^^^ expected i32, found u16
+help: you can convert an `u16` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_u16.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:145:16
+  --> $DIR/numeric-cast.rs:140:16
    |
 LL |     foo::<i32>(x_u8);
    |                ^^^^ expected i32, found u8
+help: you can convert an `u8` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_u8.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:147:16
+  --> $DIR/numeric-cast.rs:142:16
    |
 LL |     foo::<i32>(x_isize);
    |                ^^^^^^^ expected i32, found isize
+help: you can convert an `isize` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_isize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:149:16
+  --> $DIR/numeric-cast.rs:144:16
    |
 LL |     foo::<i32>(x_i64);
    |                ^^^^^ expected i32, found i64
+help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i32>(x_i64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:152:16
+  --> $DIR/numeric-cast.rs:147:16
    |
 LL |     foo::<i32>(x_i16);
-   |                ^^^^^ expected i32, found i16
-help: you can cast an `i16` to `i32`, which will sign-extend the source value
-   |
-LL |     foo::<i32>(x_i16.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected i32, found i16
+   |                help: you can convert an `i16` to `i32`: `x_i16.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:154:16
+  --> $DIR/numeric-cast.rs:149:16
    |
 LL |     foo::<i32>(x_i8);
-   |                ^^^^ expected i32, found i8
-help: you can cast an `i8` to `i32`, which will sign-extend the source value
-   |
-LL |     foo::<i32>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:156:16
-   |
-LL |     foo::<i32>(x_f64);
-   |                ^^^^^ expected i32, found f64
+   |                ^^^^
+   |                |
+   |                expected i32, found i8
+   |                help: you can convert an `i8` to `i32`: `x_i8.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:158:16
-   |
-LL |     foo::<i32>(x_f32);
-   |                ^^^^^ expected i32, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:161:16
+  --> $DIR/numeric-cast.rs:154:16
    |
 LL |     foo::<u16>(x_usize);
    |                ^^^^^^^ expected u16, found usize
+help: you can convert an `usize` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_usize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:163:16
+  --> $DIR/numeric-cast.rs:156:16
    |
 LL |     foo::<u16>(x_u64);
    |                ^^^^^ expected u16, found u64
+help: you can convert an `u64` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_u64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:165:16
+  --> $DIR/numeric-cast.rs:158:16
    |
 LL |     foo::<u16>(x_u32);
    |                ^^^^^ expected u16, found u32
+help: you can convert an `u32` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_u32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:168:16
+  --> $DIR/numeric-cast.rs:161:16
    |
 LL |     foo::<u16>(x_u8);
-   |                ^^^^ expected u16, found u8
-help: you can cast an `u8` to `u16`, which will zero-extend the source value
-   |
-LL |     foo::<u16>(x_u8.into());
-   |                ^^^^^^^^^^^
+   |                ^^^^
+   |                |
+   |                expected u16, found u8
+   |                help: you can convert an `u8` to `u16`: `x_u8.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:170:16
+  --> $DIR/numeric-cast.rs:163:16
    |
 LL |     foo::<u16>(x_isize);
    |                ^^^^^^^ expected u16, found isize
+help: you can convert an `isize` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_isize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:172:16
+  --> $DIR/numeric-cast.rs:165:16
    |
 LL |     foo::<u16>(x_i64);
    |                ^^^^^ expected u16, found i64
+help: you can convert an `i64` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_i64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:174:16
+  --> $DIR/numeric-cast.rs:167:16
    |
 LL |     foo::<u16>(x_i32);
    |                ^^^^^ expected u16, found i32
+help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_i32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:176:16
+  --> $DIR/numeric-cast.rs:169:16
    |
 LL |     foo::<u16>(x_i16);
    |                ^^^^^ expected u16, found i16
+help: you can convert an `i16` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u16>(x_i16.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:178:16
+  --> $DIR/numeric-cast.rs:171:16
    |
 LL |     foo::<u16>(x_i8);
    |                ^^^^ expected u16, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:180:16
-   |
-LL |     foo::<u16>(x_f64);
-   |                ^^^^^ expected u16, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:182:16
+help: you can convert an `i8` to `u16` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<u16>(x_f32);
-   |                ^^^^^ expected u16, found f32
+LL |     foo::<u16>(x_i8.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:185:16
+  --> $DIR/numeric-cast.rs:176:16
    |
 LL |     foo::<i16>(x_usize);
    |                ^^^^^^^ expected i16, found usize
+help: you can convert an `usize` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_usize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:187:16
+  --> $DIR/numeric-cast.rs:178:16
    |
 LL |     foo::<i16>(x_u64);
    |                ^^^^^ expected i16, found u64
+help: you can convert an `u64` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_u64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:189:16
+  --> $DIR/numeric-cast.rs:180:16
    |
 LL |     foo::<i16>(x_u32);
    |                ^^^^^ expected i16, found u32
+help: you can convert an `u32` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_u32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:191:16
+  --> $DIR/numeric-cast.rs:182:16
    |
 LL |     foo::<i16>(x_u16);
    |                ^^^^^ expected i16, found u16
+help: you can convert an `u16` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_u16.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:193:16
+  --> $DIR/numeric-cast.rs:184:16
    |
 LL |     foo::<i16>(x_u8);
    |                ^^^^ expected i16, found u8
+help: you can convert an `u8` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_u8.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:195:16
+  --> $DIR/numeric-cast.rs:186:16
    |
 LL |     foo::<i16>(x_isize);
    |                ^^^^^^^ expected i16, found isize
+help: you can convert an `isize` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_isize.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:197:16
+  --> $DIR/numeric-cast.rs:188:16
    |
 LL |     foo::<i16>(x_i64);
    |                ^^^^^ expected i16, found i64
+help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i16>(x_i64.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:199:16
+  --> $DIR/numeric-cast.rs:190:16
    |
 LL |     foo::<i16>(x_i32);
    |                ^^^^^ expected i16, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:202:16
-   |
-LL |     foo::<i16>(x_i8);
-   |                ^^^^ expected i16, found i8
-help: you can cast an `i8` to `i16`, which will sign-extend the source value
-   |
-LL |     foo::<i16>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:204:16
+help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<i16>(x_f64);
-   |                ^^^^^ expected i16, found f64
+LL |     foo::<i16>(x_i32.try_into().unwrap());
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:206:16
+  --> $DIR/numeric-cast.rs:193:16
    |
-LL |     foo::<i16>(x_f32);
-   |                ^^^^^ expected i16, found f32
+LL |     foo::<i16>(x_i8);
+   |                ^^^^
+   |                |
+   |                expected i16, found i8
+   |                help: you can convert an `i8` to `i16`: `x_i8.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:209:15
+  --> $DIR/numeric-cast.rs:198:15
    |
 LL |     foo::<u8>(x_usize);
    |               ^^^^^^^ expected u8, found usize
+help: you can convert an `usize` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_usize.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:211:15
+  --> $DIR/numeric-cast.rs:200:15
    |
 LL |     foo::<u8>(x_u64);
    |               ^^^^^ expected u8, found u64
+help: you can convert an `u64` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_u64.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:213:15
+  --> $DIR/numeric-cast.rs:202:15
    |
 LL |     foo::<u8>(x_u32);
    |               ^^^^^ expected u8, found u32
+help: you can convert an `u32` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_u32.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:215:15
+  --> $DIR/numeric-cast.rs:204:15
    |
 LL |     foo::<u8>(x_u16);
    |               ^^^^^ expected u8, found u16
+help: you can convert an `u16` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_u16.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:218:15
+  --> $DIR/numeric-cast.rs:207:15
    |
 LL |     foo::<u8>(x_isize);
    |               ^^^^^^^ expected u8, found isize
+help: you can convert an `isize` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_isize.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:220:15
+  --> $DIR/numeric-cast.rs:209:15
    |
 LL |     foo::<u8>(x_i64);
    |               ^^^^^ expected u8, found i64
+help: you can convert an `i64` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_i64.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:222:15
+  --> $DIR/numeric-cast.rs:211:15
    |
 LL |     foo::<u8>(x_i32);
    |               ^^^^^ expected u8, found i32
+help: you can convert an `i32` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_i32.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:224:15
+  --> $DIR/numeric-cast.rs:213:15
    |
 LL |     foo::<u8>(x_i16);
    |               ^^^^^ expected u8, found i16
+help: you can convert an `i16` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<u8>(x_i16.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:226:15
+  --> $DIR/numeric-cast.rs:215:15
    |
 LL |     foo::<u8>(x_i8);
    |               ^^^^ expected u8, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:228:15
-   |
-LL |     foo::<u8>(x_f64);
-   |               ^^^^^ expected u8, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:230:15
+help: you can convert an `i8` to `u8` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<u8>(x_f32);
-   |               ^^^^^ expected u8, found f32
+LL |     foo::<u8>(x_i8.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:233:15
+  --> $DIR/numeric-cast.rs:220:15
    |
 LL |     foo::<i8>(x_usize);
    |               ^^^^^^^ expected i8, found usize
+help: you can convert an `usize` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_usize.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:235:15
+  --> $DIR/numeric-cast.rs:222:15
    |
 LL |     foo::<i8>(x_u64);
    |               ^^^^^ expected i8, found u64
+help: you can convert an `u64` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_u64.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:237:15
+  --> $DIR/numeric-cast.rs:224:15
    |
 LL |     foo::<i8>(x_u32);
    |               ^^^^^ expected i8, found u32
+help: you can convert an `u32` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_u32.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:239:15
+  --> $DIR/numeric-cast.rs:226:15
    |
 LL |     foo::<i8>(x_u16);
    |               ^^^^^ expected i8, found u16
+help: you can convert an `u16` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_u16.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:241:15
+  --> $DIR/numeric-cast.rs:228:15
    |
 LL |     foo::<i8>(x_u8);
    |               ^^^^ expected i8, found u8
+help: you can convert an `u8` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_u8.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:243:15
+  --> $DIR/numeric-cast.rs:230:15
    |
 LL |     foo::<i8>(x_isize);
    |               ^^^^^^^ expected i8, found isize
+help: you can convert an `isize` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_isize.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:245:15
+  --> $DIR/numeric-cast.rs:232:15
    |
 LL |     foo::<i8>(x_i64);
    |               ^^^^^ expected i8, found i64
+help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_i64.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:247:15
+  --> $DIR/numeric-cast.rs:234:15
    |
 LL |     foo::<i8>(x_i32);
    |               ^^^^^ expected i8, found i32
+help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit
+   |
+LL |     foo::<i8>(x_i32.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:249:15
+  --> $DIR/numeric-cast.rs:236:15
    |
 LL |     foo::<i8>(x_i16);
    |               ^^^^^ expected i8, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:252:15
-   |
-LL |     foo::<i8>(x_f64);
-   |               ^^^^^ expected i8, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:254:15
+help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit
    |
-LL |     foo::<i8>(x_f32);
-   |               ^^^^^ expected i8, found f32
+LL |     foo::<i8>(x_i16.try_into().unwrap());
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:257:16
+  --> $DIR/numeric-cast.rs:242:16
    |
 LL |     foo::<f64>(x_usize);
    |                ^^^^^^^ expected f64, found usize
+help: you can cast an `usize to `f64`, producing the floating point representation of the integer,
+   |                                              rounded if necessary
+LL |     foo::<f64>(x_usize as f64);
+   |                ^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:259:16
+  --> $DIR/numeric-cast.rs:244:16
    |
 LL |     foo::<f64>(x_u64);
    |                ^^^^^ expected f64, found u64
+help: you can cast an `u64 to `f64`, producing the floating point representation of the integer,
+   |                                              rounded if necessary
+LL |     foo::<f64>(x_u64 as f64);
+   |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:261:16
+  --> $DIR/numeric-cast.rs:246:16
    |
 LL |     foo::<f64>(x_u32);
    |                ^^^^^ expected f64, found u32
-help: you can cast an `u32` to `f64`, producing the floating point representation of the integer
+help: you can convert an `u32` to `f64`, producing the floating point representation of the integer
    |
 LL |     foo::<f64>(x_u32.into());
    |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:263:16
+  --> $DIR/numeric-cast.rs:248:16
    |
 LL |     foo::<f64>(x_u16);
    |                ^^^^^ expected f64, found u16
-help: you can cast an `u16` to `f64`, producing the floating point representation of the integer
+help: you can convert an `u16` to `f64`, producing the floating point representation of the integer
    |
 LL |     foo::<f64>(x_u16.into());
    |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:265:16
+  --> $DIR/numeric-cast.rs:250:16
    |
 LL |     foo::<f64>(x_u8);
    |                ^^^^ expected f64, found u8
-help: you can cast an `u8` to `f64`, producing the floating point representation of the integer
+help: you can convert an `u8` to `f64`, producing the floating point representation of the integer
    |
 LL |     foo::<f64>(x_u8.into());
    |                ^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:267:16
+  --> $DIR/numeric-cast.rs:252:16
    |
 LL |     foo::<f64>(x_isize);
    |                ^^^^^^^ expected f64, found isize
+help: you can convert an `isize` to `f64`, producing the floating point representation of the integer, rounded if necessary
+   |
+LL |     foo::<f64>(x_isize as f64);
+   |                ^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:269:16
+  --> $DIR/numeric-cast.rs:254:16
    |
 LL |     foo::<f64>(x_i64);
    |                ^^^^^ expected f64, found i64
+help: you can convert an `i64` to `f64`, producing the floating point representation of the integer, rounded if necessary
+   |
+LL |     foo::<f64>(x_i64 as f64);
+   |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:271:16
+  --> $DIR/numeric-cast.rs:256:16
    |
 LL |     foo::<f64>(x_i32);
    |                ^^^^^ expected f64, found i32
-help: you can cast an `i32` to `f64`, producing the floating point representation of the integer
+help: you can convert an `i32` to `f64`, producing the floating point representation of the integer
    |
 LL |     foo::<f64>(x_i32.into());
    |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:273:16
+  --> $DIR/numeric-cast.rs:258:16
    |
 LL |     foo::<f64>(x_i16);
    |                ^^^^^ expected f64, found i16
-help: you can cast an `i16` to `f64`, producing the floating point representation of the integer
+help: you can convert an `i16` to `f64`, producing the floating point representation of the integer
    |
 LL |     foo::<f64>(x_i16.into());
    |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:275:16
+  --> $DIR/numeric-cast.rs:260:16
    |
 LL |     foo::<f64>(x_i8);
    |                ^^^^ expected f64, found i8
-help: you can cast an `i8` to `f64`, producing the floating point representation of the integer
+help: you can convert an `i8` to `f64`, producing the floating point representation of the integer
    |
 LL |     foo::<f64>(x_i8.into());
    |                ^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:278:16
+  --> $DIR/numeric-cast.rs:263:16
    |
 LL |     foo::<f64>(x_f32);
-   |                ^^^^^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     foo::<f64>(x_f32.into());
-   |                ^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected f64, found f32
+   |                help: you can convert an `f32` to `f64`: `x_f32.into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:281:16
+  --> $DIR/numeric-cast.rs:266:16
    |
 LL |     foo::<f32>(x_usize);
    |                ^^^^^^^ expected f32, found usize
+help: you can cast an `usize to `f32`, producing the floating point representation of the integer,
+   |                                              rounded if necessary
+LL |     foo::<f32>(x_usize as f32);
+   |                ^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:283:16
+  --> $DIR/numeric-cast.rs:268:16
    |
 LL |     foo::<f32>(x_u64);
    |                ^^^^^ expected f32, found u64
+help: you can cast an `u64 to `f32`, producing the floating point representation of the integer,
+   |                                              rounded if necessary
+LL |     foo::<f32>(x_u64 as f32);
+   |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:285:16
+  --> $DIR/numeric-cast.rs:270:16
    |
 LL |     foo::<f32>(x_u32);
    |                ^^^^^ expected f32, found u32
+help: you can cast an `u32 to `f32`, producing the floating point representation of the integer,
+   |                                              rounded if necessary
+LL |     foo::<f32>(x_u32 as f32);
+   |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:287:16
+  --> $DIR/numeric-cast.rs:272:16
    |
 LL |     foo::<f32>(x_u16);
    |                ^^^^^ expected f32, found u16
-help: you can cast an `u16` to `f32`, producing the floating point representation of the integer
+help: you can convert an `u16` to `f32`, producing the floating point representation of the integer
    |
 LL |     foo::<f32>(x_u16.into());
    |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:289:16
+  --> $DIR/numeric-cast.rs:274:16
    |
 LL |     foo::<f32>(x_u8);
    |                ^^^^ expected f32, found u8
-help: you can cast an `u8` to `f32`, producing the floating point representation of the integer
+help: you can convert an `u8` to `f32`, producing the floating point representation of the integer
    |
 LL |     foo::<f32>(x_u8.into());
    |                ^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:291:16
+  --> $DIR/numeric-cast.rs:276:16
    |
 LL |     foo::<f32>(x_isize);
    |                ^^^^^^^ expected f32, found isize
+help: you can convert an `isize` to `f32`, producing the floating point representation of the integer, rounded if necessary
+   |
+LL |     foo::<f32>(x_isize as f32);
+   |                ^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:293:16
+  --> $DIR/numeric-cast.rs:278:16
    |
 LL |     foo::<f32>(x_i64);
    |                ^^^^^ expected f32, found i64
+help: you can convert an `i64` to `f32`, producing the floating point representation of the integer, rounded if necessary
+   |
+LL |     foo::<f32>(x_i64 as f32);
+   |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:295:16
+  --> $DIR/numeric-cast.rs:280:16
    |
 LL |     foo::<f32>(x_i32);
    |                ^^^^^ expected f32, found i32
+help: you can convert an `i32` to `f32`, producing the floating point representation of the integer, rounded if necessary
+   |
+LL |     foo::<f32>(x_i32 as f32);
+   |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:297:16
+  --> $DIR/numeric-cast.rs:282:16
    |
 LL |     foo::<f32>(x_i16);
    |                ^^^^^ expected f32, found i16
-help: you can cast an `i16` to `f32`, producing the floating point representation of the integer
+help: you can convert an `i16` to `f32`, producing the floating point representation of the integer
    |
 LL |     foo::<f32>(x_i16.into());
    |                ^^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:299:16
+  --> $DIR/numeric-cast.rs:284:16
    |
 LL |     foo::<f32>(x_i8);
    |                ^^^^ expected f32, found i8
-help: you can cast an `i8` to `f32`, producing the floating point representation of the integer
+help: you can convert an `i8` to `f32`, producing the floating point representation of the integer
    |
 LL |     foo::<f32>(x_i8.into());
    |                ^^^^^^^^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:301:16
-   |
-LL |     foo::<f32>(x_f64);
-   |                ^^^^^ expected f32, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:305:16
+  --> $DIR/numeric-cast.rs:289:16
    |
 LL |     foo::<u32>(x_u8 as u16);
-   |                ^^^^^^^^^^^ expected u32, found u16
-help: you can cast an `u16` to `u32`, which will zero-extend the source value
-   |
-LL |     foo::<u32>((x_u8 as u16).into());
-   |                ^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^
+   |                |
+   |                expected u32, found u16
+   |                help: you can convert an `u16` to `u32`: `(x_u8 as u16).into()`
 
 error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:307:16
+  --> $DIR/numeric-cast.rs:291:16
    |
 LL |     foo::<i32>(-x_i8);
-   |                ^^^^^ expected i32, found i8
-help: you can cast an `i8` to `i32`, which will sign-extend the source value
-   |
-LL |     foo::<i32>((-x_i8).into());
-   |                ^^^^^^^^^^^^^^
+   |                ^^^^^
+   |                |
+   |                expected i32, found i8
+   |                help: you can convert an `i8` to `i32`: `(-x_i8).into()`
 
-error: aborting due to 134 previous errors
+error: aborting due to 113 previous errors
 
 For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/numeric/numeric-suffix.fixed b/src/test/ui/numeric/numeric-suffix.fixed
new file mode 100644 (file)
index 0000000..53c5fe0
--- /dev/null
@@ -0,0 +1,298 @@
+// run-rustfix
+
+fn foo<N>(_x: N) {}
+
+fn main() {
+    foo::<usize>(42_usize);
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42usize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42usize);
+    //~^ ERROR mismatched types
+
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42isize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42isize);
+    //~^ ERROR mismatched types
+
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42u64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42u64);
+    //~^ ERROR mismatched types
+
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42i64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42i64);
+    //~^ ERROR mismatched types
+
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42u32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42u32);
+    //~^ ERROR mismatched types
+
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42i32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42i32);
+    //~^ ERROR mismatched types
+
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42u16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42u16);
+    //~^ ERROR mismatched types
+
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    foo::<i16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42i16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42i16);
+    //~^ ERROR mismatched types
+
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42u8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42u8);
+    //~^ ERROR mismatched types
+
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    foo::<i8>(42i8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42i8);
+    //~^ ERROR mismatched types
+
+    foo::<f64>(42_f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u32.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u16.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u8.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(42_f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_f64);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i32.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i16.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i8.into());
+    //~^ ERROR mismatched types
+    foo::<f64>(42.0_f64);
+    foo::<f64>(42.0_f64);
+    //~^ ERROR mismatched types
+
+    foo::<f32>(42_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_u16.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(42_u8.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(42_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_i16.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(42_i8.into());
+    //~^ ERROR mismatched types
+    foo::<f32>(42.0_f32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42.0_f32);
+
+    foo::<u32>((42_u8 as u16).into());
+    //~^ ERROR mismatched types
+    foo::<i32>((-42_i8).into());
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/numeric/numeric-suffix.rs b/src/test/ui/numeric/numeric-suffix.rs
new file mode 100644 (file)
index 0000000..ca38ed8
--- /dev/null
@@ -0,0 +1,298 @@
+// run-rustfix
+
+fn foo<N>(_x: N) {}
+
+fn main() {
+    foo::<usize>(42_usize);
+    foo::<usize>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<usize>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<usize>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<usize>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<isize>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_isize);
+    foo::<isize>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<isize>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<isize>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<isize>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u64>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u64);
+    foo::<u64>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<u64>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<u64>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<u64>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i64>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i64);
+    foo::<i64>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i64>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i64>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<i64>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u32>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u32);
+    foo::<u32>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<u32>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<u32>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<u32>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i32>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i32);
+    foo::<i32>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i32>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i32>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<i32>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u16>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_u16);
+    foo::<u16>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<u16>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<u16>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<u16>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i16>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i16>(42_i16);
+    foo::<i16>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<i16>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<i16>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u8>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_u8);
+    foo::<u8>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<u8>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<u8>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<u8>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i8>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<i8>(42_i8);
+    foo::<i8>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<i8>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<f64>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<f64>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<f64>(42.0_f64);
+    foo::<f64>(42.0_f32);
+    //~^ ERROR mismatched types
+
+    foo::<f32>(42_usize);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_u64);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_u32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_u16);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_u8);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_isize);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_i64);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_i32);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_i16);
+    //~^ ERROR mismatched types
+    foo::<f32>(42_i8);
+    //~^ ERROR mismatched types
+    foo::<f32>(42.0_f64);
+    //~^ ERROR mismatched types
+    foo::<f32>(42.0_f32);
+
+    foo::<u32>(42_u8 as u16);
+    //~^ ERROR mismatched types
+    foo::<i32>(-42_i8);
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/numeric/numeric-suffix.stderr b/src/test/ui/numeric/numeric-suffix.stderr
new file mode 100644 (file)
index 0000000..c88eeeb
--- /dev/null
@@ -0,0 +1,1341 @@
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:7:18
+   |
+LL |     foo::<usize>(42_u64);
+   |                  ^^^^^^ expected usize, found u64
+help: change the type of the numeric literal from `u64` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:9:18
+   |
+LL |     foo::<usize>(42_u32);
+   |                  ^^^^^^ expected usize, found u32
+help: change the type of the numeric literal from `u32` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:11:18
+   |
+LL |     foo::<usize>(42_u16);
+   |                  ^^^^^^ expected usize, found u16
+help: change the type of the numeric literal from `u16` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:13:18
+   |
+LL |     foo::<usize>(42_u8);
+   |                  ^^^^^ expected usize, found u8
+help: change the type of the numeric literal from `u8` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:15:18
+   |
+LL |     foo::<usize>(42_isize);
+   |                  ^^^^^^^^ expected usize, found isize
+help: change the type of the numeric literal from `isize` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:17:18
+   |
+LL |     foo::<usize>(42_i64);
+   |                  ^^^^^^ expected usize, found i64
+help: change the type of the numeric literal from `i64` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:19:18
+   |
+LL |     foo::<usize>(42_i32);
+   |                  ^^^^^^ expected usize, found i32
+help: change the type of the numeric literal from `i32` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:21:18
+   |
+LL |     foo::<usize>(42_i16);
+   |                  ^^^^^^ expected usize, found i16
+help: change the type of the numeric literal from `i16` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:23:18
+   |
+LL |     foo::<usize>(42_i8);
+   |                  ^^^^^ expected usize, found i8
+help: change the type of the numeric literal from `i8` to `usize`
+   |
+LL |     foo::<usize>(42_usize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:25:18
+   |
+LL |     foo::<usize>(42.0_f64);
+   |                  ^^^^^^^^ expected usize, found f64
+help: change the type of the numeric literal from `f64` to `usize`
+   |
+LL |     foo::<usize>(42usize);
+   |                  ^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:27:18
+   |
+LL |     foo::<usize>(42.0_f32);
+   |                  ^^^^^^^^ expected usize, found f32
+help: change the type of the numeric literal from `f32` to `usize`
+   |
+LL |     foo::<usize>(42usize);
+   |                  ^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:30:18
+   |
+LL |     foo::<isize>(42_usize);
+   |                  ^^^^^^^^ expected isize, found usize
+help: change the type of the numeric literal from `usize` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:32:18
+   |
+LL |     foo::<isize>(42_u64);
+   |                  ^^^^^^ expected isize, found u64
+help: change the type of the numeric literal from `u64` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:34:18
+   |
+LL |     foo::<isize>(42_u32);
+   |                  ^^^^^^ expected isize, found u32
+help: change the type of the numeric literal from `u32` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:36:18
+   |
+LL |     foo::<isize>(42_u16);
+   |                  ^^^^^^ expected isize, found u16
+help: change the type of the numeric literal from `u16` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:38:18
+   |
+LL |     foo::<isize>(42_u8);
+   |                  ^^^^^ expected isize, found u8
+help: change the type of the numeric literal from `u8` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:41:18
+   |
+LL |     foo::<isize>(42_i64);
+   |                  ^^^^^^ expected isize, found i64
+help: change the type of the numeric literal from `i64` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:43:18
+   |
+LL |     foo::<isize>(42_i32);
+   |                  ^^^^^^ expected isize, found i32
+help: change the type of the numeric literal from `i32` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:45:18
+   |
+LL |     foo::<isize>(42_i16);
+   |                  ^^^^^^ expected isize, found i16
+help: change the type of the numeric literal from `i16` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:47:18
+   |
+LL |     foo::<isize>(42_i8);
+   |                  ^^^^^ expected isize, found i8
+help: change the type of the numeric literal from `i8` to `isize`
+   |
+LL |     foo::<isize>(42_isize);
+   |                  ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:49:18
+   |
+LL |     foo::<isize>(42.0_f64);
+   |                  ^^^^^^^^ expected isize, found f64
+help: change the type of the numeric literal from `f64` to `isize`
+   |
+LL |     foo::<isize>(42isize);
+   |                  ^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:51:18
+   |
+LL |     foo::<isize>(42.0_f32);
+   |                  ^^^^^^^^ expected isize, found f32
+help: change the type of the numeric literal from `f32` to `isize`
+   |
+LL |     foo::<isize>(42isize);
+   |                  ^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:54:16
+   |
+LL |     foo::<u64>(42_usize);
+   |                ^^^^^^^^ expected u64, found usize
+help: change the type of the numeric literal from `usize` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:57:16
+   |
+LL |     foo::<u64>(42_u32);
+   |                ^^^^^^ expected u64, found u32
+help: change the type of the numeric literal from `u32` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:59:16
+   |
+LL |     foo::<u64>(42_u16);
+   |                ^^^^^^ expected u64, found u16
+help: change the type of the numeric literal from `u16` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:61:16
+   |
+LL |     foo::<u64>(42_u8);
+   |                ^^^^^ expected u64, found u8
+help: change the type of the numeric literal from `u8` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:63:16
+   |
+LL |     foo::<u64>(42_isize);
+   |                ^^^^^^^^ expected u64, found isize
+help: change the type of the numeric literal from `isize` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:65:16
+   |
+LL |     foo::<u64>(42_i64);
+   |                ^^^^^^ expected u64, found i64
+help: change the type of the numeric literal from `i64` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:67:16
+   |
+LL |     foo::<u64>(42_i32);
+   |                ^^^^^^ expected u64, found i32
+help: change the type of the numeric literal from `i32` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:69:16
+   |
+LL |     foo::<u64>(42_i16);
+   |                ^^^^^^ expected u64, found i16
+help: change the type of the numeric literal from `i16` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:71:16
+   |
+LL |     foo::<u64>(42_i8);
+   |                ^^^^^ expected u64, found i8
+help: change the type of the numeric literal from `i8` to `u64`
+   |
+LL |     foo::<u64>(42_u64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:73:16
+   |
+LL |     foo::<u64>(42.0_f64);
+   |                ^^^^^^^^ expected u64, found f64
+help: change the type of the numeric literal from `f64` to `u64`
+   |
+LL |     foo::<u64>(42u64);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:75:16
+   |
+LL |     foo::<u64>(42.0_f32);
+   |                ^^^^^^^^ expected u64, found f32
+help: change the type of the numeric literal from `f32` to `u64`
+   |
+LL |     foo::<u64>(42u64);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:78:16
+   |
+LL |     foo::<i64>(42_usize);
+   |                ^^^^^^^^ expected i64, found usize
+help: change the type of the numeric literal from `usize` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:80:16
+   |
+LL |     foo::<i64>(42_u64);
+   |                ^^^^^^ expected i64, found u64
+help: change the type of the numeric literal from `u64` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:82:16
+   |
+LL |     foo::<i64>(42_u32);
+   |                ^^^^^^ expected i64, found u32
+help: change the type of the numeric literal from `u32` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:84:16
+   |
+LL |     foo::<i64>(42_u16);
+   |                ^^^^^^ expected i64, found u16
+help: change the type of the numeric literal from `u16` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:86:16
+   |
+LL |     foo::<i64>(42_u8);
+   |                ^^^^^ expected i64, found u8
+help: change the type of the numeric literal from `u8` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:88:16
+   |
+LL |     foo::<i64>(42_isize);
+   |                ^^^^^^^^ expected i64, found isize
+help: change the type of the numeric literal from `isize` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:91:16
+   |
+LL |     foo::<i64>(42_i32);
+   |                ^^^^^^ expected i64, found i32
+help: change the type of the numeric literal from `i32` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:93:16
+   |
+LL |     foo::<i64>(42_i16);
+   |                ^^^^^^ expected i64, found i16
+help: change the type of the numeric literal from `i16` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:95:16
+   |
+LL |     foo::<i64>(42_i8);
+   |                ^^^^^ expected i64, found i8
+help: change the type of the numeric literal from `i8` to `i64`
+   |
+LL |     foo::<i64>(42_i64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:97:16
+   |
+LL |     foo::<i64>(42.0_f64);
+   |                ^^^^^^^^ expected i64, found f64
+help: change the type of the numeric literal from `f64` to `i64`
+   |
+LL |     foo::<i64>(42i64);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:99:16
+   |
+LL |     foo::<i64>(42.0_f32);
+   |                ^^^^^^^^ expected i64, found f32
+help: change the type of the numeric literal from `f32` to `i64`
+   |
+LL |     foo::<i64>(42i64);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:102:16
+   |
+LL |     foo::<u32>(42_usize);
+   |                ^^^^^^^^ expected u32, found usize
+help: change the type of the numeric literal from `usize` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:104:16
+   |
+LL |     foo::<u32>(42_u64);
+   |                ^^^^^^ expected u32, found u64
+help: change the type of the numeric literal from `u64` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:107:16
+   |
+LL |     foo::<u32>(42_u16);
+   |                ^^^^^^ expected u32, found u16
+help: change the type of the numeric literal from `u16` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:109:16
+   |
+LL |     foo::<u32>(42_u8);
+   |                ^^^^^ expected u32, found u8
+help: change the type of the numeric literal from `u8` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:111:16
+   |
+LL |     foo::<u32>(42_isize);
+   |                ^^^^^^^^ expected u32, found isize
+help: change the type of the numeric literal from `isize` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:113:16
+   |
+LL |     foo::<u32>(42_i64);
+   |                ^^^^^^ expected u32, found i64
+help: change the type of the numeric literal from `i64` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:115:16
+   |
+LL |     foo::<u32>(42_i32);
+   |                ^^^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:117:16
+   |
+LL |     foo::<u32>(42_i16);
+   |                ^^^^^^ expected u32, found i16
+help: change the type of the numeric literal from `i16` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:119:16
+   |
+LL |     foo::<u32>(42_i8);
+   |                ^^^^^ expected u32, found i8
+help: change the type of the numeric literal from `i8` to `u32`
+   |
+LL |     foo::<u32>(42_u32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:121:16
+   |
+LL |     foo::<u32>(42.0_f64);
+   |                ^^^^^^^^ expected u32, found f64
+help: change the type of the numeric literal from `f64` to `u32`
+   |
+LL |     foo::<u32>(42u32);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:123:16
+   |
+LL |     foo::<u32>(42.0_f32);
+   |                ^^^^^^^^ expected u32, found f32
+help: change the type of the numeric literal from `f32` to `u32`
+   |
+LL |     foo::<u32>(42u32);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:126:16
+   |
+LL |     foo::<i32>(42_usize);
+   |                ^^^^^^^^ expected i32, found usize
+help: change the type of the numeric literal from `usize` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:128:16
+   |
+LL |     foo::<i32>(42_u64);
+   |                ^^^^^^ expected i32, found u64
+help: change the type of the numeric literal from `u64` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:130:16
+   |
+LL |     foo::<i32>(42_u32);
+   |                ^^^^^^ expected i32, found u32
+help: change the type of the numeric literal from `u32` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:132:16
+   |
+LL |     foo::<i32>(42_u16);
+   |                ^^^^^^ expected i32, found u16
+help: change the type of the numeric literal from `u16` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:134:16
+   |
+LL |     foo::<i32>(42_u8);
+   |                ^^^^^ expected i32, found u8
+help: change the type of the numeric literal from `u8` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:136:16
+   |
+LL |     foo::<i32>(42_isize);
+   |                ^^^^^^^^ expected i32, found isize
+help: change the type of the numeric literal from `isize` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:138:16
+   |
+LL |     foo::<i32>(42_i64);
+   |                ^^^^^^ expected i32, found i64
+help: change the type of the numeric literal from `i64` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:141:16
+   |
+LL |     foo::<i32>(42_i16);
+   |                ^^^^^^ expected i32, found i16
+help: change the type of the numeric literal from `i16` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:143:16
+   |
+LL |     foo::<i32>(42_i8);
+   |                ^^^^^ expected i32, found i8
+help: change the type of the numeric literal from `i8` to `i32`
+   |
+LL |     foo::<i32>(42_i32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:145:16
+   |
+LL |     foo::<i32>(42.0_f64);
+   |                ^^^^^^^^ expected i32, found f64
+help: change the type of the numeric literal from `f64` to `i32`
+   |
+LL |     foo::<i32>(42i32);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:147:16
+   |
+LL |     foo::<i32>(42.0_f32);
+   |                ^^^^^^^^ expected i32, found f32
+help: change the type of the numeric literal from `f32` to `i32`
+   |
+LL |     foo::<i32>(42i32);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:150:16
+   |
+LL |     foo::<u16>(42_usize);
+   |                ^^^^^^^^ expected u16, found usize
+help: change the type of the numeric literal from `usize` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:152:16
+   |
+LL |     foo::<u16>(42_u64);
+   |                ^^^^^^ expected u16, found u64
+help: change the type of the numeric literal from `u64` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:154:16
+   |
+LL |     foo::<u16>(42_u32);
+   |                ^^^^^^ expected u16, found u32
+help: change the type of the numeric literal from `u32` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:157:16
+   |
+LL |     foo::<u16>(42_u8);
+   |                ^^^^^ expected u16, found u8
+help: change the type of the numeric literal from `u8` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:159:16
+   |
+LL |     foo::<u16>(42_isize);
+   |                ^^^^^^^^ expected u16, found isize
+help: change the type of the numeric literal from `isize` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:161:16
+   |
+LL |     foo::<u16>(42_i64);
+   |                ^^^^^^ expected u16, found i64
+help: change the type of the numeric literal from `i64` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:163:16
+   |
+LL |     foo::<u16>(42_i32);
+   |                ^^^^^^ expected u16, found i32
+help: change the type of the numeric literal from `i32` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:165:16
+   |
+LL |     foo::<u16>(42_i16);
+   |                ^^^^^^ expected u16, found i16
+help: change the type of the numeric literal from `i16` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:167:16
+   |
+LL |     foo::<u16>(42_i8);
+   |                ^^^^^ expected u16, found i8
+help: change the type of the numeric literal from `i8` to `u16`
+   |
+LL |     foo::<u16>(42_u16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:169:16
+   |
+LL |     foo::<u16>(42.0_f64);
+   |                ^^^^^^^^ expected u16, found f64
+help: change the type of the numeric literal from `f64` to `u16`
+   |
+LL |     foo::<u16>(42u16);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:171:16
+   |
+LL |     foo::<u16>(42.0_f32);
+   |                ^^^^^^^^ expected u16, found f32
+help: change the type of the numeric literal from `f32` to `u16`
+   |
+LL |     foo::<u16>(42u16);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:174:16
+   |
+LL |     foo::<i16>(42_usize);
+   |                ^^^^^^^^ expected i16, found usize
+help: change the type of the numeric literal from `usize` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:176:16
+   |
+LL |     foo::<i16>(42_u64);
+   |                ^^^^^^ expected i16, found u64
+help: change the type of the numeric literal from `u64` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:178:16
+   |
+LL |     foo::<i16>(42_u32);
+   |                ^^^^^^ expected i16, found u32
+help: change the type of the numeric literal from `u32` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:180:16
+   |
+LL |     foo::<i16>(42_u16);
+   |                ^^^^^^ expected i16, found u16
+help: change the type of the numeric literal from `u16` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:182:16
+   |
+LL |     foo::<i16>(42_u8);
+   |                ^^^^^ expected i16, found u8
+help: change the type of the numeric literal from `u8` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:184:16
+   |
+LL |     foo::<i16>(42_isize);
+   |                ^^^^^^^^ expected i16, found isize
+help: change the type of the numeric literal from `isize` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:186:16
+   |
+LL |     foo::<i16>(42_i64);
+   |                ^^^^^^ expected i16, found i64
+help: change the type of the numeric literal from `i64` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:188:16
+   |
+LL |     foo::<i16>(42_i32);
+   |                ^^^^^^ expected i16, found i32
+help: change the type of the numeric literal from `i32` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:191:16
+   |
+LL |     foo::<i16>(42_i8);
+   |                ^^^^^ expected i16, found i8
+help: change the type of the numeric literal from `i8` to `i16`
+   |
+LL |     foo::<i16>(42_i16);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:193:16
+   |
+LL |     foo::<i16>(42.0_f64);
+   |                ^^^^^^^^ expected i16, found f64
+help: change the type of the numeric literal from `f64` to `i16`
+   |
+LL |     foo::<i16>(42i16);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:195:16
+   |
+LL |     foo::<i16>(42.0_f32);
+   |                ^^^^^^^^ expected i16, found f32
+help: change the type of the numeric literal from `f32` to `i16`
+   |
+LL |     foo::<i16>(42i16);
+   |                ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:198:15
+   |
+LL |     foo::<u8>(42_usize);
+   |               ^^^^^^^^ expected u8, found usize
+help: change the type of the numeric literal from `usize` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:200:15
+   |
+LL |     foo::<u8>(42_u64);
+   |               ^^^^^^ expected u8, found u64
+help: change the type of the numeric literal from `u64` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:202:15
+   |
+LL |     foo::<u8>(42_u32);
+   |               ^^^^^^ expected u8, found u32
+help: change the type of the numeric literal from `u32` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:204:15
+   |
+LL |     foo::<u8>(42_u16);
+   |               ^^^^^^ expected u8, found u16
+help: change the type of the numeric literal from `u16` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:207:15
+   |
+LL |     foo::<u8>(42_isize);
+   |               ^^^^^^^^ expected u8, found isize
+help: change the type of the numeric literal from `isize` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:209:15
+   |
+LL |     foo::<u8>(42_i64);
+   |               ^^^^^^ expected u8, found i64
+help: change the type of the numeric literal from `i64` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:211:15
+   |
+LL |     foo::<u8>(42_i32);
+   |               ^^^^^^ expected u8, found i32
+help: change the type of the numeric literal from `i32` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:213:15
+   |
+LL |     foo::<u8>(42_i16);
+   |               ^^^^^^ expected u8, found i16
+help: change the type of the numeric literal from `i16` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:215:15
+   |
+LL |     foo::<u8>(42_i8);
+   |               ^^^^^ expected u8, found i8
+help: change the type of the numeric literal from `i8` to `u8`
+   |
+LL |     foo::<u8>(42_u8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:217:15
+   |
+LL |     foo::<u8>(42.0_f64);
+   |               ^^^^^^^^ expected u8, found f64
+help: change the type of the numeric literal from `f64` to `u8`
+   |
+LL |     foo::<u8>(42u8);
+   |               ^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:219:15
+   |
+LL |     foo::<u8>(42.0_f32);
+   |               ^^^^^^^^ expected u8, found f32
+help: change the type of the numeric literal from `f32` to `u8`
+   |
+LL |     foo::<u8>(42u8);
+   |               ^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:222:15
+   |
+LL |     foo::<i8>(42_usize);
+   |               ^^^^^^^^ expected i8, found usize
+help: change the type of the numeric literal from `usize` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:224:15
+   |
+LL |     foo::<i8>(42_u64);
+   |               ^^^^^^ expected i8, found u64
+help: change the type of the numeric literal from `u64` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:226:15
+   |
+LL |     foo::<i8>(42_u32);
+   |               ^^^^^^ expected i8, found u32
+help: change the type of the numeric literal from `u32` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:228:15
+   |
+LL |     foo::<i8>(42_u16);
+   |               ^^^^^^ expected i8, found u16
+help: change the type of the numeric literal from `u16` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:230:15
+   |
+LL |     foo::<i8>(42_u8);
+   |               ^^^^^ expected i8, found u8
+help: change the type of the numeric literal from `u8` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:232:15
+   |
+LL |     foo::<i8>(42_isize);
+   |               ^^^^^^^^ expected i8, found isize
+help: change the type of the numeric literal from `isize` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:234:15
+   |
+LL |     foo::<i8>(42_i64);
+   |               ^^^^^^ expected i8, found i64
+help: change the type of the numeric literal from `i64` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:236:15
+   |
+LL |     foo::<i8>(42_i32);
+   |               ^^^^^^ expected i8, found i32
+help: change the type of the numeric literal from `i32` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:238:15
+   |
+LL |     foo::<i8>(42_i16);
+   |               ^^^^^^ expected i8, found i16
+help: change the type of the numeric literal from `i16` to `i8`
+   |
+LL |     foo::<i8>(42_i8);
+   |               ^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:241:15
+   |
+LL |     foo::<i8>(42.0_f64);
+   |               ^^^^^^^^ expected i8, found f64
+help: change the type of the numeric literal from `f64` to `i8`
+   |
+LL |     foo::<i8>(42i8);
+   |               ^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:243:15
+   |
+LL |     foo::<i8>(42.0_f32);
+   |               ^^^^^^^^ expected i8, found f32
+help: change the type of the numeric literal from `f32` to `i8`
+   |
+LL |     foo::<i8>(42i8);
+   |               ^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:246:16
+   |
+LL |     foo::<f64>(42_usize);
+   |                ^^^^^^^^ expected f64, found usize
+help: change the type of the numeric literal from `usize` to `f64`
+   |
+LL |     foo::<f64>(42_f64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:248:16
+   |
+LL |     foo::<f64>(42_u64);
+   |                ^^^^^^ expected f64, found u64
+help: change the type of the numeric literal from `u64` to `f64`
+   |
+LL |     foo::<f64>(42_f64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:250:16
+   |
+LL |     foo::<f64>(42_u32);
+   |                ^^^^^^ expected f64, found u32
+help: you can convert an `u32` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(42_u32.into());
+   |                ^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:252:16
+   |
+LL |     foo::<f64>(42_u16);
+   |                ^^^^^^ expected f64, found u16
+help: you can convert an `u16` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(42_u16.into());
+   |                ^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:254:16
+   |
+LL |     foo::<f64>(42_u8);
+   |                ^^^^^ expected f64, found u8
+help: you can convert an `u8` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(42_u8.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:256:16
+   |
+LL |     foo::<f64>(42_isize);
+   |                ^^^^^^^^ expected f64, found isize
+help: change the type of the numeric literal from `isize` to `f64`
+   |
+LL |     foo::<f64>(42_f64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:258:16
+   |
+LL |     foo::<f64>(42_i64);
+   |                ^^^^^^ expected f64, found i64
+help: change the type of the numeric literal from `i64` to `f64`
+   |
+LL |     foo::<f64>(42_f64);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:260:16
+   |
+LL |     foo::<f64>(42_i32);
+   |                ^^^^^^ expected f64, found i32
+help: you can convert an `i32` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(42_i32.into());
+   |                ^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:262:16
+   |
+LL |     foo::<f64>(42_i16);
+   |                ^^^^^^ expected f64, found i16
+help: you can convert an `i16` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(42_i16.into());
+   |                ^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:264:16
+   |
+LL |     foo::<f64>(42_i8);
+   |                ^^^^^ expected f64, found i8
+help: you can convert an `i8` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(42_i8.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:267:16
+   |
+LL |     foo::<f64>(42.0_f32);
+   |                ^^^^^^^^ expected f64, found f32
+help: change the type of the numeric literal from `f32` to `f64`
+   |
+LL |     foo::<f64>(42.0_f64);
+   |                ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:270:16
+   |
+LL |     foo::<f32>(42_usize);
+   |                ^^^^^^^^ expected f32, found usize
+help: change the type of the numeric literal from `usize` to `f32`
+   |
+LL |     foo::<f32>(42_f32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:272:16
+   |
+LL |     foo::<f32>(42_u64);
+   |                ^^^^^^ expected f32, found u64
+help: change the type of the numeric literal from `u64` to `f32`
+   |
+LL |     foo::<f32>(42_f32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:274:16
+   |
+LL |     foo::<f32>(42_u32);
+   |                ^^^^^^ expected f32, found u32
+help: change the type of the numeric literal from `u32` to `f32`
+   |
+LL |     foo::<f32>(42_f32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:276:16
+   |
+LL |     foo::<f32>(42_u16);
+   |                ^^^^^^ expected f32, found u16
+help: you can convert an `u16` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(42_u16.into());
+   |                ^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:278:16
+   |
+LL |     foo::<f32>(42_u8);
+   |                ^^^^^ expected f32, found u8
+help: you can convert an `u8` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(42_u8.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:280:16
+   |
+LL |     foo::<f32>(42_isize);
+   |                ^^^^^^^^ expected f32, found isize
+help: change the type of the numeric literal from `isize` to `f32`
+   |
+LL |     foo::<f32>(42_f32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:282:16
+   |
+LL |     foo::<f32>(42_i64);
+   |                ^^^^^^ expected f32, found i64
+help: change the type of the numeric literal from `i64` to `f32`
+   |
+LL |     foo::<f32>(42_f32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:284:16
+   |
+LL |     foo::<f32>(42_i32);
+   |                ^^^^^^ expected f32, found i32
+help: change the type of the numeric literal from `i32` to `f32`
+   |
+LL |     foo::<f32>(42_f32);
+   |                ^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:286:16
+   |
+LL |     foo::<f32>(42_i16);
+   |                ^^^^^^ expected f32, found i16
+help: you can convert an `i16` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(42_i16.into());
+   |                ^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:288:16
+   |
+LL |     foo::<f32>(42_i8);
+   |                ^^^^^ expected f32, found i8
+help: you can convert an `i8` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(42_i8.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:290:16
+   |
+LL |     foo::<f32>(42.0_f64);
+   |                ^^^^^^^^ expected f32, found f64
+help: change the type of the numeric literal from `f64` to `f32`
+   |
+LL |     foo::<f32>(42.0_f32);
+   |                ^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:294:16
+   |
+LL |     foo::<u32>(42_u8 as u16);
+   |                ^^^^^^^^^^^^
+   |                |
+   |                expected u32, found u16
+   |                help: you can convert an `u16` to `u32`: `(42_u8 as u16).into()`
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-suffix.rs:296:16
+   |
+LL |     foo::<i32>(-42_i8);
+   |                ^^^^^^
+   |                |
+   |                expected i32, found i8
+   |                help: you can convert an `i8` to `i32`: `(-42_i8).into()`
+
+error: aborting due to 134 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
index 32ee1a6aae99df40ff77cecebadc04472a2ade88..dc4b3ce370cb168d19734970aa10a3b9030057a6 100644 (file)
@@ -3,12 +3,20 @@ error[E0308]: mismatched types
    |
 LL |     let_in(3u32, |i| { assert!(i == 3i32); });
    |                                     ^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |     let_in(3u32, |i| { assert!(i == 3u32); });
+   |                                     ^^^^
 
 error[E0308]: mismatched types
   --> $DIR/pptypedef.rs:8:37
    |
 LL |     let_in(3i32, |i| { assert!(i == 3u32); });
    |                                     ^^^^ expected i32, found u32
+help: change the type of the numeric literal from `u32` to `i32`
+   |
+LL |     let_in(3i32, |i| { assert!(i == 3i32); });
+   |                                     ^^^^
 
 error: aborting due to 2 previous errors
 
index d4c2edf993ed45180254fe7091db127f363e8198..6772aa1c38d2c7bfe4144a24152c49d144008e6b 100644 (file)
@@ -42,12 +42,20 @@ error[E0308]: mismatched types
    |
 LL |     let f = [0; -4_isize];
    |                 ^^^^^^^^ expected usize, found isize
+help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     let f = [0; (-4_isize).try_into().unwrap()];
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/repeat_count.rs:28:23
    |
 LL |     let f = [0_usize; -1_isize];
    |                       ^^^^^^^^ expected usize, found isize
+help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit
+   |
+LL |     let f = [0_usize; (-1_isize).try_into().unwrap()];
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/repeat_count.rs:34:17
index 8ffc0f1ea08cc4203ec51e934f98b35688b6c018..97523fe82cd4ed4269af260b02f4aad82e3e2fe6 100644 (file)
@@ -27,6 +27,10 @@ error[E0308]: mismatched types
    |
 LL |     let _: i32 = 22_i64 >> 1_i32;
    |                  ^^^^^^^^^^^^^^^ expected i32, found i64
+help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit
+   |
+LL |     let _: i32 = (22_i64 >> 1_i32).try_into().unwrap();
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/suggestions/recover-invalid-float.fixed b/src/test/ui/suggestions/recover-invalid-float.fixed
new file mode 100644 (file)
index 0000000..62389ba
--- /dev/null
@@ -0,0 +1,10 @@
+// run-rustfix
+
+fn main() {
+    let _: f32 = 0.3;
+    //~^ ERROR float literals must have an integer part
+    let _: f32 = 0.42f32;
+    //~^ ERROR float literals must have an integer part
+    let _: f64 = 0.5f64;
+    //~^ ERROR float literals must have an integer part
+}
index 506ef8900b881e69d95737365d0dc00135ec19a0..a5a7efe5e76e8e9d3ddfd776f2dd2e20f58d0d5d 100644 (file)
@@ -1,11 +1,10 @@
+// run-rustfix
+
 fn main() {
-    let _: usize = .3;
+    let _: f32 = .3;
     //~^ ERROR float literals must have an integer part
-    //~| ERROR mismatched types
-    let _: usize = .42f32;
+    let _: f32 = .42f32;
     //~^ ERROR float literals must have an integer part
-    //~| ERROR mismatched types
-    let _: usize = .5f64;
+    let _: f64 = .5f64;
     //~^ ERROR float literals must have an integer part
-    //~| ERROR mismatched types
 }
index c464676b444cc391344ad6ba0ceac1c5b058269f..dd24746eab80f435dfdfb12f93225ea8a3fa9f68 100644 (file)
@@ -1,42 +1,20 @@
 error: float literals must have an integer part
-  --> $DIR/recover-invalid-float.rs:2:20
+  --> $DIR/recover-invalid-float.rs:4:18
    |
-LL |     let _: usize = .3;
-   |                    ^^ help: must have an integer part: `0.3`
+LL |     let _: f32 = .3;
+   |                  ^^ help: must have an integer part: `0.3`
 
 error: float literals must have an integer part
-  --> $DIR/recover-invalid-float.rs:5:20
+  --> $DIR/recover-invalid-float.rs:6:18
    |
-LL |     let _: usize = .42f32;
-   |                    ^^^^^^ help: must have an integer part: `0.42f32`
+LL |     let _: f32 = .42f32;
+   |                  ^^^^^^ help: must have an integer part: `0.42f32`
 
 error: float literals must have an integer part
-  --> $DIR/recover-invalid-float.rs:8:20
+  --> $DIR/recover-invalid-float.rs:8:18
    |
-LL |     let _: usize = .5f64;
-   |                    ^^^^^ help: must have an integer part: `0.5f64`
+LL |     let _: f64 = .5f64;
+   |                  ^^^^^ help: must have an integer part: `0.5f64`
 
-error[E0308]: mismatched types
-  --> $DIR/recover-invalid-float.rs:2:20
-   |
-LL |     let _: usize = .3;
-   |                    ^^ expected usize, found floating-point number
-   |
-   = note: expected type `usize`
-              found type `{float}`
-
-error[E0308]: mismatched types
-  --> $DIR/recover-invalid-float.rs:5:20
-   |
-LL |     let _: usize = .42f32;
-   |                    ^^^^^^ expected usize, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/recover-invalid-float.rs:8:20
-   |
-LL |     let _: usize = .5f64;
-   |                    ^^^^^ expected usize, found f64
-
-error: aborting due to 6 previous errors
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
index f86351c19922c5fe15234cecab42e0002023d520..a25c644680ee0bf40206cad391e9f3a7441bacb0 100644 (file)
@@ -2,21 +2,19 @@ error[E0308]: mismatched types
   --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:19
    |
 LL |     let _ = RGB { r, g, c };
-   |                   ^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     let _ = RGB { r: r.into(), g, c };
-   |                   ^^^^^^^^^^^
+   |                   ^
+   |                   |
+   |                   expected f64, found f32
+   |                   help: you can convert an `f32` to `f64`: `r: r.into()`
 
 error[E0308]: mismatched types
   --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:22
    |
 LL |     let _ = RGB { r, g, c };
-   |                      ^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     let _ = RGB { r, g: g.into(), c };
-   |                      ^^^^^^^^^^^
+   |                      ^
+   |                      |
+   |                      expected f64, found f32
+   |                      help: you can convert an `f32` to `f64`: `g: g.into()`
 
 error[E0560]: struct `RGB` has no field named `c`
   --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:25
index 6bc16ba8b70fa927c25cc1657401649dce32f244..ed8013d5997e43c0c12cb9d885fdefb9455ebbc1 100644 (file)
@@ -2,31 +2,28 @@ error[E0308]: mismatched types
   --> $DIR/type-mismatch-struct-field-shorthand.rs:8:19
    |
 LL |     let _ = RGB { r, g, b };
-   |                   ^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     let _ = RGB { r: r.into(), g, b };
-   |                   ^^^^^^^^^^^
+   |                   ^
+   |                   |
+   |                   expected f64, found f32
+   |                   help: you can convert an `f32` to `f64`: `r: r.into()`
 
 error[E0308]: mismatched types
   --> $DIR/type-mismatch-struct-field-shorthand.rs:8:22
    |
 LL |     let _ = RGB { r, g, b };
-   |                      ^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     let _ = RGB { r, g: g.into(), b };
-   |                      ^^^^^^^^^^^
+   |                      ^
+   |                      |
+   |                      expected f64, found f32
+   |                      help: you can convert an `f32` to `f64`: `g: g.into()`
 
 error[E0308]: mismatched types
   --> $DIR/type-mismatch-struct-field-shorthand.rs:8:25
    |
 LL |     let _ = RGB { r, g, b };
-   |                         ^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     let _ = RGB { r, g, b: b.into() };
-   |                         ^^^^^^^^^^^
+   |                         ^
+   |                         |
+   |                         expected f64, found f32
+   |                         help: you can convert an `f32` to `f64`: `b: b.into()`
 
 error: aborting due to 3 previous errors
 
index 5b800114aa8d1bf06468a8e79097cff0bd58fbc2..9e6c38ced0d269fc383f88579b78152a9c0738de 100644 (file)
@@ -3,6 +3,10 @@ error[E0308]: mismatched types
    |
 LL |     test(22i32, 44i32);
    |                 ^^^^^ expected u32, found i32
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |     test(22i32, 44u32);
+   |                 ^^^^^
 
 error: aborting due to previous error
 
index 7c1a833442748536dbb16e35747ad24530a1aa9b..9acd63c2c25f14fe477fc30bb0aa9757f35cacfa 100644 (file)
@@ -6,6 +6,10 @@ LL | fn global_bound_is_hidden() -> u8
 ...
 LL |     B::get_x()
    |     ^^^^^^^^^^ expected u8, found i32
+help: you can convert an `i32` to `u8` or panic if it the converted value wouldn't fit
+   |
+LL |     B::get_x().try_into().unwrap()
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 6ba1b098d19b7f78f2d37c7c0a585fb3f8628d8c..f51f2defd475925766abc6fdbc226b426e9cfc4d 100644 (file)
@@ -2,23 +2,30 @@ error[E0308]: mismatched types
   --> $DIR/tutorial-suffix-inference-test.rs:9:18
    |
 LL |     identity_u16(x);
-   |                  ^ expected u16, found u8
-help: you can cast an `u8` to `u16`, which will zero-extend the source value
-   |
-LL |     identity_u16(x.into());
-   |                  ^^^^^^^^
+   |                  ^
+   |                  |
+   |                  expected u16, found u8
+   |                  help: you can convert an `u8` to `u16`: `x.into()`
 
 error[E0308]: mismatched types
   --> $DIR/tutorial-suffix-inference-test.rs:12:18
    |
 LL |     identity_u16(y);
    |                  ^ expected u16, found i32
+help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     identity_u16(y.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/tutorial-suffix-inference-test.rs:21:18
    |
 LL |     identity_u16(a);
    |                  ^ expected u16, found isize
+help: you can convert an `isize` to `u16` or panic if it the converted value wouldn't fit
+   |
+LL |     identity_u16(a.try_into().unwrap());
+   |                  ^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 3 previous errors
 
index 610146954c9857a0f09aeb3cf8fa4668f8897081..f749ed3f9d8652c665bc364fa87bb8f8e0e70d0f 100644 (file)
@@ -11,12 +11,20 @@ error[E0308]: mismatched types
    |
 LL |     <i32 as Add<i32>>::add(1u32, 2);
    |                            ^^^^ expected i32, found u32
+help: change the type of the numeric literal from `u32` to `i32`
+   |
+LL |     <i32 as Add<i32>>::add(1i32, 2);
+   |                            ^^^^
 
 error[E0308]: mismatched types
   --> $DIR/ufcs-qpath-self-mismatch.rs:8:31
    |
 LL |     <i32 as Add<i32>>::add(1, 2u32);
    |                               ^^^^ expected i32, found u32
+help: change the type of the numeric literal from `u32` to `i32`
+   |
+LL |     <i32 as Add<i32>>::add(1, 2i32);
+   |                               ^^^^
 
 error: aborting due to 3 previous errors
 
index df31a8d6104e3a3867c08b78bf4e055a3f21440f..758762fd5fde342ec44ab4e4a23dd6f224fb039e 100644 (file)
@@ -3,6 +3,10 @@ error[E0308]: mismatched types
    |
 LL |     let z = f(1_usize, 2);
    |               ^^^^^^^ expected isize, found usize
+help: change the type of the numeric literal from `usize` to `isize`
+   |
+LL |     let z = f(1_isize, 2);
+   |               ^^^^^^^
 
 error: aborting due to previous error