Make restriction lint's use span_lint_and_then (i -> l)

This commit is contained in:
xFrednet 2024-07-21 19:26:53 +02:00
parent 7f0ed11213
commit bc8fc6b1d8
No known key found for this signature in database
GPG Key ID: F5C59D0E669E5302
7 changed files with 245 additions and 92 deletions

View File

@ -1,6 +1,6 @@
use std::fmt; use std::fmt;
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::diagnostics::span_lint_and_then;
use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions}; use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions};
use rustc_ast::{InlineAsm, Item, ItemKind}; use rustc_ast::{InlineAsm, Item, ItemKind};
use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext}; use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext};
@ -49,14 +49,10 @@ fn check_asm_syntax(
}; };
if style == check_for { if style == check_for {
span_lint_and_help( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
cx, span_lint_and_then(cx, lint, span, format!("{style} x86 assembly syntax used"), |diag| {
lint, diag.help(format!("use {} x86 assembly syntax", !style));
span, });
format!("{style} x86 assembly syntax used"),
None,
format!("use {} x86 assembly syntax", !style),
);
} }
} }
} }
@ -98,13 +94,13 @@ declare_lint_pass!(InlineAsmX86IntelSyntax => [INLINE_ASM_X86_INTEL_SYNTAX]);
impl EarlyLintPass for InlineAsmX86IntelSyntax { impl EarlyLintPass for InlineAsmX86IntelSyntax {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if let ExprKind::InlineAsm(inline_asm) = &expr.kind { if let ExprKind::InlineAsm(inline_asm) = &expr.kind {
check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Intel); check_asm_syntax(INLINE_ASM_X86_INTEL_SYNTAX, cx, inline_asm, expr.span, AsmStyle::Intel);
} }
} }
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if let ItemKind::GlobalAsm(inline_asm) = &item.kind { if let ItemKind::GlobalAsm(inline_asm) = &item.kind {
check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Intel); check_asm_syntax(INLINE_ASM_X86_INTEL_SYNTAX, cx, inline_asm, item.span, AsmStyle::Intel);
} }
} }
} }
@ -146,13 +142,13 @@ declare_lint_pass!(InlineAsmX86AttSyntax => [INLINE_ASM_X86_ATT_SYNTAX]);
impl EarlyLintPass for InlineAsmX86AttSyntax { impl EarlyLintPass for InlineAsmX86AttSyntax {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if let ExprKind::InlineAsm(inline_asm) = &expr.kind { if let ExprKind::InlineAsm(inline_asm) = &expr.kind {
check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Att); check_asm_syntax(INLINE_ASM_X86_ATT_SYNTAX, cx, inline_asm, expr.span, AsmStyle::Att);
} }
} }
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if let ItemKind::GlobalAsm(inline_asm) = &item.kind { if let ItemKind::GlobalAsm(inline_asm) = &item.kind {
check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Att); check_asm_syntax(INLINE_ASM_X86_ATT_SYNTAX, cx, inline_asm, item.span, AsmStyle::Att);
} }
} }
} }

View File

