Rollup merge of #126636 - tgross35:clippy-f16-f128-fixme, r=flip1995

Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s

This was originally a PR against the Clippy repo, https://github.com/rust-lang/rust-clippy/pull/12950

r? ``@flip1995``

Tracking issue: https://github.com/rust-lang/rust/issues/116909
Fixes: https://github.com/rust-lang/rust/pull/126636
This commit is contained in:
Matthias Krüger 2024-06-20 14:07:01 +02:00 committed by GitHub
commit d3f5e7b2d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 907 additions and 594 deletions

View file

@ -709,6 +709,7 @@ dependencies = [
"clippy_config",
"itertools 0.12.1",
"rustc-semver",
"rustc_apfloat",
]
[[package]]

View file

@ -21,6 +21,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
fn is_known_nan(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
match constant(cx, cx.typeck_results(), e) {
// FIXME(f16_f128): add these types when nan checks are available on all platforms
Some(Constant::F64(n)) => n.is_nan(),
Some(Constant::F32(n)) => n.is_nan(),
_ => false,

View file

@ -141,18 +141,17 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
#[must_use]
fn max_digits(fty: FloatTy) -> u32 {
match fty {
// FIXME(f16_f128): replace the magic numbers once `{f16,f128}::DIGITS` are available
FloatTy::F16 => 3,
FloatTy::F16 => f16::DIGITS,
FloatTy::F32 => f32::DIGITS,
FloatTy::F64 => f64::DIGITS,
FloatTy::F128 => 33,
FloatTy::F128 => f128::DIGITS,
}
}
/// Counts the digits excluding leading zeros
#[must_use]
fn count_digits(s: &str) -> usize {
// Note that s does not contain the f32/64 suffix, and underscores have been stripped
// Note that s does not contain the `f{16,32,64,128}` suffix, and underscores have been stripped
s.chars()
.filter(|c| *c != '-' && *c != '.')
.take_while(|c| *c != 'e' && *c != 'E')

View file

@ -1,6 +1,8 @@
#![feature(array_windows)]
#![feature(binary_heap_into_iter_sorted)]
#![feature(box_patterns)]
#![feature(f128)]
#![feature(f16)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]

View file

@ -156,6 +156,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
fn is_infinity(constant: &Constant<'_>) -> bool {
match constant {
// FIXME(f16_f128): add f16 and f128 when constants are available
Constant::F32(float) => *float == f32::INFINITY,
Constant::F64(float) => *float == f64::INFINITY,
_ => false,
@ -164,6 +165,7 @@ fn is_infinity(constant: &Constant<'_>) -> bool {
fn is_neg_infinity(constant: &Constant<'_>) -> bool {
match constant {
// FIXME(f16_f128): add f16 and f128 when constants are available
Constant::F32(float) => *float == f32::NEG_INFINITY,
Constant::F64(float) => *float == f64::NEG_INFINITY,
_ => false,

View file

@ -86,6 +86,7 @@ fn get_lint_and_message(is_local: bool, is_comparing_arrays: bool) -> (&'static
fn is_allowed(val: &Constant<'_>) -> bool {
match val {
// FIXME(f16_f128): add when equality check is available on all platforms
&Constant::F32(f) => f == 0.0 || f.is_infinite(),
&Constant::F64(f) => f == 0.0 || f.is_infinite(),
Constant::Vec(vec) => vec.iter().all(|f| match f {

View file

@ -79,6 +79,7 @@ fn analyze_operand(operand: &Expr<'_>, cx: &LateContext<'_>, expr: &Expr<'_>) ->
},
_ => {},
},
// FIXME(f16_f128): add when casting is available on all platforms
Some(Constant::F32(f)) => {
return Some(floating_point_operand_info(&f));
},

View file

@ -38,6 +38,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
// do something like 0.0/(2.0 - 2.0), but it would be nice to warn on that case too.
&& let Some(lhs_value) = constant_simple(cx, cx.typeck_results(), left)
&& let Some(rhs_value) = constant_simple(cx, cx.typeck_results(), right)
// FIXME(f16_f128): add these types when eq is available on all platforms
&& (Constant::F32(0.0) == lhs_value || Constant::F64(0.0) == lhs_value)
&& (Constant::F32(0.0) == rhs_value || Constant::F64(0.0) == rhs_value)
{

View file

@ -9,6 +9,8 @@ clippy_config = { path = "../clippy_config" }
arrayvec = { version = "0.7", default-features = false }
itertools = "0.12"
rustc-semver = "1.1"
# FIXME(f16_f128): remove when no longer needed for parsing
rustc_apfloat = "0.2.0"
[features]
deny-warnings = ["clippy_config/deny-warnings"]

View file

@ -3,6 +3,8 @@
use crate::source::{get_source_text, walk_span_to_context};
use crate::{clip, is_direct_expn_of, sext, unsext};
use rustc_apfloat::ieee::{Half, Quad};
use rustc_apfloat::Float;
use rustc_ast::ast::{self, LitFloatType, LitKind};
use rustc_data_structures::sync::Lrc;
use rustc_hir::def::{DefKind, Res};
@ -33,10 +35,14 @@ pub enum Constant<'tcx> {
Char(char),
/// An integer's bit representation.
Int(u128),
/// An `f16`.
F16(f16),
/// An `f32`.
F32(f32),
/// An `f64`.
F64(f64),
/// An `f128`.
F128(f128),
/// `true` or `false`.
Bool(bool),
/// An array of constants.
@ -161,12 +167,19 @@ fn hash<H>(&self, state: &mut H)
Self::Int(i) => {
i.hash(state);
},
Self::F16(f) => {
// FIXME(f16_f128): once conversions to/from `f128` are available on all platforms,
f.to_bits().hash(state);
},
Self::F32(f) => {
f64::from(f).to_bits().hash(state);
},
Self::F64(f) => {
f.to_bits().hash(state);
},
Self::F128(f) => {
f.to_bits().hash(state);
},
Self::Bool(b) => {
b.hash(state);
},
@ -268,6 +281,16 @@ pub fn peel_refs(mut self) -> Self {
}
self
}
fn parse_f16(s: &str) -> Self {
let f: Half = s.parse().unwrap();
Self::F16(f16::from_bits(f.to_bits().try_into().unwrap()))
}
fn parse_f128(s: &str) -> Self {
let f: Quad = s.parse().unwrap();
Self::F128(f128::from_bits(f.to_bits()))
}
}
/// Parses a `LitKind` to a `Constant`.
@ -279,16 +302,17 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
LitKind::Char(c) => Constant::Char(c),
LitKind::Int(n, _) => Constant::Int(n.get()),
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
ast::FloatTy::F16 => unimplemented!("f16_f128"),
// FIXME(f16_f128): just use `parse()` directly when available for `f16`/`f128`
ast::FloatTy::F16 => Constant::parse_f16(is.as_str()),
ast::FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
ast::FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
ast::FloatTy::F128 => unimplemented!("f16_f128"),
ast::FloatTy::F128 => Constant::parse_f128(is.as_str()),
},
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() {
ty::Float(FloatTy::F16) => unimplemented!("f16_f128"),
ty::Float(FloatTy::F16) => Constant::parse_f16(is.as_str()),
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
ty::Float(FloatTy::F128) => unimplemented!("f16_f128"),
ty::Float(FloatTy::F128) => Constant::parse_f128(is.as_str()),
_ => bug!(),
},
LitKind::Bool(b) => Constant::Bool(b),
@ -625,15 +649,19 @@ fn index(&mut self, lhs: &'_ Expr<'_>, index: &'_ Expr<'_>) -> Option<Constant<'
match (lhs, index) {
(Some(Constant::Vec(vec)), Some(Constant::Int(index))) => match vec.get(index as usize) {
Some(Constant::F16(x)) => Some(Constant::F16(*x)),
Some(Constant::F32(x)) => Some(Constant::F32(*x)),
Some(Constant::F64(x)) => Some(Constant::F64(*x)),
Some(Constant::F128(x)) => Some(Constant::F128(*x)),
_ => None,
},
(Some(Constant::Vec(vec)), _) => {
if !vec.is_empty() && vec.iter().all(|x| *x == vec[0]) {
match vec.first() {
Some(Constant::F16(x)) => Some(Constant::F16(*x)),
Some(Constant::F32(x)) => Some(Constant::F32(*x)),
Some(Constant::F64(x)) => Some(Constant::F64(*x)),
Some(Constant::F128(x)) => Some(Constant::F128(*x)),
_ => None,
}
} else {
@ -760,6 +788,7 @@ fn binop(&mut self, op: BinOp, left: &Expr<'_>, right: &Expr<'_>) -> Option<Cons
},
_ => None,
},
// FIXME(f16_f128): add these types when binary operations are available on all platforms
(Constant::F32(l), Some(Constant::F32(r))) => match op.node {
BinOpKind::Add => Some(Constant::F32(l + r)),
BinOpKind::Sub => Some(Constant::F32(l - r)),
@ -813,8 +842,10 @@ pub fn mir_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::Const<'tcx>) ->
ty::Adt(adt_def, _) if adt_def.is_struct() => Some(Constant::Adt(result)),
ty::Bool => Some(Constant::Bool(int == ScalarInt::TRUE)),
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(int.to_bits(int.size()))),
ty::Float(FloatTy::F16) => Some(Constant::F16(f16::from_bits(int.into()))),
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(int.into()))),
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(int.into()))),
ty::Float(FloatTy::F128) => Some(Constant::F128(f128::from_bits(int.into()))),
ty::RawPtr(_, _) => Some(Constant::RawPtr(int.to_bits(int.size()))),
_ => None,
},
@ -835,10 +866,10 @@ pub fn mir_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::Const<'tcx>) ->
let range = alloc_range(offset + size * idx, size);
let val = alloc.read_scalar(&lcx.tcx, range, /* read_provenance */ false).ok()?;
res.push(match flt {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().ok()?)),
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)),
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)),
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().ok()?)),
});
}
Some(Constant::Vec(res))

View file

@ -1,6 +1,8 @@
#![feature(array_chunks)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(f128)]
#![feature(f16)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(lint_reasons)]

View file

