}
};
- 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.
//
}
}
+ 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,
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,
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()
}
};
- 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
},
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
}
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
);
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
);
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
...
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
|
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
--- /dev/null
+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
+}
--- /dev/null
+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`.
--- /dev/null
+// 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
+}
+// 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() {
//~^ 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
//~^ 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
//~^ 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
//~^ 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
//~^ 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
//~^ 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
//~^ 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
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
//~^ 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
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
//~^ 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);
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`.
--- /dev/null
+// 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
+}
--- /dev/null
+// 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
+}
--- /dev/null
+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`.
|
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
|
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
|
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
--- /dev/null
+// 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
+}
+// 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
}
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`.
--> $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
--> $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
|
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
...
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
--> $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
|
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
|
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