@ -1,7 +1,7 @@
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::numeric_literal; use clippy_utils::numeric_literal;
use rustc_ast::ast::{self, LitFloatType, LitKind}; use rustc_ast::ast::{self, LitFloatType, LitKind};
use rustc_errors::Applicability; use rustc_errors::{Applicability, SuggestionStyle};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, FloatTy}; use rustc_middle::ty::{self, FloatTy};
@ -109,29 +109,41 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
// If the type suffix is missing the suggestion would be // If the type suffix is missing the suggestion would be
// incorrectly interpreted as an integer so adding a `.0` // incorrectly interpreted as an integer so adding a `.0`
// suffix to prevent that. // suffix to prevent that.
if type_suffix.is_none() {
float_str.push_str(".0"); span_lint_and_then(
}
span_lint_and_sugg(
cx, cx,
LOSSY_FLOAT_LITERAL, LOSSY_FLOAT_LITERAL,
expr.span, expr.span,
"literal cannot be represented as the underlying type without loss of precision", "literal cannot be represented as the underlying type without loss of precision",
"consider changing the type or replacing it with", |diag| {
numeric_literal::format(&float_str, type_suffix, true), if type_suffix.is_none() {
Applicability::MachineApplicable, float_str.push_str(".0");
}
diag.span_suggestion_with_style(
expr.span,
"consider changing the type or replacing it with",
numeric_literal::format(&float_str, type_suffix, true),
Applicability::MachineApplicable,
SuggestionStyle::ShowAlways,
);
},
); );
} }
} else if digits > max as usize && float_str.len() < sym_str.len() { } else if digits > max as usize && float_str.len() < sym_str.len() {
span_lint_and_sugg( span_lint_and_then(
cx, cx,
EXCESSIVE_PRECISION, EXCESSIVE_PRECISION,
expr.span, expr.span,
"float has excessive precision", "float has excessive precision",
"consider changing the type or truncating it to", |diag| {
numeric_literal::format(&float_str, type_suffix, true), diag.span_suggestion_with_style(
Applicability::MachineApplicable, expr.span,
"consider changing the type or truncating it to",
numeric_literal::format(&float_str, type_suffix, true),
Applicability::MachineApplicable,
SuggestionStyle::ShowAlways,
);
},
); );
} }
} }

View File

@ -1,5 +1,5 @@
use clippy_config::Conf; use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::macros::root_macro_call_first_node;
use rustc_ast::LitKind; use rustc_ast::LitKind;
use rustc_hir::{Expr, ExprKind}; use rustc_hir::{Expr, ExprKind};
@ -66,16 +66,18 @@ impl LateLintPass<'_> for LargeIncludeFile {
&& (cx.tcx.is_diagnostic_item(sym::include_bytes_macro, macro_call.def_id) && (cx.tcx.is_diagnostic_item(sym::include_bytes_macro, macro_call.def_id)
|| cx.tcx.is_diagnostic_item(sym::include_str_macro, macro_call.def_id)) || cx.tcx.is_diagnostic_item(sym::include_str_macro, macro_call.def_id))
{ {
span_lint_and_note( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(
cx, cx,
LARGE_INCLUDE_FILE, LARGE_INCLUDE_FILE,
expr.span.source_callsite(), expr.span.source_callsite(),
"attempted to include a large file", "attempted to include a large file",
None, |diag| {
format!( diag.note(format!(
"the configuration allows a maximum size of {} bytes", "the configuration allows a maximum size of {} bytes",
self.max_file_size self.max_file_size
), ));
},
); );
} }
} }

View File