@ -40,6 +40,7 @@ fn main() {
a.sort_unstable();
// FIXME(f16_f128): add a clamp test once the function is available
let _ = 2.0f32.clamp(3.0f32, 4.0f32);
let _ = 2.0f64.clamp(3.0f64, 4.0f64);

View file

@ -28,61 +28,61 @@ LL | a.sort_unstable();
| ^^^^^^^^^^^^^^^^^
error: use of a disallowed method `f32::clamp`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:43:13
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:44:13
|
LL | let _ = 2.0f32.clamp(3.0f32, 4.0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of a disallowed method `regex::Regex::new`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:46:61
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:47:61
|
LL | let indirect: fn(&str) -> Result<Regex, regex::Error> = Regex::new;
| ^^^^^^^^^^
error: use of a disallowed method `f32::clamp`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:49:28
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:50:28
|
LL | let in_call = Box::new(f32::clamp);
| ^^^^^^^^^^
error: use of a disallowed method `regex::Regex::new`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:50:53
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:51:53
|
LL | let in_method_call = ["^", "$"].into_iter().map(Regex::new);
| ^^^^^^^^^^
error: use of a disallowed method `futures::stream::select_all`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:53:31
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:54:31
|
LL | let same_name_as_module = select_all(vec![empty::<()>()]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of a disallowed method `conf_disallowed_methods::local_fn`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:55:5
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:56:5
|
LL | local_fn();
| ^^^^^^^^^^
error: use of a disallowed method `conf_disallowed_methods::local_mod::f`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:56:5
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:57:5
|
LL | local_mod::f();
| ^^^^^^^^^^^^^^
error: use of a disallowed method `conf_disallowed_methods::Struct::method`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:58:5
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:59:5
|
LL | s.method();
| ^^^^^^^^^^
error: use of a disallowed method `conf_disallowed_methods::Trait::provided_method`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:59:5
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:60:5
|
LL | s.provided_method();
| ^^^^^^^^^^^^^^^^^^^
error: use of a disallowed method `conf_disallowed_methods::Trait::implemented_method`
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:60:5
--> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:61:5
|
LL | s.implemented_method();
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -11,6 +11,8 @@
unconditional_panic
)]
#![feature(const_mut_refs)]
#![feature(f128)]
#![feature(f16)]
#![warn(clippy::arithmetic_side_effects)]
extern crate proc_macro_derive;
@ -162,8 +164,10 @@ union Qux {
}
pub fn hard_coded_allowed() {
let _ = 1f16 + 1f16;
let _ = 1f32 + 1f32;
let _ = 1f64 + 1f64;
let _ = 1f128 + 1f128;
let _ = Saturating(0u32) + Saturating(0u32);
let _ = String::new() + "";

View file

@ -1,731 +1,743 @@
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:304:5
--> tests/ui/arithmetic_side_effects.rs:167:13
|
LL | _n += 1;
| ^^^^^^^
LL | let _ = 1f16 + 1f16;
| ^^^^^^^^^^^
|
= note: `-D clippy::arithmetic-side-effects` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]`
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:305:5
--> tests/ui/arithmetic_side_effects.rs:170:13
|
LL | _n += &1;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:306:5
|
LL | _n -= 1;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:307:5
|
LL | _n -= &1;
| ^^^^^^^^
LL | let _ = 1f128 + 1f128;
| ^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:308:5
|
LL | _n /= 0;
LL | _n += 1;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:309:5
|
LL | _n /= &0;
LL | _n += &1;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:310:5
|
LL | _n %= 0;
LL | _n -= 1;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:311:5
|
LL | _n %= &0;
LL | _n -= &1;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:312:5
|
LL | _n *= 2;
LL | _n /= 0;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:313:5
|
LL | _n *= &2;
LL | _n /= &0;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:314:5
|
LL | _n += -1;
| ^^^^^^^^
LL | _n %= 0;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:315:5
|
LL | _n += &-1;
| ^^^^^^^^^
LL | _n %= &0;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:316:5
|
LL | _n -= -1;
| ^^^^^^^^
LL | _n *= 2;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:317:5
|
LL | _n -= &-1;
| ^^^^^^^^^
LL | _n *= &2;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:318:5
|
LL | _n /= -0;
LL | _n += -1;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:319:5
|
LL | _n /= &-0;
LL | _n += &-1;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:320:5
|
LL | _n %= -0;
LL | _n -= -1;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:321:5
|
LL | _n %= &-0;
LL | _n -= &-1;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:322:5
|
LL | _n *= -2;
LL | _n /= -0;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:323:5
|
LL | _n *= &-2;
LL | _n /= &-0;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:324:5
|
LL | _custom += Custom;
| ^^^^^^^^^^^^^^^^^
LL | _n %= -0;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:325:5
|
LL | _custom += &Custom;
| ^^^^^^^^^^^^^^^^^^
LL | _n %= &-0;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:326:5
|
LL | _custom -= Custom;
| ^^^^^^^^^^^^^^^^^
LL | _n *= -2;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:327:5
|
LL | _custom -= &Custom;
| ^^^^^^^^^^^^^^^^^^
LL | _n *= &-2;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:328:5
|
LL | _custom /= Custom;
LL | _custom += Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:329:5
|
LL | _custom /= &Custom;
LL | _custom += &Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:330:5
|
LL | _custom %= Custom;
LL | _custom -= Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:331:5
|
LL | _custom %= &Custom;
LL | _custom -= &Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:332:5
|
LL | _custom *= Custom;
LL | _custom /= Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:333:5
|
LL | _custom *= &Custom;
LL | _custom /= &Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:334:5
|
LL | _custom >>= Custom;
| ^^^^^^^^^^^^^^^^^^
LL | _custom %= Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:335:5
|
LL | _custom >>= &Custom;
| ^^^^^^^^^^^^^^^^^^^
LL | _custom %= &Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:336:5
|
LL | _custom <<= Custom;
| ^^^^^^^^^^^^^^^^^^
LL | _custom *= Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:337:5
|
LL | _custom <<= &Custom;
| ^^^^^^^^^^^^^^^^^^^
LL | _custom *= &Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:338:5
|
LL | _custom += -Custom;
LL | _custom >>= Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:339:5
|
LL | _custom += &-Custom;
LL | _custom >>= &Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:340:5
|
LL | _custom -= -Custom;
LL | _custom <<= Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:341:5
|
LL | _custom -= &-Custom;
LL | _custom <<= &Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:342:5
|
LL | _custom /= -Custom;
LL | _custom += -Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:343:5
|
LL | _custom /= &-Custom;
LL | _custom += &-Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:344:5
|
LL | _custom %= -Custom;
LL | _custom -= -Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:345:5
|
LL | _custom %= &-Custom;
LL | _custom -= &-Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:346:5
|
LL | _custom *= -Custom;
LL | _custom /= -Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:347:5
|
LL | _custom *= &-Custom;
LL | _custom /= &-Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:348:5
|
LL | _custom %= -Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:349:5
|
LL | _custom %= &-Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:350:5
|
LL | _custom *= -Custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:351:5
|
LL | _custom *= &-Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:352:5
|
LL | _custom >>= -Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:349:5
--> tests/ui/arithmetic_side_effects.rs:353:5
|
LL | _custom >>= &-Custom;
| ^^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:350:5
--> tests/ui/arithmetic_side_effects.rs:354:5
|
LL | _custom <<= -Custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:351:5
--> tests/ui/arithmetic_side_effects.rs:355:5
|
LL | _custom <<= &-Custom;
| ^^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:354:10
--> tests/ui/arithmetic_side_effects.rs:358:10
|
LL | _n = _n + 1;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:355:10
--> tests/ui/arithmetic_side_effects.rs:359:10
|
LL | _n = _n + &1;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:356:10
--> tests/ui/arithmetic_side_effects.rs:360:10
|
LL | _n = 1 + _n;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:357:10
--> tests/ui/arithmetic_side_effects.rs:361:10
|
LL | _n = &1 + _n;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:358:10
--> tests/ui/arithmetic_side_effects.rs:362:10
|
LL | _n = _n - 1;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:359:10
--> tests/ui/arithmetic_side_effects.rs:363:10
|
LL | _n = _n - &1;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:360:10
--> tests/ui/arithmetic_side_effects.rs:364:10
|
LL | _n = 1 - _n;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:361:10
--> tests/ui/arithmetic_side_effects.rs:365:10
|
LL | _n = &1 - _n;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:362:10
--> tests/ui/arithmetic_side_effects.rs:366:10
|
LL | _n = _n / 0;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:363:10
--> tests/ui/arithmetic_side_effects.rs:367:10
|
LL | _n = _n / &0;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:364:10
--> tests/ui/arithmetic_side_effects.rs:368:10
|
LL | _n = _n % 0;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:365:10
--> tests/ui/arithmetic_side_effects.rs:369:10
|
LL | _n = _n % &0;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:366:10
--> tests/ui/arithmetic_side_effects.rs:370:10
|
LL | _n = _n * 2;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:367:10
--> tests/ui/arithmetic_side_effects.rs:371:10
|
LL | _n = _n * &2;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:368:10
--> tests/ui/arithmetic_side_effects.rs:372:10
|
LL | _n = 2 * _n;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:369:10
--> tests/ui/arithmetic_side_effects.rs:373:10
|
LL | _n = &2 * _n;
| ^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:370:10
--> tests/ui/arithmetic_side_effects.rs:374:10
|
LL | _n = 23 + &85;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:371:10
--> tests/ui/arithmetic_side_effects.rs:375:10
|
LL | _n = &23 + 85;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:372:10
--> tests/ui/arithmetic_side_effects.rs:376:10
|
LL | _n = &23 + &85;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:373:15
--> tests/ui/arithmetic_side_effects.rs:377:15
|
LL | _custom = _custom + _custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:374:15
--> tests/ui/arithmetic_side_effects.rs:378:15
|
LL | _custom = _custom + &_custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:375:15
--> tests/ui/arithmetic_side_effects.rs:379:15
|
LL | _custom = Custom + _custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:376:15
--> tests/ui/arithmetic_side_effects.rs:380:15
|
LL | _custom = &Custom + _custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:377:15
--> tests/ui/arithmetic_side_effects.rs:381:15
|
LL | _custom = _custom - Custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:378:15
--> tests/ui/arithmetic_side_effects.rs:382:15
|
LL | _custom = _custom - &Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:379:15
--> tests/ui/arithmetic_side_effects.rs:383:15
|
LL | _custom = Custom - _custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:380:15
--> tests/ui/arithmetic_side_effects.rs:384:15
|
LL | _custom = &Custom - _custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:381:15
--> tests/ui/arithmetic_side_effects.rs:385:15
|
LL | _custom = _custom / Custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:382:15
--> tests/ui/arithmetic_side_effects.rs:386:15
|
LL | _custom = _custom / &Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:383:15
--> tests/ui/arithmetic_side_effects.rs:387:15
|
LL | _custom = _custom % Custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:384:15
--> tests/ui/arithmetic_side_effects.rs:388:15
|
LL | _custom = _custom % &Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:385:15
--> tests/ui/arithmetic_side_effects.rs:389:15
|
LL | _custom = _custom * Custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:386:15
--> tests/ui/arithmetic_side_effects.rs:390:15
|
LL | _custom = _custom * &Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:387:15
--> tests/ui/arithmetic_side_effects.rs:391:15
|
LL | _custom = Custom * _custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:388:15
--> tests/ui/arithmetic_side_effects.rs:392:15
|
LL | _custom = &Custom * _custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:389:15
--> tests/ui/arithmetic_side_effects.rs:393:15
|
LL | _custom = Custom + &Custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:390:15
--> tests/ui/arithmetic_side_effects.rs:394:15
|
LL | _custom = &Custom + Custom;
| ^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:391:15
--> tests/ui/arithmetic_side_effects.rs:395:15
|
LL | _custom = &Custom + &Custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:392:15
--> tests/ui/arithmetic_side_effects.rs:396:15
|
LL | _custom = _custom >> _custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:393:15
--> tests/ui/arithmetic_side_effects.rs:397:15
|
LL | _custom = _custom >> &_custom;
| ^^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:394:15
--> tests/ui/arithmetic_side_effects.rs:398:15
|
LL | _custom = Custom << _custom;
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:395:15
--> tests/ui/arithmetic_side_effects.rs:399:15
|
LL | _custom = &Custom << _custom;
| ^^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:398:23
--> tests/ui/arithmetic_side_effects.rs:402:23
|
LL | _n.saturating_div(0);
| ^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:399:21
--> tests/ui/arithmetic_side_effects.rs:403:21
|
LL | _n.wrapping_div(0);
| ^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:400:21
--> tests/ui/arithmetic_side_effects.rs:404:21
|
LL | _n.wrapping_rem(0);
| ^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:401:28
--> tests/ui/arithmetic_side_effects.rs:405:28
|
LL | _n.wrapping_rem_euclid(0);
| ^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:403:23
--> tests/ui/arithmetic_side_effects.rs:407:23
|
LL | _n.saturating_div(_n);
| ^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:404:21
--> tests/ui/arithmetic_side_effects.rs:408:21
|
LL | _n.wrapping_div(_n);
| ^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:405:21
--> tests/ui/arithmetic_side_effects.rs:409:21
|
LL | _n.wrapping_rem(_n);
| ^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:406:28
--> tests/ui/arithmetic_side_effects.rs:410:28
|
LL | _n.wrapping_rem_euclid(_n);
| ^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:409:10
--> tests/ui/arithmetic_side_effects.rs:413:10
|
LL | _n = -_n;
| ^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:410:10
--> tests/ui/arithmetic_side_effects.rs:414:10
|
LL | _n = -&_n;
| ^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:411:15
--> tests/ui/arithmetic_side_effects.rs:415:15
|
LL | _custom = -_custom;
| ^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:412:15
--> tests/ui/arithmetic_side_effects.rs:416:15
|
LL | _custom = -&_custom;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:421:5
--> tests/ui/arithmetic_side_effects.rs:425:5
|
LL | 1 + i;
| ^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:422:5
--> tests/ui/arithmetic_side_effects.rs:426:5
|
LL | i * 2;
| ^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:423:5
--> tests/ui/arithmetic_side_effects.rs:427:5
|
LL | 1 % i / 2;
| ^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:424:5
--> tests/ui/arithmetic_side_effects.rs:428:5
|
LL | i - 2 + 2 - i;
| ^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:425:5
--> tests/ui/arithmetic_side_effects.rs:429:5
|
LL | -i;
| ^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:436:5
--> tests/ui/arithmetic_side_effects.rs:440:5
|
LL | i += 1;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:437:5
--> tests/ui/arithmetic_side_effects.rs:441:5
|
LL | i -= 1;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:438:5
--> tests/ui/arithmetic_side_effects.rs:442:5
|
LL | i *= 2;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:440:5
--> tests/ui/arithmetic_side_effects.rs:444:5
|
LL | i /= 0;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:442:5
--> tests/ui/arithmetic_side_effects.rs:446:5
|
LL | i /= var1;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:443:5
--> tests/ui/arithmetic_side_effects.rs:447:5
|
LL | i /= var2;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:445:5
--> tests/ui/arithmetic_side_effects.rs:449:5
|
LL | i %= 0;
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:447:5
--> tests/ui/arithmetic_side_effects.rs:451:5
|
LL | i %= var1;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:448:5
--> tests/ui/arithmetic_side_effects.rs:452:5
|
LL | i %= var2;
| ^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:458:5
--> tests/ui/arithmetic_side_effects.rs:462:5
|
LL | 10 / a
| ^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:512:9
--> tests/ui/arithmetic_side_effects.rs:516:9
|
LL | x / maybe_zero
| ^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:516:9
--> tests/ui/arithmetic_side_effects.rs:520:9
|
LL | x % maybe_zero
| ^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:527:5
--> tests/ui/arithmetic_side_effects.rs:531:5
|
LL | one.add_assign(1);
| ^^^^^^^^^^^^^^^^^
error: arithmetic operation that can potentially result in unexpected side-effects
--> tests/ui/arithmetic_side_effects.rs:531:5
--> tests/ui/arithmetic_side_effects.rs:535:5
|
LL | one.sub_assign(1);
| ^^^^^^^^^^^^^^^^^
error: aborting due to 121 previous errors
error: aborting due to 123 previous errors

View file

@ -17,6 +17,8 @@
clippy::identity_op
)]
// FIXME(f16_f128): add tests once const casting is available for these types
fn main() {
// Test clippy::cast_precision_loss
let x0 = 1i32;

View file

@ -1,5 +1,5 @@
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast.rs:23:5
--> tests/ui/cast.rs:25:5
|
LL | x0 as f32;
| ^^^^^^^^^
@ -8,37 +8,37 @@ LL | x0 as f32;
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast.rs:27:5
--> tests/ui/cast.rs:29:5
|
LL | x1 as f32;
| ^^^^^^^^^
error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast.rs:29:5
--> tests/ui/cast.rs:31:5
|
LL | x1 as f64;
| ^^^^^^^^^
error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast.rs:32:5
--> tests/ui/cast.rs:34:5
|
LL | x2 as f32;
| ^^^^^^^^^
error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast.rs:35:5
--> tests/ui/cast.rs:37:5
|
LL | x3 as f32;
| ^^^^^^^^^
error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast.rs:37:5
--> tests/ui/cast.rs:39:5
|
LL | x3 as f64;
| ^^^^^^^^^
error: casting `f32` to `i32` may truncate the value
--> tests/ui/cast.rs:40:5
--> tests/ui/cast.rs:42:5
|
LL | 1f32 as i32;
| ^^^^^^^^^^^
@ -48,7 +48,7 @@ LL | 1f32 as i32;
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
error: casting `f32` to `u32` may truncate the value
--> tests/ui/cast.rs:42:5
--> tests/ui/cast.rs:44:5
|
LL | 1f32 as u32;
| ^^^^^^^^^^^
@ -56,7 +56,7 @@ LL | 1f32 as u32;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:42:5
--> tests/ui/cast.rs:44:5
|
LL | 1f32 as u32;
| ^^^^^^^^^^^
@ -65,7 +65,7 @@ LL | 1f32 as u32;
= help: to override `-D warnings` add `#[allow(clippy::cast_sign_loss)]`
error: casting `f64` to `f32` may truncate the value
--> tests/ui/cast.rs:46:5
--> tests/ui/cast.rs:48:5
|
LL | 1f64 as f32;
| ^^^^^^^^^^^
@ -73,7 +73,7 @@ LL | 1f64 as f32;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `i32` to `i8` may truncate the value
--> tests/ui/cast.rs:48:5
--> tests/ui/cast.rs:50:5
|
LL | 1i32 as i8;
| ^^^^^^^^^^
@ -85,7 +85,7 @@ LL | i8::try_from(1i32);
| ~~~~~~~~~~~~~~~~~~
error: casting `i32` to `u8` may truncate the value
--> tests/ui/cast.rs:50:5
--> tests/ui/cast.rs:52:5
|
LL | 1i32 as u8;
| ^^^^^^^^^^
@ -97,7 +97,7 @@ LL | u8::try_from(1i32);
| ~~~~~~~~~~~~~~~~~~
error: casting `f64` to `isize` may truncate the value
--> tests/ui/cast.rs:52:5
--> tests/ui/cast.rs:54:5
|
LL | 1f64 as isize;
| ^^^^^^^^^^^^^
@ -105,7 +105,7 @@ LL | 1f64 as isize;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f64` to `usize` may truncate the value
--> tests/ui/cast.rs:54:5
--> tests/ui/cast.rs:56:5
|
LL | 1f64 as usize;
| ^^^^^^^^^^^^^
@ -113,13 +113,13 @@ LL | 1f64 as usize;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f64` to `usize` may lose the sign of the value
--> tests/ui/cast.rs:54:5
--> tests/ui/cast.rs:56:5
|
LL | 1f64 as usize;
| ^^^^^^^^^^^^^
error: casting `u32` to `u16` may truncate the value
--> tests/ui/cast.rs:57:5
--> tests/ui/cast.rs:59:5
|
LL | 1f32 as u32 as u16;
| ^^^^^^^^^^^^^^^^^^
@ -131,7 +131,7 @@ LL | u16::try_from(1f32 as u32);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
error: casting `f32` to `u32` may truncate the value
--> tests/ui/cast.rs:57:5
--> tests/ui/cast.rs:59:5
|
LL | 1f32 as u32 as u16;
| ^^^^^^^^^^^
@ -139,13 +139,13 @@ LL | 1f32 as u32 as u16;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:57:5
--> tests/ui/cast.rs:59:5
|
LL | 1f32 as u32 as u16;
| ^^^^^^^^^^^
error: casting `i32` to `i8` may truncate the value
--> tests/ui/cast.rs:62:22
--> tests/ui/cast.rs:64:22
|
LL | let _x: i8 = 1i32 as _;
| ^^^^^^^^^
@ -157,7 +157,7 @@ LL | let _x: i8 = 1i32.try_into();
| ~~~~~~~~~~~~~~~
error: casting `f32` to `i32` may truncate the value
--> tests/ui/cast.rs:64:9
--> tests/ui/cast.rs:66:9
|
LL | 1f32 as i32;
| ^^^^^^^^^^^
@ -165,7 +165,7 @@ LL | 1f32 as i32;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f64` to `i32` may truncate the value
--> tests/ui/cast.rs:66:9
--> tests/ui/cast.rs:68:9
|
LL | 1f64 as i32;
| ^^^^^^^^^^^
@ -173,7 +173,7 @@ LL | 1f64 as i32;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f32` to `u8` may truncate the value
--> tests/ui/cast.rs:68:9
--> tests/ui/cast.rs:70:9
|
LL | 1f32 as u8;
| ^^^^^^^^^^
@ -181,13 +181,13 @@ LL | 1f32 as u8;
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
error: casting `f32` to `u8` may lose the sign of the value
--> tests/ui/cast.rs:68:9
--> tests/ui/cast.rs:70:9
|
LL | 1f32 as u8;
| ^^^^^^^^^^
error: casting `u8` to `i8` may wrap around the value
--> tests/ui/cast.rs:73:5
--> tests/ui/cast.rs:75:5
|
LL | 1u8 as i8;
| ^^^^^^^^^
@ -196,31 +196,31 @@ LL | 1u8 as i8;
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
error: casting `u16` to `i16` may wrap around the value
--> tests/ui/cast.rs:76:5
--> tests/ui/cast.rs:78:5
|
LL | 1u16 as i16;
| ^^^^^^^^^^^
error: casting `u32` to `i32` may wrap around the value
--> tests/ui/cast.rs:78:5
--> tests/ui/cast.rs:80:5
|
LL | 1u32 as i32;
| ^^^^^^^^^^^
error: casting `u64` to `i64` may wrap around the value
--> tests/ui/cast.rs:80:5
--> tests/ui/cast.rs:82:5
|
LL | 1u64 as i64;
| ^^^^^^^^^^^
error: casting `usize` to `isize` may wrap around the value
--> tests/ui/cast.rs:82:5
--> tests/ui/cast.rs:84:5
|
LL | 1usize as isize;
| ^^^^^^^^^^^^^^^
error: casting `usize` to `i8` may truncate the value
--> tests/ui/cast.rs:85:5
--> tests/ui/cast.rs:87:5
|
LL | 1usize as i8;
| ^^^^^^^^^^^^
@ -232,7 +232,7 @@ LL | i8::try_from(1usize);
| ~~~~~~~~~~~~~~~~~~~~
error: casting `usize` to `i16` may truncate the value
--> tests/ui/cast.rs:88:5
--> tests/ui/cast.rs:90:5
|
LL | 1usize as i16;
| ^^^^^^^^^^^^^
@ -244,7 +244,7 @@ LL | i16::try_from(1usize);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `usize` to `i16` may wrap around the value on targets with 16-bit wide pointers
--> tests/ui/cast.rs:88:5
--> tests/ui/cast.rs:90:5
|
LL | 1usize as i16;
| ^^^^^^^^^^^^^
@ -253,7 +253,7 @@ LL | 1usize as i16;
= note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
--> tests/ui/cast.rs:93:5
--> tests/ui/cast.rs:95:5
|
LL | 1usize as i32;
| ^^^^^^^^^^^^^
@ -265,19 +265,19 @@ LL | i32::try_from(1usize);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
--> tests/ui/cast.rs:93:5
--> tests/ui/cast.rs:95:5
|
LL | 1usize as i32;
| ^^^^^^^^^^^^^
error: casting `usize` to `i64` may wrap around the value on targets with 64-bit wide pointers
--> tests/ui/cast.rs:97:5
--> tests/ui/cast.rs:99:5
|
LL | 1usize as i64;
| ^^^^^^^^^^^^^
error: casting `u16` to `isize` may wrap around the value on targets with 16-bit wide pointers
--> tests/ui/cast.rs:102:5
--> tests/ui/cast.rs:104:5
|
LL | 1u16 as isize;
| ^^^^^^^^^^^^^
@ -286,13 +286,13 @@ LL | 1u16 as isize;
= note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
--> tests/ui/cast.rs:106:5
--> tests/ui/cast.rs:108:5
|
LL | 1u32 as isize;
| ^^^^^^^^^^^^^
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast.rs:109:5
--> tests/ui/cast.rs:111:5
|
LL | 1u64 as isize;
| ^^^^^^^^^^^^^
@ -304,55 +304,55 @@ LL | isize::try_from(1u64);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
--> tests/ui/cast.rs:109:5
--> tests/ui/cast.rs:111:5
|
LL | 1u64 as isize;
| ^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:114:5
--> tests/ui/cast.rs:116:5
|
LL | -1i32 as u32;
| ^^^^^^^^^^^^
error: casting `isize` to `usize` may lose the sign of the value
--> tests/ui/cast.rs:117:5
--> tests/ui/cast.rs:119:5
|
LL | -1isize as usize;
| ^^^^^^^^^^^^^^^^
error: casting `i8` to `u8` may lose the sign of the value
--> tests/ui/cast.rs:128:5
--> tests/ui/cast.rs:130:5
|
LL | (i8::MIN).abs() as u8;
| ^^^^^^^^^^^^^^^^^^^^^
error: casting `i64` to `u64` may lose the sign of the value
--> tests/ui/cast.rs:132:5
--> tests/ui/cast.rs:134:5
|
LL | (-1i64).abs() as u64;
| ^^^^^^^^^^^^^^^^^^^^
error: casting `isize` to `usize` may lose the sign of the value
--> tests/ui/cast.rs:133:5
--> tests/ui/cast.rs:135:5
|
LL | (-1isize).abs() as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i64` to `u64` may lose the sign of the value
--> tests/ui/cast.rs:140:5
--> tests/ui/cast.rs:142:5
|
LL | (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i64` to `u64` may lose the sign of the value
--> tests/ui/cast.rs:155:5
--> tests/ui/cast.rs:157:5
|
LL | (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i64` to `i8` may truncate the value
--> tests/ui/cast.rs:206:5
--> tests/ui/cast.rs:208:5
|
LL | (-99999999999i64).min(1) as i8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -364,7 +364,7 @@ LL | i8::try_from((-99999999999i64).min(1));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: casting `u64` to `u8` may truncate the value
--> tests/ui/cast.rs:220:5
--> tests/ui/cast.rs:222:5
|
LL | 999999u64.clamp(0, 256) as u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -376,7 +376,7 @@ LL | u8::try_from(999999u64.clamp(0, 256));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: casting `main::E2` to `u8` may truncate the value
--> tests/ui/cast.rs:243:21
--> tests/ui/cast.rs:245:21
|
LL | let _ = self as u8;
| ^^^^^^^^^^
@ -388,7 +388,7 @@ LL | let _ = u8::try_from(self);
| ~~~~~~~~~~~~~~~~~~
error: casting `main::E2::B` to `u8` will truncate the value
--> tests/ui/cast.rs:245:21
--> tests/ui/cast.rs:247:21
|
LL | let _ = Self::B as u8;
| ^^^^^^^^^^^^^
@ -397,7 +397,7 @@ LL | let _ = Self::B as u8;
= help: to override `-D warnings` add `#[allow(clippy::cast_enum_truncation)]`
error: casting `main::E5` to `i8` may truncate the value
--> tests/ui/cast.rs:287:21
--> tests/ui/cast.rs:289:21
|
LL | let _ = self as i8;
| ^^^^^^^^^^
@ -409,13 +409,13 @@ LL | let _ = i8::try_from(self);
| ~~~~~~~~~~~~~~~~~~
error: casting `main::E5::A` to `i8` will truncate the value
--> tests/ui/cast.rs:289:21
--> tests/ui/cast.rs:291:21
|
LL | let _ = Self::A as i8;
| ^^^^^^^^^^^^^
error: casting `main::E6` to `i16` may truncate the value
--> tests/ui/cast.rs:306:21
--> tests/ui/cast.rs:308:21
|
LL | let _ = self as i16;
| ^^^^^^^^^^^
@ -427,7 +427,7 @@ LL | let _ = i16::try_from(self);
| ~~~~~~~~~~~~~~~~~~~
error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast.rs:325:21
--> tests/ui/cast.rs:327:21
|
LL | let _ = self as usize;
| ^^^^^^^^^^^^^
@ -439,7 +439,7 @@ LL | let _ = usize::try_from(self);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `main::E10` to `u16` may truncate the value
--> tests/ui/cast.rs:372:21
--> tests/ui/cast.rs:374:21
|
LL | let _ = self as u16;
| ^^^^^^^^^^^
@ -451,7 +451,7 @@ LL | let _ = u16::try_from(self);
| ~~~~~~~~~~~~~~~~~~~
error: casting `u32` to `u8` may truncate the value
--> tests/ui/cast.rs:383:13
--> tests/ui/cast.rs:385:13
|
LL | let c = (q >> 16) as u8;
| ^^^^^^^^^^^^^^^
@ -463,7 +463,7 @@ LL | let c = u8::try_from(q >> 16);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `u32` to `u8` may truncate the value
--> tests/ui/cast.rs:387:13
--> tests/ui/cast.rs:389:13
|
LL | let c = (q / 1000) as u8;
| ^^^^^^^^^^^^^^^^
@ -475,85 +475,85 @@ LL | let c = u8::try_from(q / 1000);
| ~~~~~~~~~~~~~~~~~~~~~~
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:399:9
--> tests/ui/cast.rs:401:9
|
LL | (x * x) as u32;
| ^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:404:32
--> tests/ui/cast.rs:406:32
|
LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 };
| ^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:406:5
--> tests/ui/cast.rs:408:5
|
LL | (2_i32).checked_pow(3).unwrap() as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:407:5
--> tests/ui/cast.rs:409:5
|
LL | (-2_i32).pow(3) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:412:5
--> tests/ui/cast.rs:414:5
|
LL | (-5_i32 % 2) as u32;
| ^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:414:5
--> tests/ui/cast.rs:416:5
|
LL | (-5_i32 % -2) as u32;
| ^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:417:5
--> tests/ui/cast.rs:419:5
|
LL | (-2_i32 >> 1) as u32;
| ^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:421:5
--> tests/ui/cast.rs:423:5
|
LL | (x * x) as u32;
| ^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:422:5
--> tests/ui/cast.rs:424:5
|
LL | (x * x * x) as u32;
| ^^^^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:426:5
--> tests/ui/cast.rs:428:5
|
LL | (y * y * y * y * -2) as u16;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:428:5
--> tests/ui/cast.rs:430:5
|
LL | (y * y * y / y * 2) as u16;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:429:5
--> tests/ui/cast.rs:431:5
|
LL | (y * y / y * 2) as u16;
| ^^^^^^^^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:431:5
--> tests/ui/cast.rs:433:5
|
LL | (y / y * y * -2) as u16;
| ^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `/`
--> tests/ui/cast.rs:431:6
--> tests/ui/cast.rs:433:6
|
LL | (y / y * y * -2) as u16;
| ^^^^^
@ -561,97 +561,97 @@ LL | (y / y * y * -2) as u16;
= note: `#[deny(clippy::eq_op)]` on by default
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:434:5
--> tests/ui/cast.rs:436:5
|
LL | (y + y + y + -2) as u16;
| ^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:436:5
--> tests/ui/cast.rs:438:5
|
LL | (y + y + y + 2) as u16;
| ^^^^^^^^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:440:5
--> tests/ui/cast.rs:442:5
|
LL | (z + -2) as u16;
| ^^^^^^^^^^^^^^^
error: casting `i16` to `u16` may lose the sign of the value
--> tests/ui/cast.rs:442:5
--> tests/ui/cast.rs:444:5
|
LL | (z + z + 2) as u16;
| ^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:445:9
--> tests/ui/cast.rs:447:9
|
LL | (a * a * b * b * c * c) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:446:9
--> tests/ui/cast.rs:448:9
|
LL | (a * b * c) as u32;
| ^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:448:9
--> tests/ui/cast.rs:450:9
|
LL | (a * -b * c) as u32;
| ^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:450:9
--> tests/ui/cast.rs:452:9
|
LL | (a * b * c * c) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:451:9
--> tests/ui/cast.rs:453:9
|
LL | (a * -2) as u32;
| ^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:453:9
--> tests/ui/cast.rs:455:9
|
LL | (a * b * c * -2) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:455:9
--> tests/ui/cast.rs:457:9
|
LL | (a / b) as u32;
| ^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:456:9
--> tests/ui/cast.rs:458:9
|
LL | (a / b * c) as u32;
| ^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:458:9
--> tests/ui/cast.rs:460:9
|
LL | (a / b + b * c) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:460:9
--> tests/ui/cast.rs:462:9
|
LL | a.saturating_pow(3) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:462:9
--> tests/ui/cast.rs:464:9
|
LL | (a.abs() * b.pow(2) / c.abs()) as u32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `i32` to `u32` may lose the sign of the value
--> tests/ui/cast.rs:470:21
--> tests/ui/cast.rs:472:21
|
LL | let _ = i32::MIN as u32; // cast_sign_loss
| ^^^^^^^^^^^^^^^
@ -662,7 +662,7 @@ LL | m!();
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
error: casting `u32` to `u8` may truncate the value
--> tests/ui/cast.rs:471:21
--> tests/ui/cast.rs:473:21
|
LL | let _ = u32::MAX as u8; // cast_possible_truncation
| ^^^^^^^^^^^^^^
@ -678,7 +678,7 @@ LL | let _ = u8::try_from(u32::MAX); // cast_possible_truncation
| ~~~~~~~~~~~~~~~~~~~~~~
error: casting `f64` to `f32` may truncate the value
--> tests/ui/cast.rs:472:21
--> tests/ui/cast.rs:474:21
|
LL | let _ = std::f64::consts::PI as f32; // cast_possible_truncation
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -690,7 +690,7 @@ LL | m!();
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast.rs:481:5
--> tests/ui/cast.rs:483:5
|
LL | bar.unwrap().unwrap() as usize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -702,13 +702,13 @@ LL | usize::try_from(bar.unwrap().unwrap())
|
error: casting `i64` to `usize` may lose the sign of the value
--> tests/ui/cast.rs:481:5
--> tests/ui/cast.rs:483:5
|
LL | bar.unwrap().unwrap() as usize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: casting `u64` to `u8` may truncate the value
--> tests/ui/cast.rs:496:5
--> tests/ui/cast.rs:498:5
|
LL | (256 & 999999u64) as u8;
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -720,7 +720,7 @@ LL | u8::try_from(256 & 999999u64);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: casting `u64` to `u8` may truncate the value
--> tests/ui/cast.rs:498:5
--> tests/ui/cast.rs:500:5
|
LL | (255 % 999999u64) as u8;
| ^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,8 @@
#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
#![warn(clippy::cast_lossless)]
// FIXME(f16_f128): add tests for these types once const casting is available
type F32 = f32;
type F64 = f64;

View file

@ -1,6 +1,8 @@
#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)]
#![warn(clippy::cast_lossless)]
// FIXME(f16_f128): add tests for these types once const casting is available
type F32 = f32;
type F64 = f64;

View file

@ -1,5 +1,5 @@
error: casting `i8` to `f32` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:10:13
--> tests/ui/cast_lossless_float.rs:12:13
|
LL | let _ = x0 as f32;
| ^^^^^^^^^ help: try: `f32::from(x0)`
@ -8,73 +8,73 @@ LL | let _ = x0 as f32;
= help: to override `-D warnings` add `#[allow(clippy::cast_lossless)]`
error: casting `i8` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:11:13
--> tests/ui/cast_lossless_float.rs:13:13
|
LL | let _ = x0 as f64;
| ^^^^^^^^^ help: try: `f64::from(x0)`
error: casting `i8` to `F32` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:12:13
--> tests/ui/cast_lossless_float.rs:14:13
|
LL | let _ = x0 as F32;
| ^^^^^^^^^ help: try: `F32::from(x0)`
error: casting `i8` to `F64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:13:13
--> tests/ui/cast_lossless_float.rs:15:13
|
LL | let _ = x0 as F64;
| ^^^^^^^^^ help: try: `F64::from(x0)`
error: casting `u8` to `f32` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:15:13
--> tests/ui/cast_lossless_float.rs:17:13
|
LL | let _ = x1 as f32;
| ^^^^^^^^^ help: try: `f32::from(x1)`
error: casting `u8` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:16:13
--> tests/ui/cast_lossless_float.rs:18:13
|
LL | let _ = x1 as f64;
| ^^^^^^^^^ help: try: `f64::from(x1)`
error: casting `i16` to `f32` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:18:13
--> tests/ui/cast_lossless_float.rs:20:13
|
LL | let _ = x2 as f32;
| ^^^^^^^^^ help: try: `f32::from(x2)`
error: casting `i16` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:19:13
--> tests/ui/cast_lossless_float.rs:21:13
|
LL | let _ = x2 as f64;
| ^^^^^^^^^ help: try: `f64::from(x2)`
error: casting `u16` to `f32` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:21:13
--> tests/ui/cast_lossless_float.rs:23:13
|
LL | let _ = x3 as f32;
| ^^^^^^^^^ help: try: `f32::from(x3)`
error: casting `u16` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:22:13
--> tests/ui/cast_lossless_float.rs:24:13
|
LL | let _ = x3 as f64;
| ^^^^^^^^^ help: try: `f64::from(x3)`
error: casting `i32` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:24:13
--> tests/ui/cast_lossless_float.rs:26:13
|
LL | let _ = x4 as f64;
| ^^^^^^^^^ help: try: `f64::from(x4)`
error: casting `u32` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:26:13
--> tests/ui/cast_lossless_float.rs:28:13
|
LL | let _ = x5 as f64;
| ^^^^^^^^^ help: try: `f64::from(x5)`
error: casting `f32` to `f64` may become silently lossy if you later change the type
--> tests/ui/cast_lossless_float.rs:29:13
--> tests/ui/cast_lossless_float.rs:31:13
|
LL | let _ = 1.0f32 as f64;
| ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)`

View file

@ -1,3 +1,5 @@
// FIXME(f16_f128): add tests when constants are available
#![warn(clippy::cast_nan_to_int)]
#![allow(clippy::eq_op)]

View file

@ -1,5 +1,5 @@
error: casting a known NaN to usize
--> tests/ui/cast_nan_to_int.rs:5:13
--> tests/ui/cast_nan_to_int.rs:7:13
|
LL | let _ = (0.0_f32 / -0.0) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9,7 +9,7 @@ LL | let _ = (0.0_f32 / -0.0) as usize;
= help: to override `-D warnings` add `#[allow(clippy::cast_nan_to_int)]`
error: casting a known NaN to usize
--> tests/ui/cast_nan_to_int.rs:8:13
--> tests/ui/cast_nan_to_int.rs:10:13
|
LL | let _ = (f64::INFINITY * -0.0) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -17,7 +17,7 @@ LL | let _ = (f64::INFINITY * -0.0) as usize;
= note: this always evaluates to 0
error: casting a known NaN to usize
--> tests/ui/cast_nan_to_int.rs:11:13
--> tests/ui/cast_nan_to_int.rs:13:13
|
LL | let _ = (0.0 * f32::INFINITY) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | let _ = (0.0 * f32::INFINITY) as usize;
= note: this always evaluates to 0
error: casting a known NaN to usize
--> tests/ui/cast_nan_to_int.rs:15:13
--> tests/ui/cast_nan_to_int.rs:17:13
|
LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -33,7 +33,7 @@ LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize;
= note: this always evaluates to 0
error: casting a known NaN to usize
--> tests/ui/cast_nan_to_int.rs:18:13
--> tests/ui/cast_nan_to_int.rs:20:13
|
LL | let _ = (f32::INFINITY - f32::INFINITY) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -41,7 +41,7 @@ LL | let _ = (f32::INFINITY - f32::INFINITY) as usize;
= note: this always evaluates to 0
error: casting a known NaN to usize
--> tests/ui/cast_nan_to_int.rs:21:13
--> tests/ui/cast_nan_to_int.rs:23:13
|
LL | let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -12,35 +12,35 @@ help: ... or use `try_from` and handle the error accordingly
LL | i8::try_from(1isize);
| ~~~~~~~~~~~~~~~~~~~~
error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast_size.rs:18:5
error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:21:5
|
LL | x0 as f64;
LL | x0 as f32;
| ^^^^^^^^^
|
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast_size.rs:19:5
|
LL | x1 as f64;
| ^^^^^^^^^
error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:20:5
|
LL | x0 as f32;
| ^^^^^^^^^
error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:21:5
--> tests/ui/cast_size.rs:22:5
|
LL | x1 as f32;
| ^^^^^^^^^
error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast_size.rs:23:5
|
LL | x0 as f64;
| ^^^^^^^^^
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast_size.rs:24:5
|
LL | x1 as f64;
| ^^^^^^^^^
error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
--> tests/ui/cast_size.rs:22:5
--> tests/ui/cast_size.rs:28:5
|
LL | 1isize as i32;
| ^^^^^^^^^^^^^
@ -52,7 +52,7 @@ LL | i32::try_from(1isize);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
--> tests/ui/cast_size.rs:23:5
--> tests/ui/cast_size.rs:29:5
|
LL | 1isize as u32;
| ^^^^^^^^^^^^^
@ -64,7 +64,7 @@ LL | u32::try_from(1isize);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
--> tests/ui/cast_size.rs:24:5
--> tests/ui/cast_size.rs:30:5
|
LL | 1usize as u32;
| ^^^^^^^^^^^^^
@ -76,7 +76,7 @@ LL | u32::try_from(1usize);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
--> tests/ui/cast_size.rs:25:5
--> tests/ui/cast_size.rs:31:5
|
LL | 1usize as i32;
| ^^^^^^^^^^^^^
@ -88,7 +88,7 @@ LL | i32::try_from(1usize);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
--> tests/ui/cast_size.rs:25:5
--> tests/ui/cast_size.rs:31:5
|
LL | 1usize as i32;
| ^^^^^^^^^^^^^
@ -97,7 +97,7 @@ LL | 1usize as i32;
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast_size.rs:26:5
--> tests/ui/cast_size.rs:32:5
|
LL | 1i64 as isize;
| ^^^^^^^^^^^^^
@ -109,7 +109,7 @@ LL | isize::try_from(1i64);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast_size.rs:27:5
--> tests/ui/cast_size.rs:33:5
|
LL | 1i64 as usize;
| ^^^^^^^^^^^^^
@ -121,7 +121,7 @@ LL | usize::try_from(1i64);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast_size.rs:28:5
--> tests/ui/cast_size.rs:34:5
|
LL | 1u64 as isize;
| ^^^^^^^^^^^^^
@ -133,13 +133,13 @@ LL | isize::try_from(1u64);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
--> tests/ui/cast_size.rs:28:5
--> tests/ui/cast_size.rs:34:5
|
LL | 1u64 as isize;
| ^^^^^^^^^^^^^
error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
--> tests/ui/cast_size.rs:29:5
--> tests/ui/cast_size.rs:35:5
|
LL | 1u64 as usize;
| ^^^^^^^^^^^^^
@ -151,19 +151,19 @@ LL | usize::try_from(1u64);
| ~~~~~~~~~~~~~~~~~~~~~
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
--> tests/ui/cast_size.rs:30:5
--> tests/ui/cast_size.rs:36:5
|
LL | 1u32 as isize;
| ^^^^^^^^^^^^^
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:35:5
--> tests/ui/cast_size.rs:43:5
|
LL | 999_999_999 as f32;
| ^^^^^^^^^^^^^^^^^^
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> tests/ui/cast_size.rs:36:5
--> tests/ui/cast_size.rs:44:5
|
LL | 9_999_999_999_999_999usize as f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -15,10 +15,16 @@ fn main() {
1isize as i8;
let x0 = 1isize;
let x1 = 1usize;
x0 as f64;
x1 as f64;
// FIXME(f16_f128): enable f16 and f128 conversions once const eval supports them
// x0 as f16;
// x1 as f16;
x0 as f32;
x1 as f32;
x0 as f64;
x1 as f64;
// x0 as f128;
// x1 as f128;
1isize as i32;
1isize as u32;
1usize as u32;
@ -31,7 +37,10 @@ fn main() {
1u32 as usize; // Should not trigger any lint
1i32 as isize; // Neither should this
1i32 as usize;
// Big integer literal to float
// 999_999 as f16;
999_999_999 as f32;
9_999_999_999_999_999usize as f64;
// 999_999_999_999_999_999_999_999_999_999u128 as f128;
}

View file

@ -2,6 +2,8 @@
#![allow(clippy::diverging_sub_expression)]
#![no_main]
// FIXME(f16_f128): add these types when `{to_from}_*_bytes` are available
macro_rules! fn_body {
() => {
2u8.to_ne_bytes();

View file

@ -1,5 +1,5 @@
error: usage of the `u8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:7:9
--> tests/ui/endian_bytes.rs:9:9
|
LL | 2u8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -13,7 +13,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:8:9
--> tests/ui/endian_bytes.rs:10:9
|
LL | 2i8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u16::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:9:9
--> tests/ui/endian_bytes.rs:11:9
|
LL | 2u16.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -37,7 +37,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i16::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:10:9
--> tests/ui/endian_bytes.rs:12:9
|
LL | 2i16.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -49,7 +49,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u32::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:11:9
--> tests/ui/endian_bytes.rs:13:9
|
LL | 2u32.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -61,7 +61,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i32::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:12:9
--> tests/ui/endian_bytes.rs:14:9
|
LL | 2i32.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -73,7 +73,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u64::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:13:9
--> tests/ui/endian_bytes.rs:15:9
|
LL | 2u64.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -85,7 +85,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i64::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:14:9
--> tests/ui/endian_bytes.rs:16:9
|
LL | 2i64.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -97,7 +97,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u128::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:15:9
--> tests/ui/endian_bytes.rs:17:9
|
LL | 2u128.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^^
@ -109,7 +109,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i128::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:16:9
--> tests/ui/endian_bytes.rs:18:9
|
LL | 2i128.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^^
@ -121,7 +121,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `f32::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:17:9
--> tests/ui/endian_bytes.rs:19:9
|
LL | 2.0f32.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -133,7 +133,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `f64::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:18:9
--> tests/ui/endian_bytes.rs:20:9
|
LL | 2.0f64.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -145,7 +145,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `usize::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:19:9
--> tests/ui/endian_bytes.rs:21:9
|
LL | 2usize.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -157,7 +157,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `isize::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:20:9
--> tests/ui/endian_bytes.rs:22:9
|
LL | 2isize.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -169,7 +169,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:21:9
--> tests/ui/endian_bytes.rs:23:9
|
LL | u8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -181,7 +181,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:22:9
--> tests/ui/endian_bytes.rs:24:9
|
LL | i8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -193,7 +193,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u16::from_ne_bytes`
--> tests/ui/endian_bytes.rs:23:9
--> tests/ui/endian_bytes.rs:25:9
|
LL | u16::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -205,7 +205,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i16::from_ne_bytes`
--> tests/ui/endian_bytes.rs:24:9
--> tests/ui/endian_bytes.rs:26:9
|
LL | i16::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -217,7 +217,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u32::from_ne_bytes`
--> tests/ui/endian_bytes.rs:25:9
--> tests/ui/endian_bytes.rs:27:9
|
LL | u32::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -229,7 +229,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i32::from_ne_bytes`
--> tests/ui/endian_bytes.rs:26:9
--> tests/ui/endian_bytes.rs:28:9
|
LL | i32::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -241,7 +241,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u64::from_ne_bytes`
--> tests/ui/endian_bytes.rs:27:9
--> tests/ui/endian_bytes.rs:29:9
|
LL | u64::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -253,7 +253,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i64::from_ne_bytes`
--> tests/ui/endian_bytes.rs:28:9
--> tests/ui/endian_bytes.rs:30:9
|
LL | i64::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -265,7 +265,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u128::from_ne_bytes`
--> tests/ui/endian_bytes.rs:29:9
--> tests/ui/endian_bytes.rs:31:9
|
LL | u128::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -277,7 +277,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i128::from_ne_bytes`
--> tests/ui/endian_bytes.rs:30:9
--> tests/ui/endian_bytes.rs:32:9
|
LL | i128::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -289,7 +289,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `usize::from_ne_bytes`
--> tests/ui/endian_bytes.rs:31:9
--> tests/ui/endian_bytes.rs:33:9
|
LL | usize::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -301,7 +301,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `isize::from_ne_bytes`
--> tests/ui/endian_bytes.rs:32:9
--> tests/ui/endian_bytes.rs:34:9
|
LL | isize::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -313,7 +313,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `f32::from_ne_bytes`
--> tests/ui/endian_bytes.rs:33:9
--> tests/ui/endian_bytes.rs:35:9
|
LL | f32::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -325,7 +325,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `f64::from_ne_bytes`
--> tests/ui/endian_bytes.rs:34:9
--> tests/ui/endian_bytes.rs:36:9
|
LL | f64::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -337,7 +337,7 @@ LL | fn host() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:36:9
--> tests/ui/endian_bytes.rs:38:9
|
LL | 2u8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -351,7 +351,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:37:9
--> tests/ui/endian_bytes.rs:39:9
|
LL | 2i8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -363,7 +363,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u16::to_le_bytes` method
--> tests/ui/endian_bytes.rs:38:9
--> tests/ui/endian_bytes.rs:40:9
|
LL | 2u16.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -375,7 +375,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i16::to_le_bytes` method
--> tests/ui/endian_bytes.rs:39:9
--> tests/ui/endian_bytes.rs:41:9
|
LL | 2i16.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -387,7 +387,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u32::to_le_bytes` method
--> tests/ui/endian_bytes.rs:40:9
--> tests/ui/endian_bytes.rs:42:9
|
LL | 2u32.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -399,7 +399,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i32::to_le_bytes` method
--> tests/ui/endian_bytes.rs:41:9
--> tests/ui/endian_bytes.rs:43:9
|
LL | 2i32.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -411,7 +411,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u64::to_le_bytes` method
--> tests/ui/endian_bytes.rs:42:9
--> tests/ui/endian_bytes.rs:44:9
|
LL | 2u64.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -423,7 +423,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i64::to_le_bytes` method
--> tests/ui/endian_bytes.rs:43:9
--> tests/ui/endian_bytes.rs:45:9
|
LL | 2i64.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^
@ -435,7 +435,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u128::to_le_bytes` method
--> tests/ui/endian_bytes.rs:44:9
--> tests/ui/endian_bytes.rs:46:9
|
LL | 2u128.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^^
@ -447,7 +447,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `i128::to_le_bytes` method
--> tests/ui/endian_bytes.rs:45:9
--> tests/ui/endian_bytes.rs:47:9
|
LL | 2i128.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^^
@ -459,7 +459,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `f32::to_le_bytes` method
--> tests/ui/endian_bytes.rs:46:9
--> tests/ui/endian_bytes.rs:48:9
|
LL | 2.0f32.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -471,7 +471,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `f64::to_le_bytes` method
--> tests/ui/endian_bytes.rs:47:9
--> tests/ui/endian_bytes.rs:49:9
|
LL | 2.0f64.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -483,7 +483,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `usize::to_le_bytes` method
--> tests/ui/endian_bytes.rs:48:9
--> tests/ui/endian_bytes.rs:50:9
|
LL | 2usize.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -495,7 +495,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `isize::to_le_bytes` method
--> tests/ui/endian_bytes.rs:49:9
--> tests/ui/endian_bytes.rs:51:9
|
LL | 2isize.to_le_bytes();
| ^^^^^^^^^^^^^^^^^^^^
@ -507,7 +507,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_le_bytes`
--> tests/ui/endian_bytes.rs:50:9
--> tests/ui/endian_bytes.rs:52:9
|
LL | u8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -519,7 +519,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i8::from_le_bytes`
--> tests/ui/endian_bytes.rs:51:9
--> tests/ui/endian_bytes.rs:53:9
|
LL | i8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -531,7 +531,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u16::from_le_bytes`
--> tests/ui/endian_bytes.rs:52:9
--> tests/ui/endian_bytes.rs:54:9
|
LL | u16::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -543,7 +543,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i16::from_le_bytes`
--> tests/ui/endian_bytes.rs:53:9
--> tests/ui/endian_bytes.rs:55:9
|
LL | i16::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -555,7 +555,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u32::from_le_bytes`
--> tests/ui/endian_bytes.rs:54:9
--> tests/ui/endian_bytes.rs:56:9
|
LL | u32::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -567,7 +567,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i32::from_le_bytes`
--> tests/ui/endian_bytes.rs:55:9
--> tests/ui/endian_bytes.rs:57:9
|
LL | i32::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -579,7 +579,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u64::from_le_bytes`
--> tests/ui/endian_bytes.rs:56:9
--> tests/ui/endian_bytes.rs:58:9
|
LL | u64::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -591,7 +591,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i64::from_le_bytes`
--> tests/ui/endian_bytes.rs:57:9
--> tests/ui/endian_bytes.rs:59:9
|
LL | i64::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -603,7 +603,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u128::from_le_bytes`
--> tests/ui/endian_bytes.rs:58:9
--> tests/ui/endian_bytes.rs:60:9
|
LL | u128::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -615,7 +615,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `i128::from_le_bytes`
--> tests/ui/endian_bytes.rs:59:9
--> tests/ui/endian_bytes.rs:61:9
|
LL | i128::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -627,7 +627,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `usize::from_le_bytes`
--> tests/ui/endian_bytes.rs:60:9
--> tests/ui/endian_bytes.rs:62:9
|
LL | usize::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -639,7 +639,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `isize::from_le_bytes`
--> tests/ui/endian_bytes.rs:61:9
--> tests/ui/endian_bytes.rs:63:9
|
LL | isize::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -651,7 +651,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `f32::from_le_bytes`
--> tests/ui/endian_bytes.rs:62:9
--> tests/ui/endian_bytes.rs:64:9
|
LL | f32::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -663,7 +663,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `f64::from_le_bytes`
--> tests/ui/endian_bytes.rs:63:9
--> tests/ui/endian_bytes.rs:65:9
|
LL | f64::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -675,7 +675,7 @@ LL | fn little() { fn_body!(); }
= note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:70:9
--> tests/ui/endian_bytes.rs:72:9
|
LL | 2u8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -687,7 +687,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:71:9
--> tests/ui/endian_bytes.rs:73:9
|
LL | u8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -699,7 +699,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_be_bytes` method
--> tests/ui/endian_bytes.rs:76:9
--> tests/ui/endian_bytes.rs:78:9
|
LL | 2u8.to_be_bytes();
| ^^^^^^^^^^^^^^^^^
@ -713,7 +713,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_be_bytes`
--> tests/ui/endian_bytes.rs:77:9
--> tests/ui/endian_bytes.rs:79:9
|
LL | u8::from_be_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -725,7 +725,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:70:9
--> tests/ui/endian_bytes.rs:72:9
|
LL | 2u8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -737,7 +737,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:71:9
--> tests/ui/endian_bytes.rs:73:9
|
LL | u8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -749,7 +749,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:73:9
--> tests/ui/endian_bytes.rs:75:9
|
LL | 2u8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -761,7 +761,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_le_bytes`
--> tests/ui/endian_bytes.rs:74:9
--> tests/ui/endian_bytes.rs:76:9
|
LL | u8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -773,7 +773,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:70:9
--> tests/ui/endian_bytes.rs:72:9
|
LL | 2u8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -784,7 +784,7 @@ LL | fn no_help() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:71:9
--> tests/ui/endian_bytes.rs:73:9
|
LL | u8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -795,7 +795,7 @@ LL | fn no_help() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:73:9
--> tests/ui/endian_bytes.rs:75:9
|
LL | 2u8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -806,7 +806,7 @@ LL | fn no_help() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_le_bytes`
--> tests/ui/endian_bytes.rs:74:9
--> tests/ui/endian_bytes.rs:76:9
|
LL | u8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -817,7 +817,7 @@ LL | fn no_help() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_be_bytes` method
--> tests/ui/endian_bytes.rs:76:9
--> tests/ui/endian_bytes.rs:78:9
|
LL | 2u8.to_be_bytes();
| ^^^^^^^^^^^^^^^^^
@ -828,7 +828,7 @@ LL | fn no_help() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_be_bytes`
--> tests/ui/endian_bytes.rs:77:9
--> tests/ui/endian_bytes.rs:79:9
|
LL | u8::from_be_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -839,7 +839,7 @@ LL | fn no_help() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:73:9
--> tests/ui/endian_bytes.rs:75:9
|
LL | 2u8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -851,7 +851,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_le_bytes`
--> tests/ui/endian_bytes.rs:74:9
--> tests/ui/endian_bytes.rs:76:9
|
LL | u8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -863,7 +863,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_be_bytes` method
--> tests/ui/endian_bytes.rs:76:9
--> tests/ui/endian_bytes.rs:78:9
|
LL | 2u8.to_be_bytes();
| ^^^^^^^^^^^^^^^^^
@ -875,7 +875,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_be_bytes`
--> tests/ui/endian_bytes.rs:77:9
--> tests/ui/endian_bytes.rs:79:9
|
LL | u8::from_be_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -887,7 +887,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:70:9
--> tests/ui/endian_bytes.rs:72:9
|
LL | 2u8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -899,7 +899,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:71:9
--> tests/ui/endian_bytes.rs:73:9
|
LL | u8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -911,7 +911,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:73:9
--> tests/ui/endian_bytes.rs:75:9
|
LL | 2u8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -923,7 +923,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_le_bytes`
--> tests/ui/endian_bytes.rs:74:9
--> tests/ui/endian_bytes.rs:76:9
|
LL | u8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -935,7 +935,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_le_bytes` method
--> tests/ui/endian_bytes.rs:73:9
--> tests/ui/endian_bytes.rs:75:9
|
LL | 2u8.to_le_bytes();
| ^^^^^^^^^^^^^^^^^
@ -947,7 +947,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_le_bytes`
--> tests/ui/endian_bytes.rs:74:9
--> tests/ui/endian_bytes.rs:76:9
|
LL | u8::from_le_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -959,7 +959,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_be_bytes` method
--> tests/ui/endian_bytes.rs:76:9
--> tests/ui/endian_bytes.rs:78:9
|
LL | 2u8.to_be_bytes();
| ^^^^^^^^^^^^^^^^^
@ -971,7 +971,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_be_bytes`
--> tests/ui/endian_bytes.rs:77:9
--> tests/ui/endian_bytes.rs:79:9
|
LL | u8::from_be_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -983,7 +983,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_ne_bytes` method
--> tests/ui/endian_bytes.rs:70:9
--> tests/ui/endian_bytes.rs:72:9
|
LL | 2u8.to_ne_bytes();
| ^^^^^^^^^^^^^^^^^
@ -995,7 +995,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_ne_bytes`
--> tests/ui/endian_bytes.rs:71:9
--> tests/ui/endian_bytes.rs:73:9
|
LL | u8::from_ne_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1007,7 +1007,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the `u8::to_be_bytes` method
--> tests/ui/endian_bytes.rs:76:9
--> tests/ui/endian_bytes.rs:78:9
|
LL | 2u8.to_be_bytes();
| ^^^^^^^^^^^^^^^^^
@ -1019,7 +1019,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); }
= note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info)
error: usage of the function `u8::from_be_bytes`
--> tests/ui/endian_bytes.rs:77:9
--> tests/ui/endian_bytes.rs:79:9
|
LL | u8::from_be_bytes(todo!());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,3 +1,5 @@
// FIXME(f16_f128): const casting is not yet supported for these types. Add when available.
#![warn(clippy::float_cmp)]
#![allow(
unused,

View file

@ -1,5 +1,5 @@
error: strict comparison of `f32` or `f64`
--> tests/ui/float_cmp.rs:70:5
--> tests/ui/float_cmp.rs:72:5
|
LL | ONE as f64 != 2.0;
| ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin`
@ -9,7 +9,7 @@ LL | ONE as f64 != 2.0;
= help: to override `-D warnings` add `#[allow(clippy::float_cmp)]`
error: strict comparison of `f32` or `f64`
--> tests/ui/float_cmp.rs:77:5
--> tests/ui/float_cmp.rs:79:5
|
LL | x == 1.0;
| ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 1.0).abs() < error_margin`
@ -17,7 +17,7 @@ LL | x == 1.0;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64`
--> tests/ui/float_cmp.rs:82:5
--> tests/ui/float_cmp.rs:84:5
|
LL | twice(x) != twice(ONE as f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin`
@ -25,7 +25,7 @@ LL | twice(x) != twice(ONE as f64);
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64`
--> tests/ui/float_cmp.rs:104:5
--> tests/ui/float_cmp.rs:106:5
|
LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin`
@ -33,7 +33,7 @@ LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j];
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` arrays
--> tests/ui/float_cmp.rs:111:5
--> tests/ui/float_cmp.rs:113:5
|
LL | a1 == a2;
| ^^^^^^^^
@ -41,7 +41,7 @@ LL | a1 == a2;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64`
--> tests/ui/float_cmp.rs:114:5
--> tests/ui/float_cmp.rs:116:5
|
LL | a1[0] == a2[0];
| ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin`

View file

@ -1,5 +1,8 @@
#![warn(clippy::float_equality_without_abs)]
//@no-rustfix
// FIXME(f16_f128): add tests for these types when abs is available
pub fn is_roughly_equal(a: f32, b: f32) -> bool {
(a - b) < f32::EPSILON
//~^ ERROR: float equality check without `.abs()`

View file

@ -1,5 +1,5 @@
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:4:5
--> tests/ui/float_equality_without_abs.rs:7:5
|
LL | (a - b) < f32::EPSILON
| -------^^^^^^^^^^^^^^^
@ -10,7 +10,7 @@ LL | (a - b) < f32::EPSILON
= help: to override `-D warnings` add `#[allow(clippy::float_equality_without_abs)]`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:15:13
--> tests/ui/float_equality_without_abs.rs:18:13
|
LL | let _ = (a - b) < f32::EPSILON;
| -------^^^^^^^^^^^^^^^
@ -18,7 +18,7 @@ LL | let _ = (a - b) < f32::EPSILON;
| help: add `.abs()`: `(a - b).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:17:13
--> tests/ui/float_equality_without_abs.rs:20:13
|
LL | let _ = a - b < f32::EPSILON;
| -----^^^^^^^^^^^^^^^
@ -26,7 +26,7 @@ LL | let _ = a - b < f32::EPSILON;
| help: add `.abs()`: `(a - b).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:19:13
--> tests/ui/float_equality_without_abs.rs:22:13
|
LL | let _ = a - b.abs() < f32::EPSILON;
| -----------^^^^^^^^^^^^^^^
@ -34,7 +34,7 @@ LL | let _ = a - b.abs() < f32::EPSILON;
| help: add `.abs()`: `(a - b.abs()).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:21:13
--> tests/ui/float_equality_without_abs.rs:24:13
|
LL | let _ = (a as f64 - b as f64) < f64::EPSILON;
| ---------------------^^^^^^^^^^^^^^^
@ -42,7 +42,7 @@ LL | let _ = (a as f64 - b as f64) < f64::EPSILON;
| help: add `.abs()`: `(a as f64 - b as f64).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:23:13
--> tests/ui/float_equality_without_abs.rs:26:13
|
LL | let _ = 1.0 - 2.0 < f32::EPSILON;
| ---------^^^^^^^^^^^^^^^
@ -50,7 +50,7 @@ LL | let _ = 1.0 - 2.0 < f32::EPSILON;
| help: add `.abs()`: `(1.0 - 2.0).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:26:13
--> tests/ui/float_equality_without_abs.rs:29:13
|
LL | let _ = f32::EPSILON > (a - b);
| ^^^^^^^^^^^^^^^-------
@ -58,7 +58,7 @@ LL | let _ = f32::EPSILON > (a - b);
| help: add `.abs()`: `(a - b).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:28:13
--> tests/ui/float_equality_without_abs.rs:31:13
|
LL | let _ = f32::EPSILON > a - b;
| ^^^^^^^^^^^^^^^-----
@ -66,7 +66,7 @@ LL | let _ = f32::EPSILON > a - b;
| help: add `.abs()`: `(a - b).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:30:13
--> tests/ui/float_equality_without_abs.rs:33:13
|
LL | let _ = f32::EPSILON > a - b.abs();
| ^^^^^^^^^^^^^^^-----------
@ -74,7 +74,7 @@ LL | let _ = f32::EPSILON > a - b.abs();
| help: add `.abs()`: `(a - b.abs()).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:32:13
--> tests/ui/float_equality_without_abs.rs:35:13
|
LL | let _ = f64::EPSILON > (a as f64 - b as f64);
| ^^^^^^^^^^^^^^^---------------------
@ -82,7 +82,7 @@ LL | let _ = f64::EPSILON > (a as f64 - b as f64);
| help: add `.abs()`: `(a as f64 - b as f64).abs()`
error: float equality check without `.abs()`
--> tests/ui/float_equality_without_abs.rs:34:13
--> tests/ui/float_equality_without_abs.rs:37:13
|
LL | let _ = f32::EPSILON > 1.0 - 2.0;
| ^^^^^^^^^^^^^^^---------

View file

@ -3,8 +3,8 @@
#![warn(clippy::suboptimal_flops)]
#![no_std]
// The following should not lint, as the suggested methods {f32,f64}.mul_add()
// and {f32,f64}::abs() are not available in no_std
// The following should not lint, as the suggested methods `{f16,f32,f64,f128}.mul_add()`
// and ``{f16,f32,f64,f128}::abs()` are not available in no_std
pub fn mul_add() {
let a: f64 = 1234.567;

View file

@ -1,3 +1,5 @@
// FIXME(f16_f128): add tests when exp is available
#![warn(clippy::imprecise_flops)]
#![allow(clippy::unnecessary_cast)]

View file

@ -1,3 +1,5 @@
// FIXME(f16_f128): add tests when exp is available
#![warn(clippy::imprecise_flops)]
#![allow(clippy::unnecessary_cast)]

View file

@ -1,5 +1,5 @@
error: (e.pow(x) - 1) can be computed more accurately
--> tests/ui/floating_point_exp.rs:6:13
--> tests/ui/floating_point_exp.rs:8:13
|
LL | let _ = x.exp() - 1.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
@ -8,25 +8,25 @@ LL | let _ = x.exp() - 1.0;
= help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]`
error: (e.pow(x) - 1) can be computed more accurately
--> tests/ui/floating_point_exp.rs:7:13
--> tests/ui/floating_point_exp.rs:9:13
|
LL | let _ = x.exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately
--> tests/ui/floating_point_exp.rs:8:13
--> tests/ui/floating_point_exp.rs:10:13
|
LL | let _ = (x as f32).exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately
--> tests/ui/floating_point_exp.rs:14:13
--> tests/ui/floating_point_exp.rs:16:13
|
LL | let _ = x.exp() - 1.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately
--> tests/ui/floating_point_exp.rs:15:13
--> tests/ui/floating_point_exp.rs:17:13
|
LL | let _ = x.exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`

View file

@ -1,6 +1,8 @@
#![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)]
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
// FIXME(f16_f128): add tests for these types once math functions are available
const TWO: f32 = 2.0;
const E: f32 = std::f32::consts::E;

View file

@ -1,6 +1,8 @@
#![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)]
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
// FIXME(f16_f128): add tests for these types once math functions are available
const TWO: f32 = 2.0;
const E: f32 = std::f32::consts::E;

View file

@ -1,5 +1,5 @@
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:9:13
--> tests/ui/floating_point_log.rs:11:13
|
LL | let _ = x.log(2f32);
| ^^^^^^^^^^^ help: consider using: `x.log2()`
@ -8,55 +8,55 @@ LL | let _ = x.log(2f32);
= help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:10:13
--> tests/ui/floating_point_log.rs:12:13
|
LL | let _ = x.log(10f32);
| ^^^^^^^^^^^^ help: consider using: `x.log10()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:11:13
--> tests/ui/floating_point_log.rs:13:13
|
LL | let _ = x.log(std::f32::consts::E);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:12:13
--> tests/ui/floating_point_log.rs:14:13
|
LL | let _ = x.log(TWO);
| ^^^^^^^^^^ help: consider using: `x.log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:13:13
--> tests/ui/floating_point_log.rs:15:13
|
LL | let _ = x.log(E);
| ^^^^^^^^ help: consider using: `x.ln()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:14:13
--> tests/ui/floating_point_log.rs:16:13
|
LL | let _ = (x as f32).log(2f32);
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:17:13
--> tests/ui/floating_point_log.rs:19:13
|
LL | let _ = x.log(2f64);
| ^^^^^^^^^^^ help: consider using: `x.log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:18:13
--> tests/ui/floating_point_log.rs:20:13
|
LL | let _ = x.log(10f64);
| ^^^^^^^^^^^^ help: consider using: `x.log10()`
error: logarithm for bases 2, 10 and e can be computed more accurately
--> tests/ui/floating_point_log.rs:19:13
--> tests/ui/floating_point_log.rs:21:13
|
LL | let _ = x.log(std::f64::consts::E);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:24:13
--> tests/ui/floating_point_log.rs:26:13
|
LL | let _ = (1f32 + 2.).ln();
| ^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()`
@ -65,115 +65,115 @@ LL | let _ = (1f32 + 2.).ln();
= help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:25:13
--> tests/ui/floating_point_log.rs:27:13
|
LL | let _ = (1f32 + 2.0).ln();
| ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:26:13
--> tests/ui/floating_point_log.rs:28:13
|
LL | let _ = (1.0 + x).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:27:13
--> tests/ui/floating_point_log.rs:29:13
|
LL | let _ = (1.0 + x / 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:28:13
--> tests/ui/floating_point_log.rs:30:13
|
LL | let _ = (1.0 + x.powi(3)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:29:13
--> tests/ui/floating_point_log.rs:31:13
|
LL | let _ = (1.0 + x.powi(3) / 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(3) / 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:30:13
--> tests/ui/floating_point_log.rs:32:13
|
LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(std::f32::consts::E - 1.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:31:13
--> tests/ui/floating_point_log.rs:33:13
|
LL | let _ = (x + 1.0).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:32:13
--> tests/ui/floating_point_log.rs:34:13
|
LL | let _ = (x.powi(3) + 1.0).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:33:13
--> tests/ui/floating_point_log.rs:35:13
|
LL | let _ = (x + 2.0 + 1.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:34:13
--> tests/ui/floating_point_log.rs:36:13
|
LL | let _ = (x / 2.0 + 1.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:42:13
--> tests/ui/floating_point_log.rs:44:13
|
LL | let _ = (1f64 + 2.).ln();
| ^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:43:13
--> tests/ui/floating_point_log.rs:45:13
|
LL | let _ = (1f64 + 2.0).ln();
| ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:44:13
--> tests/ui/floating_point_log.rs:46:13
|
LL | let _ = (1.0 + x).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:45:13
--> tests/ui/floating_point_log.rs:47:13
|
LL | let _ = (1.0 + x / 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:46:13
--> tests/ui/floating_point_log.rs:48:13
|
LL | let _ = (1.0 + x.powi(3)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:47:13
--> tests/ui/floating_point_log.rs:49:13
|
LL | let _ = (x + 1.0).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:48:13
--> tests/ui/floating_point_log.rs:50:13
|
LL | let _ = (x.powi(3) + 1.0).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:49:13
--> tests/ui/floating_point_log.rs:51:13
|
LL | let _ = (x + 2.0 + 1.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately
--> tests/ui/floating_point_log.rs:50:13
--> tests/ui/floating_point_log.rs:52:13
|
LL | let _ = (x / 2.0 + 1.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()`

View file

@ -1,6 +1,8 @@
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
#![allow(clippy::unnecessary_cast)]
// FIXME(f16_f128): add tests for these types when `powf` is available
fn main() {
let x = 3f32;
let _ = x.exp2();

View file

@ -1,6 +1,8 @@
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
#![allow(clippy::unnecessary_cast)]
// FIXME(f16_f128): add tests for these types when `powf` is available
fn main() {
let x = 3f32;
let _ = 2f32.powf(x);

View file

@ -1,5 +1,5 @@
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:6:13
--> tests/ui/floating_point_powf.rs:8:13
|
LL | let _ = 2f32.powf(x);
| ^^^^^^^^^^^^ help: consider using: `x.exp2()`
@ -8,43 +8,43 @@ LL | let _ = 2f32.powf(x);
= help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:7:13
--> tests/ui/floating_point_powf.rs:9:13
|
LL | let _ = 2f32.powf(3.1);
| ^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp2()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:8:13
--> tests/ui/floating_point_powf.rs:10:13
|
LL | let _ = 2f32.powf(-3.1);
| ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp2()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:9:13
--> tests/ui/floating_point_powf.rs:11:13
|
LL | let _ = std::f32::consts::E.powf(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:10:13
--> tests/ui/floating_point_powf.rs:12:13
|
LL | let _ = std::f32::consts::E.powf(3.1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:11:13
--> tests/ui/floating_point_powf.rs:13:13
|
LL | let _ = std::f32::consts::E.powf(-3.1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp()`
error: square-root of a number can be computed more efficiently and accurately
--> tests/ui/floating_point_powf.rs:12:13
--> tests/ui/floating_point_powf.rs:14:13
|
LL | let _ = x.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()`
error: cube-root of a number can be computed more accurately
--> tests/ui/floating_point_powf.rs:13:13
--> tests/ui/floating_point_powf.rs:15:13
|
LL | let _ = x.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
@ -53,139 +53,139 @@ LL | let _ = x.powf(1.0 / 3.0);
= help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]`
error: cube-root of a number can be computed more accurately
--> tests/ui/floating_point_powf.rs:14:13
--> tests/ui/floating_point_powf.rs:16:13
|
LL | let _ = (x as f32).powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).cbrt()`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:15:13
--> tests/ui/floating_point_powf.rs:17:13
|
LL | let _ = x.powf(3.0);
| ^^^^^^^^^^^ help: consider using: `x.powi(3)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:16:13
--> tests/ui/floating_point_powf.rs:18:13
|
LL | let _ = x.powf(-2.0);
| ^^^^^^^^^^^^ help: consider using: `x.powi(-2)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:17:13
--> tests/ui/floating_point_powf.rs:19:13
|
LL | let _ = x.powf(16_777_215.0);
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(16_777_215)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:18:13
--> tests/ui/floating_point_powf.rs:20:13
|
LL | let _ = x.powf(-16_777_215.0);
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-16_777_215)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:19:13
--> tests/ui/floating_point_powf.rs:21:13
|
LL | let _ = (x as f32).powf(-16_777_215.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(-16_777_215)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:20:13
--> tests/ui/floating_point_powf.rs:22:13
|
LL | let _ = (x as f32).powf(3.0);
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(3)`
error: cube-root of a number can be computed more accurately
--> tests/ui/floating_point_powf.rs:21:13
--> tests/ui/floating_point_powf.rs:23:13
|
LL | let _ = (1.5_f32 + 1.0).powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(1.5_f32 + 1.0).cbrt()`
error: cube-root of a number can be computed more accurately
--> tests/ui/floating_point_powf.rs:22:13
--> tests/ui/floating_point_powf.rs:24:13
|
LL | let _ = 1.5_f64.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.cbrt()`
error: square-root of a number can be computed more efficiently and accurately
--> tests/ui/floating_point_powf.rs:23:13
--> tests/ui/floating_point_powf.rs:25:13
|
LL | let _ = 1.5_f64.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.sqrt()`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:24:13
--> tests/ui/floating_point_powf.rs:26:13
|
LL | let _ = 1.5_f64.powf(3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.powi(3)`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:33:13
--> tests/ui/floating_point_powf.rs:35:13
|
LL | let _ = 2f64.powf(x);
| ^^^^^^^^^^^^ help: consider using: `x.exp2()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:34:13
--> tests/ui/floating_point_powf.rs:36:13
|
LL | let _ = 2f64.powf(3.1);
| ^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp2()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:35:13
--> tests/ui/floating_point_powf.rs:37:13
|
LL | let _ = 2f64.powf(-3.1);
| ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp2()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:36:13
--> tests/ui/floating_point_powf.rs:38:13
|
LL | let _ = std::f64::consts::E.powf(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:37:13
--> tests/ui/floating_point_powf.rs:39:13
|
LL | let _ = std::f64::consts::E.powf(3.1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp()`
error: exponent for bases 2 and e can be computed more accurately
--> tests/ui/floating_point_powf.rs:38:13
--> tests/ui/floating_point_powf.rs:40:13
|
LL | let _ = std::f64::consts::E.powf(-3.1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp()`
error: square-root of a number can be computed more efficiently and accurately
--> tests/ui/floating_point_powf.rs:39:13
--> tests/ui/floating_point_powf.rs:41:13
|
LL | let _ = x.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()`
error: cube-root of a number can be computed more accurately
--> tests/ui/floating_point_powf.rs:40:13
--> tests/ui/floating_point_powf.rs:42:13
|
LL | let _ = x.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:41:13
--> tests/ui/floating_point_powf.rs:43:13
|
LL | let _ = x.powf(3.0);
| ^^^^^^^^^^^ help: consider using: `x.powi(3)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:42:13
--> tests/ui/floating_point_powf.rs:44:13
|
LL | let _ = x.powf(-2.0);
| ^^^^^^^^^^^^ help: consider using: `x.powi(-2)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:43:13
--> tests/ui/floating_point_powf.rs:45:13
|
LL | let _ = x.powf(-2_147_483_648.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-2_147_483_648)`
error: exponentiation with integer powers can be computed more efficiently
--> tests/ui/floating_point_powf.rs:44:13
--> tests/ui/floating_point_powf.rs:46:13
|
LL | let _ = x.powf(2_147_483_647.0);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2_147_483_647)`

View file

@ -1,31 +1,55 @@
#![warn(clippy::lossy_float_literal)]
#![allow(overflowing_literals, unused)]
#![feature(f128)]
#![feature(f16)]
fn main() {
// Lossy whole-number float literals
let _: f16 = 4_097.0;
let _: f16 = 4_097.;
let _: f16 = 4_097.000;
let _ = 4_097f16;
let _: f16 = -4_097.0;
let _: f32 = 16_777_216.0;
let _: f32 = 16_777_220.0;
let _: f32 = 16_777_220.0;
let _: f32 = 16_777_220.0;
let _ = 16_777_220_f32;
let _: f32 = -16_777_220.0;
let _: f64 = 9_007_199_254_740_992.0;
let _: f64 = 9_007_199_254_740_992.0;
let _: f64 = 9_007_199_254_740_992.0;
let _ = 9_007_199_254_740_992_f64;
let _: f64 = -9_007_199_254_740_992.0;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_193.0;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_193.;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_193.00;
let _ = 10_384_593_717_069_655_257_060_992_658_440_193f128;
let _: f128 = -10_384_593_717_069_655_257_060_992_658_440_193.0;
// Lossless whole number float literals
let _: f16 = 4_096.0;
let _: f16 = -4_096.0;
let _: f32 = 16_777_216.0;
let _: f32 = 16_777_218.0;
let _: f32 = 16_777_220.0;
let _: f32 = -16_777_216.0;
let _: f32 = -16_777_220.0;
let _: f64 = 16_777_217.0;
let _: f64 = -16_777_217.0;
let _: f64 = 9_007_199_254_740_992.0;
let _: f64 = -9_007_199_254_740_992.0;
let _: f128 = 9_007_199_254_740_993.0;
let _: f128 = -9_007_199_254_740_993.0;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_192.0;
let _: f128 = -10_384_593_717_069_655_257_060_992_658_440_192.0;
// Ignored whole number float literals
let _: f32 = 1e25;
let _: f32 = 1E25;

View file

@ -1,31 +1,55 @@
#![warn(clippy::lossy_float_literal)]
#![allow(overflowing_literals, unused)]
#![feature(f128)]
#![feature(f16)]
fn main() {
// Lossy whole-number float literals
let _: f16 = 4_097.0;
let _: f16 = 4_097.;
let _: f16 = 4_097.000;
let _ = 4_097f16;
let _: f16 = -4_097.0;
let _: f32 = 16_777_217.0;
let _: f32 = 16_777_219.0;
let _: f32 = 16_777_219.;
let _: f32 = 16_777_219.000;
let _ = 16_777_219f32;
let _: f32 = -16_777_219.0;
let _: f64 = 9_007_199_254_740_993.0;
let _: f64 = 9_007_199_254_740_993.;
let _: f64 = 9_007_199_254_740_993.00;
let _ = 9_007_199_254_740_993f64;
let _: f64 = -9_007_199_254_740_993.0;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_193.0;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_193.;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_193.00;
let _ = 10_384_593_717_069_655_257_060_992_658_440_193f128;
let _: f128 = -10_384_593_717_069_655_257_060_992_658_440_193.0;
// Lossless whole number float literals
let _: f16 = 4_096.0;
let _: f16 = -4_096.0;
let _: f32 = 16_777_216.0;
let _: f32 = 16_777_218.0;
let _: f32 = 16_777_220.0;
let _: f32 = -16_777_216.0;
let _: f32 = -16_777_220.0;
let _: f64 = 16_777_217.0;
let _: f64 = -16_777_217.0;
let _: f64 = 9_007_199_254_740_992.0;
let _: f64 = -9_007_199_254_740_992.0;
let _: f128 = 9_007_199_254_740_993.0;
let _: f128 = -9_007_199_254_740_993.0;
let _: f128 = 10_384_593_717_069_655_257_060_992_658_440_192.0;
let _: f128 = -10_384_593_717_069_655_257_060_992_658_440_192.0;
// Ignored whole number float literals
let _: f32 = 1e25;
let _: f32 = 1E25;

View file

@ -1,5 +1,5 @@
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:6:18
--> tests/ui/lossy_float_literal.rs:14:18
|
LL | let _: f32 = 16_777_217.0;
| ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_216.0`
@ -8,61 +8,61 @@ LL | let _: f32 = 16_777_217.0;
= help: to override `-D warnings` add `#[allow(clippy::lossy_float_literal)]`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:7:18
--> tests/ui/lossy_float_literal.rs:15:18
|
LL | let _: f32 = 16_777_219.0;
| ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:8:18
--> tests/ui/lossy_float_literal.rs:16:18
|
LL | let _: f32 = 16_777_219.;
| ^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:9:18
--> tests/ui/lossy_float_literal.rs:17:18
|
LL | let _: f32 = 16_777_219.000;
| ^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:10:13
--> tests/ui/lossy_float_literal.rs:18:13
|
LL | let _ = 16_777_219f32;
| ^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220_f32`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:11:19
--> tests/ui/lossy_float_literal.rs:19:19
|
LL | let _: f32 = -16_777_219.0;
| ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:12:18
--> tests/ui/lossy_float_literal.rs:21:18
|
LL | let _: f64 = 9_007_199_254_740_993.0;
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:13:18
--> tests/ui/lossy_float_literal.rs:22:18
|
LL | let _: f64 = 9_007_199_254_740_993.;
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:14:18
--> tests/ui/lossy_float_literal.rs:23:18
|
LL | let _: f64 = 9_007_199_254_740_993.00;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:15:13
--> tests/ui/lossy_float_literal.rs:24:13
|
LL | let _ = 9_007_199_254_740_993f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992_f64`
error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:16:19
--> tests/ui/lossy_float_literal.rs:25:19
|
LL | let _: f64 = -9_007_199_254_740_993.0;
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0`

View file

@ -3,6 +3,8 @@
#![allow(clippy::needless_if, unused)]
#![warn(clippy::manual_is_infinite, clippy::manual_is_finite)]
// FIXME(f16_f128): add tests for these types once constants are available
#[macro_use]
extern crate proc_macros;

View file

@ -1,5 +1,5 @@
error: manually checking if a float is infinite
--> tests/ui/manual_float_methods.rs:22:8
--> tests/ui/manual_float_methods.rs:24:8
|
LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
@ -8,7 +8,7 @@ LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
= help: to override `-D warnings` add `#[allow(clippy::manual_is_infinite)]`
error: manually checking if a float is finite
--> tests/ui/manual_float_methods.rs:23:8
--> tests/ui/manual_float_methods.rs:25:8
|
LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -29,13 +29,13 @@ LL | if !x.is_infinite() {}
| ~~~~~~~~~~~~~~~~
error: manually checking if a float is infinite
--> tests/ui/manual_float_methods.rs:24:8
--> tests/ui/manual_float_methods.rs:26:8
|
LL | if x == INFINITE || x == NEG_INFINITE {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
error: manually checking if a float is finite
--> tests/ui/manual_float_methods.rs:25:8
--> tests/ui/manual_float_methods.rs:27:8
|
LL | if x != INFINITE && x != NEG_INFINITE {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -54,13 +54,13 @@ LL | if !x.is_infinite() {}
| ~~~~~~~~~~~~~~~~
error: manually checking if a float is infinite
--> tests/ui/manual_float_methods.rs:27:8
--> tests/ui/manual_float_methods.rs:29:8
|
LL | if x == f64::INFINITY || x == f64::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
error: manually checking if a float is finite
--> tests/ui/manual_float_methods.rs:28:8
--> tests/ui/manual_float_methods.rs:30:8
|
LL | if x != f64::INFINITY && x != f64::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,3 +1,5 @@
#![feature(f128)]
#![feature(f16)]
#![warn(clippy::modulo_arithmetic)]
#![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::modulo_one)]
@ -16,6 +18,19 @@ fn main() {
//~^ ERROR: you are using modulo operator on constants with different signs: `3.400 %
//~| NOTE: double check for expected result especially when interoperating with differ
// Lint on floating point numbers
let a_f16: f16 = -1.6;
let mut b_f16: f16 = 2.1;
a_f16 % b_f16;
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
b_f16 % a_f16;
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
b_f16 %= a_f16;
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
// Lint on floating point numbers
let a_f32: f32 = -1.6;
let mut b_f32: f32 = 2.1;
@ -41,6 +56,18 @@ fn main() {
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
let a_f128: f128 = -1.6;
let mut b_f128: f128 = 2.1;
a_f128 % b_f128;
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
b_f128 % a_f128;
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
b_f128 %= a_f128;
//~^ ERROR: you are using modulo operator on types that might have different signs
//~| NOTE: double check for expected result especially when interoperating with differ
// No lint when both sides are const and of the same sign
1.6 % 2.1;
-1.6 % -2.1;

View file

@ -1,5 +1,5 @@
error: you are using modulo operator on constants with different signs: `-1.600 % 2.100`
--> tests/ui/modulo_arithmetic_float.rs:6:5
--> tests/ui/modulo_arithmetic_float.rs:8:5
|
LL | -1.6 % 2.1;
| ^^^^^^^^^^
@ -9,7 +9,7 @@ LL | -1.6 % 2.1;
= help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]`
error: you are using modulo operator on constants with different signs: `1.600 % -2.100`
--> tests/ui/modulo_arithmetic_float.rs:9:5
--> tests/ui/modulo_arithmetic_float.rs:11:5
|
LL | 1.6 % -2.1;
| ^^^^^^^^^^
@ -17,7 +17,7 @@ LL | 1.6 % -2.1;
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on constants with different signs: `-1.200 % 3.400`
--> tests/ui/modulo_arithmetic_float.rs:12:5
--> tests/ui/modulo_arithmetic_float.rs:14:5
|
LL | (1.1 - 2.3) % (1.1 + 2.3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | (1.1 - 2.3) % (1.1 + 2.3);
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on constants with different signs: `3.400 % -1.200`
--> tests/ui/modulo_arithmetic_float.rs:15:5
--> tests/ui/modulo_arithmetic_float.rs:17:5
|
LL | (1.1 + 2.3) % (1.1 - 2.3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -33,7 +33,31 @@ LL | (1.1 + 2.3) % (1.1 - 2.3);
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:22:5
--> tests/ui/modulo_arithmetic_float.rs:24:5
|
LL | a_f16 % b_f16;
| ^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:27:5
|
LL | b_f16 % a_f16;
| ^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:30:5
|
LL | b_f16 %= a_f16;
| ^^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:37:5
|
LL | a_f32 % b_f32;
| ^^^^^^^^^^^^^
@ -41,7 +65,7 @@ LL | a_f32 % b_f32;
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:25:5
--> tests/ui/modulo_arithmetic_float.rs:40:5
|
LL | b_f32 % a_f32;
| ^^^^^^^^^^^^^
@ -49,7 +73,7 @@ LL | b_f32 % a_f32;
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:28:5
--> tests/ui/modulo_arithmetic_float.rs:43:5
|
LL | b_f32 %= a_f32;
| ^^^^^^^^^^^^^^
@ -57,7 +81,7 @@ LL | b_f32 %= a_f32;
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:34:5
--> tests/ui/modulo_arithmetic_float.rs:49:5
|
LL | a_f64 % b_f64;
| ^^^^^^^^^^^^^
@ -65,7 +89,7 @@ LL | a_f64 % b_f64;
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:37:5
--> tests/ui/modulo_arithmetic_float.rs:52:5
|
LL | b_f64 % a_f64;
| ^^^^^^^^^^^^^
@ -73,12 +97,36 @@ LL | b_f64 % a_f64;
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:40:5
--> tests/ui/modulo_arithmetic_float.rs:55:5
|
LL | b_f64 %= a_f64;
| ^^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: aborting due to 10 previous errors
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:61:5
|
LL | a_f128 % b_f128;
| ^^^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:64:5
|
LL | b_f128 % a_f128;
| ^^^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: you are using modulo operator on types that might have different signs
--> tests/ui/modulo_arithmetic_float.rs:67:5
|
LL | b_f128 %= a_f128;
| ^^^^^^^^^^^^^^^^
|
= note: double check for expected result especially when interoperating with different languages
error: aborting due to 16 previous errors

View file

@ -1,3 +1,5 @@
#![feature(f128)]
#![feature(f16)]
#![allow(
dead_code,
clippy::borrow_as_ptr,
@ -117,20 +119,34 @@ fn int_to_bool() {
#[warn(clippy::transmute_int_to_float)]
mod int_to_float {
fn test() {
let _: f16 = unsafe { std::mem::transmute(0_u16) };
//~^ ERROR: transmute from a `u16` to a `f16`
//~| NOTE: `-D clippy::transmute-int-to-float` implied by `-D warnings`
let _: f16 = unsafe { std::mem::transmute(0_i16) };
//~^ ERROR: transmute from a `i16` to a `f16`
let _: f32 = unsafe { std::mem::transmute(0_u32) };
//~^ ERROR: transmute from a `u32` to a `f32`
//~| NOTE: `-D clippy::transmute-int-to-float` implied by `-D warnings`
let _: f32 = unsafe { std::mem::transmute(0_i32) };
//~^ ERROR: transmute from a `i32` to a `f32`
let _: f64 = unsafe { std::mem::transmute(0_u64) };
//~^ ERROR: transmute from a `u64` to a `f64`
let _: f64 = unsafe { std::mem::transmute(0_i64) };
//~^ ERROR: transmute from a `i64` to a `f64`
let _: f128 = unsafe { std::mem::transmute(0_u128) };
//~^ ERROR: transmute from a `u128` to a `f128`
let _: f128 = unsafe { std::mem::transmute(0_i128) };
//~^ ERROR: transmute from a `i128` to a `f128`
}
mod issue_5747 {
const VALUE16: f16 = unsafe { std::mem::transmute(0_u16) };
const VALUE32: f32 = unsafe { std::mem::transmute(0_u32) };
const VALUE64: f64 = unsafe { std::mem::transmute(0_i64) };
const VALUE128: f128 = unsafe { std::mem::transmute(0_i128) };
const fn from_bits_16(v: i16) -> f16 {
unsafe { std::mem::transmute(v) }
}
const fn from_bits_32(v: i32) -> f32 {
unsafe { std::mem::transmute(v) }
@ -139,6 +155,10 @@ const fn from_bits_32(v: i32) -> f32 {
const fn from_bits_64(v: u64) -> f64 {
unsafe { std::mem::transmute(v) }
}
const fn from_bits_128(v: u128) -> f128 {
unsafe { std::mem::transmute(v) }
}
}
}
@ -158,10 +178,15 @@ fn test() {
//~^ ERROR: transmute from a `i32` to a `[u8; 4]`
let _: [u8; 16] = std::mem::transmute(0i128);
//~^ ERROR: transmute from a `i128` to a `[u8; 16]`
let _: [u8; 2] = std::mem::transmute(0.0f16);
//~^ ERROR: transmute from a `f16` to a `[u8; 2]`
let _: [u8; 4] = std::mem::transmute(0.0f32);
//~^ ERROR: transmute from a `f32` to a `[u8; 4]`
let _: [u8; 8] = std::mem::transmute(0.0f64);
//~^ ERROR: transmute from a `f64` to a `[u8; 8]`
let _: [u8; 16] = std::mem::transmute(0.0f128);
//~^ ERROR: transmute from a `f128` to a `[u8; 16]`
}
}
const fn test_const() {
@ -178,8 +203,11 @@ const fn test_const() {
//~^ ERROR: transmute from a `i32` to a `[u8; 4]`
let _: [u8; 16] = std::mem::transmute(0i128);
//~^ ERROR: transmute from a `i128` to a `[u8; 16]`
let _: [u8; 2] = std::mem::transmute(0.0f16);
let _: [u8; 4] = std::mem::transmute(0.0f32);
let _: [u8; 8] = std::mem::transmute(0.0f64);
let _: [u8; 16] = std::mem::transmute(0.0f128);
}
}
}

View file

@ -1,5 +1,5 @@
error: transmute from a reference to a pointer
--> tests/ui/transmute.rs:29:23
--> tests/ui/transmute.rs:31:23
|
LL | let _: *const T = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T`
@ -8,61 +8,61 @@ LL | let _: *const T = core::intrinsics::transmute(t);
= help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]`
error: transmute from a reference to a pointer
--> tests/ui/transmute.rs:33:21
--> tests/ui/transmute.rs:35:21
|
LL | let _: *mut T = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T`
error: transmute from a reference to a pointer
--> tests/ui/transmute.rs:36:23
--> tests/ui/transmute.rs:38:23
|
LL | let _: *const U = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U`
error: transmute from a type (`std::vec::Vec<i32>`) to itself
--> tests/ui/transmute.rs:43:27
--> tests/ui/transmute.rs:45:27
|
LL | let _: Vec<i32> = core::intrinsics::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
--> tests/ui/transmute.rs:46:27
--> tests/ui/transmute.rs:48:27
|
LL | let _: Vec<i32> = core::mem::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
--> tests/ui/transmute.rs:49:27
--> tests/ui/transmute.rs:51:27
|
LL | let _: Vec<i32> = std::intrinsics::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
--> tests/ui/transmute.rs:52:27
--> tests/ui/transmute.rs:54:27
|
LL | let _: Vec<i32> = std::mem::transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`std::vec::Vec<i32>`) to itself
--> tests/ui/transmute.rs:55:27
--> tests/ui/transmute.rs:57:27
|
LL | let _: Vec<i32> = my_transmute(my_vec());
| ^^^^^^^^^^^^^^^^^^^^^^
error: transmute from an integer to a pointer
--> tests/ui/transmute.rs:58:31
--> tests/ui/transmute.rs:60:31
|
LL | let _: *const usize = std::mem::transmute(5_isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize`
error: transmute from an integer to a pointer
--> tests/ui/transmute.rs:63:31
--> tests/ui/transmute.rs:65:31
|
LL | let _: *const usize = std::mem::transmute(1 + 1usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize`
error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`)
--> tests/ui/transmute.rs:95:24
--> tests/ui/transmute.rs:97:24
|
LL | let _: Usize = core::intrinsics::transmute(int_const_ptr);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -71,25 +71,25 @@ LL | let _: Usize = core::intrinsics::transmute(int_const_ptr);
= help: to override `-D warnings` add `#[allow(clippy::crosspointer_transmute)]`
error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`)
--> tests/ui/transmute.rs:99:24
--> tests/ui/transmute.rs:101:24
|
LL | let _: Usize = core::intrinsics::transmute(int_mut_ptr);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`)
--> tests/ui/transmute.rs:102:31
--> tests/ui/transmute.rs:104:31
|
LL | let _: *const Usize = core::intrinsics::transmute(my_int());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`)
--> tests/ui/transmute.rs:105:29
--> tests/ui/transmute.rs:107:29
|
LL | let _: *mut Usize = core::intrinsics::transmute(my_int());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: transmute from a `u8` to a `bool`
--> tests/ui/transmute.rs:112:28
--> tests/ui/transmute.rs:114:28
|
LL | let _: bool = unsafe { std::mem::transmute(0_u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0`
@ -97,35 +97,59 @@ LL | let _: bool = unsafe { std::mem::transmute(0_u8) };
= note: `-D clippy::transmute-int-to-bool` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]`
error: transmute from a `u32` to a `f32`
--> tests/ui/transmute.rs:120:31
error: transmute from a `u16` to a `f16`
--> tests/ui/transmute.rs:122:31
|
LL | let _: f32 = unsafe { std::mem::transmute(0_u32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
LL | let _: f16 = unsafe { std::mem::transmute(0_u16) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_u16)`
|
= note: `-D clippy::transmute-int-to-float` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]`
error: transmute from a `i16` to a `f16`
--> tests/ui/transmute.rs:125:31
|
LL | let _: f16 = unsafe { std::mem::transmute(0_i16) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_i16 as u16)`
error: transmute from a `u32` to a `f32`
--> tests/ui/transmute.rs:127:31
|
LL | let _: f32 = unsafe { std::mem::transmute(0_u32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
error: transmute from a `i32` to a `f32`
--> tests/ui/transmute.rs:123:31
--> tests/ui/transmute.rs:129:31
|
LL | let _: f32 = unsafe { std::mem::transmute(0_i32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)`
error: transmute from a `u64` to a `f64`
--> tests/ui/transmute.rs:125:31
--> tests/ui/transmute.rs:131:31
|
LL | let _: f64 = unsafe { std::mem::transmute(0_u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)`
error: transmute from a `i64` to a `f64`
--> tests/ui/transmute.rs:127:31
--> tests/ui/transmute.rs:133:31
|
LL | let _: f64 = unsafe { std::mem::transmute(0_i64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)`
error: transmute from a `u128` to a `f128`
--> tests/ui/transmute.rs:135:32
|
LL | let _: f128 = unsafe { std::mem::transmute(0_u128) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_u128)`
error: transmute from a `i128` to a `f128`
--> tests/ui/transmute.rs:137:32
|
LL | let _: f128 = unsafe { std::mem::transmute(0_i128) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)`
error: transmute from a `u8` to a `[u8; 1]`
--> tests/ui/transmute.rs:148:30
--> tests/ui/transmute.rs:168:30
|
LL | let _: [u8; 1] = std::mem::transmute(0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
@ -133,54 +157,6 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8);
= note: `-D clippy::transmute-num-to-bytes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]`
error: transmute from a `u32` to a `[u8; 4]`
--> tests/ui/transmute.rs:151:30
|
LL | let _: [u8; 4] = std::mem::transmute(0u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
error: transmute from a `u128` to a `[u8; 16]`
--> tests/ui/transmute.rs:153:31
|
LL | let _: [u8; 16] = std::mem::transmute(0u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
error: transmute from a `i8` to a `[u8; 1]`
--> tests/ui/transmute.rs:155:30
|
LL | let _: [u8; 1] = std::mem::transmute(0i8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
error: transmute from a `i32` to a `[u8; 4]`
--> tests/ui/transmute.rs:157:30
|
LL | let _: [u8; 4] = std::mem::transmute(0i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
error: transmute from a `i128` to a `[u8; 16]`
--> tests/ui/transmute.rs:159:31
|
LL | let _: [u8; 16] = std::mem::transmute(0i128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
error: transmute from a `f32` to a `[u8; 4]`
--> tests/ui/transmute.rs:161:30
|
LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
error: transmute from a `f64` to a `[u8; 8]`
--> tests/ui/transmute.rs:163:30
|
LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
error: transmute from a `u8` to a `[u8; 1]`
--> tests/ui/transmute.rs:169:30
|
LL | let _: [u8; 1] = std::mem::transmute(0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
error: transmute from a `u32` to a `[u8; 4]`
--> tests/ui/transmute.rs:171:30
|
@ -211,8 +187,68 @@ error: transmute from a `i128` to a `[u8; 16]`
LL | let _: [u8; 16] = std::mem::transmute(0i128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
error: transmute from a `f16` to a `[u8; 2]`
--> tests/ui/transmute.rs:182:30
|
LL | let _: [u8; 2] = std::mem::transmute(0.0f16);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()`
error: transmute from a `f32` to a `[u8; 4]`
--> tests/ui/transmute.rs:184:30
|
LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
error: transmute from a `f64` to a `[u8; 8]`
--> tests/ui/transmute.rs:186:30
|
LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
error: transmute from a `f128` to a `[u8; 16]`
--> tests/ui/transmute.rs:188:31
|
LL | let _: [u8; 16] = std::mem::transmute(0.0f128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()`
error: transmute from a `u8` to a `[u8; 1]`
--> tests/ui/transmute.rs:194:30
|
LL | let _: [u8; 1] = std::mem::transmute(0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
error: transmute from a `u32` to a `[u8; 4]`
--> tests/ui/transmute.rs:196:30
|
LL | let _: [u8; 4] = std::mem::transmute(0u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
error: transmute from a `u128` to a `[u8; 16]`
--> tests/ui/transmute.rs:198:31
|
LL | let _: [u8; 16] = std::mem::transmute(0u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
error: transmute from a `i8` to a `[u8; 1]`
--> tests/ui/transmute.rs:200:30
|
LL | let _: [u8; 1] = std::mem::transmute(0i8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
error: transmute from a `i32` to a `[u8; 4]`
--> tests/ui/transmute.rs:202:30
|
LL | let _: [u8; 4] = std::mem::transmute(0i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
error: transmute from a `i128` to a `[u8; 16]`
--> tests/ui/transmute.rs:204:31
|
LL | let _: [u8; 16] = std::mem::transmute(0i128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
error: transmute from a `&[u8]` to a `&str`
--> tests/ui/transmute.rs:190:28
--> tests/ui/transmute.rs:218:28
|
LL | let _: &str = unsafe { std::mem::transmute(B) };
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()`
@ -221,16 +257,16 @@ LL | let _: &str = unsafe { std::mem::transmute(B) };
= help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]`
error: transmute from a `&mut [u8]` to a `&mut str`
--> tests/ui/transmute.rs:193:32
--> tests/ui/transmute.rs:221:32
|
LL | let _: &mut str = unsafe { std::mem::transmute(mb) };
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()`
error: transmute from a `&[u8]` to a `&str`
--> tests/ui/transmute.rs:195:30
--> tests/ui/transmute.rs:223:30
|
LL | const _: &str = unsafe { std::mem::transmute(B) };
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)`
error: aborting due to 36 previous errors
error: aborting due to 42 previous errors

View file

@ -1,5 +1,7 @@
#![warn(clippy::transmute_float_to_int)]
#![allow(clippy::missing_transmute_annotations)]
#![feature(f128)]
#![feature(f16)]
fn float_to_int() {
let _: u32 = unsafe { 1f32.to_bits() };
@ -18,8 +20,14 @@ fn float_to_int() {
}
mod issue_5747 {
const VALUE16: i16 = unsafe { std::mem::transmute(1f16) };
const VALUE32: i32 = unsafe { std::mem::transmute(1f32) };
const VALUE64: u64 = unsafe { std::mem::transmute(1f64) };
const VALUE128: u128 = unsafe { std::mem::transmute(1f128) };
const fn to_bits_16(v: f16) -> u16 {
unsafe { std::mem::transmute(v) }
}
const fn to_bits_32(v: f32) -> u32 {
unsafe { std::mem::transmute(v) }
@ -28,6 +36,10 @@ mod issue_5747 {
const fn to_bits_64(v: f64) -> i64 {
unsafe { std::mem::transmute(v) }
}
const fn to_bits_128(v: f128) -> i128 {
unsafe { std::mem::transmute(v) }
}
}
fn main() {}

View file

@ -1,5 +1,7 @@
#![warn(clippy::transmute_float_to_int)]
#![allow(clippy::missing_transmute_annotations)]
#![feature(f128)]
#![feature(f16)]
fn float_to_int() {
let _: u32 = unsafe { std::mem::transmute(1f32) };
@ -18,8 +20,14 @@ fn float_to_int() {
}
mod issue_5747 {
const VALUE16: i16 = unsafe { std::mem::transmute(1f16) };
const VALUE32: i32 = unsafe { std::mem::transmute(1f32) };
const VALUE64: u64 = unsafe { std::mem::transmute(1f64) };
const VALUE128: u128 = unsafe { std::mem::transmute(1f128) };
const fn to_bits_16(v: f16) -> u16 {
unsafe { std::mem::transmute(v) }
}
const fn to_bits_32(v: f32) -> u32 {
unsafe { std::mem::transmute(v) }
@ -28,6 +36,10 @@ const fn to_bits_32(v: f32) -> u32 {
const fn to_bits_64(v: f64) -> i64 {
unsafe { std::mem::transmute(v) }
}
const fn to_bits_128(v: f128) -> i128 {
unsafe { std::mem::transmute(v) }
}
}
fn main() {}

View file

@ -1,5 +1,5 @@
error: transmute from a `f32` to a `u32`
--> tests/ui/transmute_float_to_int.rs:5:27
--> tests/ui/transmute_float_to_int.rs:7:27
|
LL | let _: u32 = unsafe { std::mem::transmute(1f32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits()`
@ -8,31 +8,31 @@ LL | let _: u32 = unsafe { std::mem::transmute(1f32) };
= help: to override `-D warnings` add `#[allow(clippy::transmute_float_to_int)]`
error: transmute from a `f32` to a `i32`
--> tests/ui/transmute_float_to_int.rs:8:27
--> tests/ui/transmute_float_to_int.rs:10:27
|
LL | let _: i32 = unsafe { std::mem::transmute(1f32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits() as i32`
error: transmute from a `f64` to a `u64`
--> tests/ui/transmute_float_to_int.rs:10:27
--> tests/ui/transmute_float_to_int.rs:12:27
|
LL | let _: u64 = unsafe { std::mem::transmute(1f64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits()`
error: transmute from a `f64` to a `i64`
--> tests/ui/transmute_float_to_int.rs:12:27
--> tests/ui/transmute_float_to_int.rs:14:27
|
LL | let _: i64 = unsafe { std::mem::transmute(1f64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits() as i64`
error: transmute from a `f64` to a `u64`
--> tests/ui/transmute_float_to_int.rs:14:27
--> tests/ui/transmute_float_to_int.rs:16:27
|
LL | let _: u64 = unsafe { std::mem::transmute(1.0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.0f64.to_bits()`
error: transmute from a `f64` to a `u64`
--> tests/ui/transmute_float_to_int.rs:16:27
--> tests/ui/transmute_float_to_int.rs:18:27
|
LL | let _: u64 = unsafe { std::mem::transmute(-1.0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-1.0f64).to_bits()`

View file

@ -1,3 +1,5 @@
// FIXME(f16_f128): add tests when math functions are available
#![warn(clippy::unused_rounding)]
fn main() {

View file

@ -1,3 +1,5 @@
// FIXME(f16_f128): add tests when math functions are available
#![warn(clippy::unused_rounding)]
fn main() {

View file

@ -1,5 +1,5 @@
error: used the `ceil` method with a whole number float
--> tests/ui/unused_rounding.rs:4:13
--> tests/ui/unused_rounding.rs:6:13
|
LL | let _ = 1f32.ceil();
| ^^^^^^^^^^^ help: remove the `ceil` method call: `1f32`
@ -8,25 +8,25 @@ LL | let _ = 1f32.ceil();
= help: to override `-D warnings` add `#[allow(clippy::unused_rounding)]`
error: used the `floor` method with a whole number float
--> tests/ui/unused_rounding.rs:5:13
--> tests/ui/unused_rounding.rs:7:13
|
LL | let _ = 1.0f64.floor();
| ^^^^^^^^^^^^^^ help: remove the `floor` method call: `1.0f64`
error: used the `round` method with a whole number float
--> tests/ui/unused_rounding.rs:6:13
--> tests/ui/unused_rounding.rs:8:13
|
LL | let _ = 1.00f32.round();
| ^^^^^^^^^^^^^^^ help: remove the `round` method call: `1.00f32`
error: used the `round` method with a whole number float
--> tests/ui/unused_rounding.rs:12:13
--> tests/ui/unused_rounding.rs:14:13
|
LL | let _ = 3.0_f32.round();
| ^^^^^^^^^^^^^^^ help: remove the `round` method call: `3.0_f32`
error: used the `round` method with a whole number float
--> tests/ui/unused_rounding.rs:14:13
--> tests/ui/unused_rounding.rs:16:13
|
LL | let _ = 3_3.0_0_f32.round();
| ^^^^^^^^^^^^^^^^^^^ help: remove the `round` method call: `3_3.0_0_f32`