}
true
}
- (&ty::TyFloat(ref exp), &ty::TyFloat(ref found)) => {
+ (&ty::Float(ref exp), &ty::Float(ref found)) => {
if found.bit_width() < exp.bit_width() {
- err.span_suggestion(expr.span,
- &format!("{} in a lossless way",
- msg),
- into_suggestion);
+ err.span_suggestion_with_applicability(
+ expr.span,
+ &format!("{} in a lossless way", msg),
+ into_suggestion,
+ Applicability::MachineApplicable
+ );
} else if can_cast {
- err.span_suggestion(expr.span,
- &format!("{}, producing the closest possible value",
- msg),
- cast_suggestion);
+ err.span_suggestion_with_applicability(
+ expr.span,
+ &format!("{}, producing the closest possible value", msg),
+ cast_suggestion,
+ Applicability::MaybeIncorrect // lossy conversion
+ );
}
true
}
- (&ty::TyUint(_), &ty::TyFloat(_)) | (&ty::TyInt(_), &ty::TyFloat(_)) => {
+ (&ty::Uint(_), &ty::Float(_)) | (&ty::Int(_), &ty::Float(_)) => {
if can_cast {
- err.span_suggestion(expr.span,
- &format!("{}, rounding the float towards zero",
- msg),
- cast_suggestion);
+ err.span_suggestion_with_applicability(
+ 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)");
}
true
}
- (&ty::TyFloat(ref exp), &ty::TyUint(ref found)) => {
+ (&ty::Float(ref exp), &ty::Uint(ref found)) => {
// if `found` is `None` (meaning found is `usize`), don't suggest `.into()`
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),
- into_suggestion);
+ err.span_suggestion_with_applicability(
+ expr.span,
+ &format!("{}, producing the floating point representation of the \
+ integer",
+ msg),
+ into_suggestion,
+ Applicability::MachineApplicable
+ );
} else if can_cast {
- err.span_suggestion(expr.span,
- &format!("{}, producing the floating point \
- representation of the integer, rounded if \
- necessary",
- msg),
- cast_suggestion);
+ err.span_suggestion_with_applicability(expr.span,
+ &format!("{}, producing the floating point representation of the \
+ integer, rounded if necessary",
+ msg),
+ cast_suggestion,
+ Applicability::MaybeIncorrect // lossy conversion
+ );
}
true
}
- (&ty::TyFloat(ref exp), &ty::TyInt(ref found)) => {
+ (&ty::Float(ref exp), &ty::Int(ref found)) => {
// if `found` is `None` (meaning found is `isize`), don't suggest `.into()`
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),
- into_suggestion);
+ err.span_suggestion_with_applicability(
+ expr.span,
+ &format!("{}, producing the floating point representation of the \
+ integer",
+ msg),
+ into_suggestion,
+ Applicability::MachineApplicable
+ );
} else if can_cast {
- err.span_suggestion(expr.span,
- &format!("{}, producing the floating point \
- representation of the integer, rounded if \
- necessary",
- msg),
- cast_suggestion);
+ err.span_suggestion_with_applicability(
+ expr.span,
+ &format!("{}, producing the floating point representation of the \
+ integer, rounded if necessary",
+ msg),
+ cast_suggestion,
+ Applicability::MaybeIncorrect // lossy conversion
+ );
}
true
}