@ -1,4 +1,4 @@
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::ty::{implements_trait, is_must_use_ty, match_type}; use clippy_utils::ty::{implements_trait, is_must_use_ty, match_type};
use clippy_utils::{is_from_proc_macro, is_must_use_func_call, paths}; use clippy_utils::{is_from_proc_macro, is_must_use_func_call, paths};
use rustc_hir::{LetStmt, LocalSource, PatKind}; use rustc_hir::{LetStmt, LocalSource, PatKind};
@ -149,43 +149,53 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false, GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
}); });
if contains_sync_guard { if contains_sync_guard {
span_lint_and_help( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(
cx, cx,
LET_UNDERSCORE_LOCK, LET_UNDERSCORE_LOCK,
local.span, local.span,
"non-binding `let` on a synchronization lock", "non-binding `let` on a synchronization lock",
None, |diag| {
"consider using an underscore-prefixed named \ diag.help(
binding or dropping explicitly with `std::mem::drop`", "consider using an underscore-prefixed named \
binding or dropping explicitly with `std::mem::drop`",
);
},
); );
} else if let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait() } else if let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait()
&& implements_trait(cx, cx.typeck_results().expr_ty(init), future_trait_def_id, &[]) && implements_trait(cx, cx.typeck_results().expr_ty(init), future_trait_def_id, &[])
{ {
span_lint_and_help( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(
cx, cx,
LET_UNDERSCORE_FUTURE, LET_UNDERSCORE_FUTURE,
local.span, local.span,
"non-binding `let` on a future", "non-binding `let` on a future",
None, |diag| {
"consider awaiting the future or dropping explicitly with `std::mem::drop`", diag.help("consider awaiting the future or dropping explicitly with `std::mem::drop`");
},
); );
} else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) { } else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) {
span_lint_and_help( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(
cx, cx,
LET_UNDERSCORE_MUST_USE, LET_UNDERSCORE_MUST_USE,
local.span, local.span,
"non-binding `let` on an expression with `#[must_use]` type", "non-binding `let` on an expression with `#[must_use]` type",
None, |diag| {
"consider explicitly using expression value", diag.help("consider explicitly using expression value");
},
); );
} else if is_must_use_func_call(cx, init) { } else if is_must_use_func_call(cx, init) {
span_lint_and_help( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(
cx, cx,
LET_UNDERSCORE_MUST_USE, LET_UNDERSCORE_MUST_USE,
local.span, local.span,
"non-binding `let` on a result of a `#[must_use]` function", "non-binding `let` on a result of a `#[must_use]` function",
None, |diag| {
"consider explicitly using function result", diag.help("consider explicitly using function result");
},
); );
} }
@ -204,18 +214,22 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
return; return;
} }
span_lint_and_help( span_lint_and_then(
cx, cx,
LET_UNDERSCORE_UNTYPED, LET_UNDERSCORE_UNTYPED,
local.span, local.span,
"non-binding `let` without a type annotation", "non-binding `let` without a type annotation",
Some(Span::new( |diag| {
local.pat.span.hi(), diag.span_help(
local.pat.span.hi() + BytePos(1), Span::new(
local.pat.span.ctxt(), local.pat.span.hi(),
local.pat.span.parent(), local.pat.span.hi() + BytePos(1),
)), local.pat.span.ctxt(),
"consider adding a type annotation", local.pat.span.parent(),
),
"consider adding a type annotation",
);
},
); );
} }
} }

View File

@ -1,4 +1,4 @@
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::diagnostics::span_lint_and_then;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_lint::LateContext; use rustc_lint::LateContext;
@ -15,13 +15,9 @@ pub(crate) fn check<'tcx>(
&& cx.typeck_results().expr_ty(left).is_integral() && cx.typeck_results().expr_ty(left).is_integral()
&& cx.typeck_results().expr_ty(right).is_integral() && cx.typeck_results().expr_ty(right).is_integral()
{ {
span_lint_and_help( #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
cx, span_lint_and_then(cx, INTEGER_DIVISION, expr.span, "integer division", |diag| {
INTEGER_DIVISION, diag.help("division of integers may cause loss of precision. consider using floats");
expr.span, });
"integer division",
None,
"division of integers may cause loss of precision. consider using floats",
);
} }
} }

View File

@ -2,100 +2,179 @@ error: float has excessive precision
--> tests/ui/excessive_precision.rs:20:26 --> tests/ui/excessive_precision.rs:20:26
| |
LL | const BAD32_1: f32 = 0.123_456_789_f32; LL | const BAD32_1: f32 = 0.123_456_789_f32;
| ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79_f32` | ^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::excessive-precision` implied by `-D warnings` = note: `-D clippy::excessive-precision` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::excessive_precision)]` = help: to override `-D warnings` add `#[allow(clippy::excessive_precision)]`
help: consider changing the type or truncating it to
|
LL | const BAD32_1: f32 = 0.123_456_79_f32;
| ~~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:21:26 --> tests/ui/excessive_precision.rs:21:26
| |
LL | const BAD32_2: f32 = 0.123_456_789; LL | const BAD32_2: f32 = 0.123_456_789;
| ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` | ^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | const BAD32_2: f32 = 0.123_456_79;
| ~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:22:26 --> tests/ui/excessive_precision.rs:22:26
| |
LL | const BAD32_3: f32 = 0.100_000_000_000_1; LL | const BAD32_3: f32 = 0.100_000_000_000_1;
| ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` | ^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | const BAD32_3: f32 = 0.1;
| ~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:23:29 --> tests/ui/excessive_precision.rs:23:29
| |
LL | const BAD32_EDGE: f32 = 1.000_000_9; LL | const BAD32_EDGE: f32 = 1.000_000_9;
| ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` | ^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | const BAD32_EDGE: f32 = 1.000_001;
| ~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:27:26 --> tests/ui/excessive_precision.rs:27:26
| |
LL | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; LL | const BAD64_3: f64 = 0.100_000_000_000_000_000_1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | const BAD64_3: f64 = 0.1;
| ~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:30:22 --> tests/ui/excessive_precision.rs:30:22
| |
LL | println!("{:?}", 8.888_888_888_888_888_888_888); LL | println!("{:?}", 8.888_888_888_888_888_888_888);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | println!("{:?}", 8.888_888_888_888_89);
| ~~~~~~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:41:22 --> tests/ui/excessive_precision.rs:41:22
| |
LL | let bad32: f32 = 1.123_456_789; LL | let bad32: f32 = 1.123_456_789;
| ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` | ^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad32: f32 = 1.123_456_8;
| ~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:42:26 --> tests/ui/excessive_precision.rs:42:26
| |
LL | let bad32_suf: f32 = 1.123_456_789_f32; LL | let bad32_suf: f32 = 1.123_456_789_f32;
| ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` | ^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad32_suf: f32 = 1.123_456_8_f32;
| ~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:43:21 --> tests/ui/excessive_precision.rs:43:21
| |
LL | let bad32_inf = 1.123_456_789_f32; LL | let bad32_inf = 1.123_456_789_f32;
| ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` | ^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad32_inf = 1.123_456_8_f32;
| ~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:53:36 --> tests/ui/excessive_precision.rs:53:36
| |
LL | let bad_vec32: Vec<f32> = vec![0.123_456_789]; LL | let bad_vec32: Vec<f32> = vec![0.123_456_789];
| ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` | ^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad_vec32: Vec<f32> = vec![0.123_456_79];
| ~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:54:36 --> tests/ui/excessive_precision.rs:54:36
| |
LL | let bad_vec64: Vec<f64> = vec![0.123_456_789_123_456_789]; LL | let bad_vec64: Vec<f64> = vec![0.123_456_789_123_456_789];
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` | ^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad_vec64: Vec<f64> = vec![0.123_456_789_123_456_78];
| ~~~~~~~~~~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:58:24 --> tests/ui/excessive_precision.rs:58:24
| |
LL | let bad_e32: f32 = 1.123_456_788_888e-10; LL | let bad_e32: f32 = 1.123_456_788_888e-10;
| ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` | ^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad_e32: f32 = 1.123_456_8e-10;
| ~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:61:27 --> tests/ui/excessive_precision.rs:61:27
| |
LL | let bad_bige32: f32 = 1.123_456_788_888E-10; LL | let bad_bige32: f32 = 1.123_456_788_888E-10;
| ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` | ^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let bad_bige32: f32 = 1.123_456_8E-10;
| ~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:70:13 --> tests/ui/excessive_precision.rs:70:13
| |
LL | let _ = 2.225_073_858_507_201_1e-308_f64; LL | let _ = 2.225_073_858_507_201_1e-308_f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-308_f64` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let _ = 2.225_073_858_507_201e-308_f64;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:73:13 --> tests/ui/excessive_precision.rs:73:13
| |
LL | let _ = 1.000_000_000_000_001e-324_f64; LL | let _ = 1.000_000_000_000_001e-324_f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0_f64` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | let _ = 0_f64;
| ~~~~~
error: float has excessive precision error: float has excessive precision
--> tests/ui/excessive_precision.rs:83:20 --> tests/ui/excessive_precision.rs:83:20
| |
LL | const _: f64 = 3.0000000000000000e+00; LL | const _: f64 = 3.0000000000000000e+00;
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `3.0` | ^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or truncating it to
|
LL | const _: f64 = 3.0;
| ~~~
error: aborting due to 16 previous errors error: aborting due to 16 previous errors

