Auto merge of #13144 - xFrednet:07797-restriction-and-then-what, r=y21
Make restriction lint's use `span_lint_and_then` (i -> p) This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by https://github.com/rust-lang/rust-clippy/issues/7797. I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways` --- cc: https://github.com/rust-lang/rust-clippy/issues/7797 brother PR of: https://github.com/rust-lang/rust-clippy/pull/13136 changelog: none
This commit is contained in:
commit
345c94c98f
20 changed files with 409 additions and 226 deletions
|
|
@ -2,100 +2,179 @@ error: float has excessive precision
|
|||
--> tests/ui/excessive_precision.rs:20:26
|
||||
|
|
||||
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`
|
||||
= 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
|
||||
--> tests/ui/excessive_precision.rs:21:26
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:22:26
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:23:29
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:27:26
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:30:22
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:41:22
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:42:26
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:43:21
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:53:36
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:54:36
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:58:24
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:61:27
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:70:13
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:73:13
|
||||
|
|
||||
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
|
||||
--> tests/ui/excessive_precision.rs:83:20
|
||||
|
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
||||
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`
|
||||
= 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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
--> 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`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -2,22 +2,27 @@ error: unnecessary `pub(self)`
|
|||
--> tests/ui/needless_pub_self.rs:13:1
|
||||
|
|
||||
LL | pub(self) fn a() {}
|
||||
| ^^^^^^^^^ help: remove it
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::needless-pub-self` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::needless_pub_self)]`
|
||||
= help: remove it
|
||||
|
||||
error: unnecessary `pub(in self)`
|
||||
--> tests/ui/needless_pub_self.rs:14:1
|
||||
|
|
||||
LL | pub(in self) fn b() {}
|
||||
| ^^^^^^^^^^^^ help: remove it
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= help: remove it
|
||||
|
||||
error: unnecessary `pub(self)`
|
||||
--> tests/ui/needless_pub_self.rs:20:5
|
||||
|
|
||||
LL | pub(self) fn f() {}
|
||||
| ^^^^^^^^^ help: remove it
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: remove it
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue