Skip to content

Commit 4e0fcf6

Browse files
committed
Addressed comments
1 parent 201f1d6 commit 4e0fcf6

File tree

9 files changed

+36
-9
lines changed

9 files changed

+36
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6712,7 +6712,7 @@ Released 2018-09-13
67126712
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
67136713
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
67146714
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
6715-
[`const-literal-precision-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#const-literal-precision-threshold
6715+
[`const-literal-digits-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#const-literal-digits-threshold
67166716
[`disallowed-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-macros
67176717
[`disallowed-methods`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-methods
67186718
[`disallowed-names`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-names

book/src/lint_configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ The maximum cognitive complexity a function can have
485485
* [`cognitive_complexity`](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity)
486486

487487

488-
## `const-literal-precision-threshold`
488+
## `const-literal-digits-threshold`
489489
The minimum digits a const float literal must have to supress the `excessive_precicion` lint
490490

491491
**Default Value:** `40`

clippy_config/src/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ define_Conf! {
572572
cognitive_complexity_threshold: u64 = 25,
573573
/// The minimum digits a const float literal must have to supress the `excessive_precicion` lint
574574
#[lints(excessive_precision)]
575-
const_literal_precision_threshold: usize = 40,
575+
const_literal_digits_threshold: usize = 40,
576576
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
577577
///
578578
/// Use the Cognitive Complexity lint instead.

clippy_lints/src/float_literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl_lint_pass!(FloatLiteral => [
7272
impl FloatLiteral {
7373
pub fn new(conf: &'static Conf) -> Self {
7474
Self {
75-
const_literal_precision_threshold: conf.const_literal_precision_threshold,
75+
const_literal_precision_threshold: conf.const_literal_digits_threshold,
7676
}
7777
}
7878
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const-literal-precision-threshold = 20
1+
const-literal-digits-threshold = 20

tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect
3535
check-inconsistent-struct-field-initializers
3636
check-private-items
3737
cognitive-complexity-threshold
38-
const-literal-precision-threshold
38+
const-literal-digits-threshold
3939
disallowed-macros
4040
disallowed-methods
4141
disallowed-names
@@ -130,7 +130,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
130130
check-inconsistent-struct-field-initializers
131131
check-private-items
132132
cognitive-complexity-threshold
133-
const-literal-precision-threshold
133+
const-literal-digits-threshold
134134
disallowed-macros
135135
disallowed-methods
136136
disallowed-names
@@ -225,7 +225,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni
225225
check-inconsistent-struct-field-initializers
226226
check-private-items
227227
cognitive-complexity-threshold
228-
const-literal-precision-threshold
228+
const-literal-digits-threshold
229229
disallowed-macros
230230
disallowed-methods
231231
disallowed-names

tests/ui/excessive_precision.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ fn main() {
115115

116116
static mut STATIC_MUT1: f32 = 1.01234567890123456789012345678901234567890;
117117
static mut STATIC_MUT2: f64 = 1.01234567890123456789012345678901234567890;
118+
119+
// From issue #13855
120+
let gamma = 0.577_215_664_901_532_9;
121+
//~^ excessive_precision
122+
const GAMMA: f64 = 0.5772156649015328606065120900824024310421;
118123
}
119124

120125
trait ExcessivelyPreciseTrait {

tests/ui/excessive_precision.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ fn main() {
115115

116116
static mut STATIC_MUT1: f32 = 1.01234567890123456789012345678901234567890;
117117
static mut STATIC_MUT2: f64 = 1.01234567890123456789012345678901234567890;
118+
119+
// From issue #13855
120+
let gamma = 0.5772156649015328606065120900824024310421;
121+
//~^ excessive_precision
122+
const GAMMA: f64 = 0.5772156649015328606065120900824024310421;
118123
}
119124

120125
trait ExcessivelyPreciseTrait {

tests/ui/excessive_precision.stderr

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,22 @@ LL - let _: f64 = 1.01234567890123456789012345678901234567890;
226226
LL + let _: f64 = 1.012_345_678_901_234_6;
227227
|
228228

229-
error: aborting due to 18 previous errors
229+
error: float has excessive precision
230+
--> tests/ui/excessive_precision.rs:120:17
231+
|
232+
LL | let gamma = 0.5772156649015328606065120900824024310421;
233+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
234+
|
235+
note: consider making it a `const` item
236+
--> tests/ui/excessive_precision.rs:120:5
237+
|
238+
LL | let gamma = 0.5772156649015328606065120900824024310421;
239+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
240+
help: consider changing the type or truncating it to
241+
|
242+
LL - let gamma = 0.5772156649015328606065120900824024310421;
243+
LL + let gamma = 0.577_215_664_901_532_9;
244+
|
245+
246+
error: aborting due to 19 previous errors
230247

0 commit comments

Comments
 (0)