View File

@ -2,70 +2,124 @@ error: literal cannot be represented as the underlying type without loss of prec
--> tests/ui/lossy_float_literal.rs:14:18 --> tests/ui/lossy_float_literal.rs:14:18
| |
LL | let _: f32 = 16_777_217.0; LL | let _: f32 = 16_777_217.0;
| ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_216.0` | ^^^^^^^^^^^^
| |
= note: `-D clippy::lossy-float-literal` implied by `-D warnings` = note: `-D clippy::lossy-float-literal` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::lossy_float_literal)]` = help: to override `-D warnings` add `#[allow(clippy::lossy_float_literal)]`
help: consider changing the type or replacing it with
|
LL | let _: f32 = 16_777_216.0;
| ~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:15:18 --> tests/ui/lossy_float_literal.rs:15:18
| |
LL | let _: f32 = 16_777_219.0; LL | let _: f32 = 16_777_219.0;
| ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` | ^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f32 = 16_777_220.0;
| ~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:16:18 --> tests/ui/lossy_float_literal.rs:16:18
| |
LL | let _: f32 = 16_777_219.; LL | let _: f32 = 16_777_219.;
| ^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` | ^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f32 = 16_777_220.0;
| ~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:17:18 --> tests/ui/lossy_float_literal.rs:17:18
| |
LL | let _: f32 = 16_777_219.000; LL | let _: f32 = 16_777_219.000;
| ^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` | ^^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f32 = 16_777_220.0;
| ~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:18:13 --> tests/ui/lossy_float_literal.rs:18:13
| |
LL | let _ = 16_777_219f32; LL | let _ = 16_777_219f32;
| ^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220_f32` | ^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _ = 16_777_220_f32;
| ~~~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:19:19 --> tests/ui/lossy_float_literal.rs:19:19
| |
LL | let _: f32 = -16_777_219.0; LL | let _: f32 = -16_777_219.0;
| ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` | ^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f32 = -16_777_220.0;
| ~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:21:18 --> tests/ui/lossy_float_literal.rs:21:18
| |
LL | let _: f64 = 9_007_199_254_740_993.0; 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` | ^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f64 = 9_007_199_254_740_992.0;
| ~~~~~~~~~~~~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:22:18 --> tests/ui/lossy_float_literal.rs:22:18
| |
LL | let _: f64 = 9_007_199_254_740_993.; 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` | ^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f64 = 9_007_199_254_740_992.0;
| ~~~~~~~~~~~~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:23:18 --> tests/ui/lossy_float_literal.rs:23:18
| |
LL | let _: f64 = 9_007_199_254_740_993.00; 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` | ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f64 = 9_007_199_254_740_992.0;
| ~~~~~~~~~~~~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:24:13 --> tests/ui/lossy_float_literal.rs:24:13
| |
LL | let _ = 9_007_199_254_740_993f64; LL | let _ = 9_007_199_254_740_993f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992_f64` | ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _ = 9_007_199_254_740_992_f64;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
error: literal cannot be represented as the underlying type without loss of precision error: literal cannot be represented as the underlying type without loss of precision
--> tests/ui/lossy_float_literal.rs:25:19 --> tests/ui/lossy_float_literal.rs:25:19
| |
LL | let _: f64 = -9_007_199_254_740_993.0; 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` | ^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the type or replacing it with
|
LL | let _: f64 = -9_007_199_254_740_992.0;
| ~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 11 previous errors error: aborting due to 11 previous errors