Skip to content

Commit b7c25e1

Browse files
committed
Auto merge of #7642 - mikerite:fix-7641, r=flip1995
Add `TAU` to `approx_constant` changelog: [`approx_constant`]: Add `TAU`
2 parents 17294b8 + a7a5a5d commit b7c25e1

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ declare_clippy_lint! {
3939
}
4040

4141
// Tuples are of the form (constant, name, min_digits, msrv)
42-
const KNOWN_CONSTS: [(f64, &str, usize, Option<RustcVersion>); 18] = [
42+
const KNOWN_CONSTS: [(f64, &str, usize, Option<RustcVersion>); 19] = [
4343
(f64::E, "E", 4, None),
4444
(f64::FRAC_1_PI, "FRAC_1_PI", 4, None),
4545
(f64::FRAC_1_SQRT_2, "FRAC_1_SQRT_2", 5, None),
@@ -58,6 +58,7 @@ const KNOWN_CONSTS: [(f64, &str, usize, Option<RustcVersion>); 18] = [
5858
(f64::LOG10_E, "LOG10_E", 5, None),
5959
(f64::PI, "PI", 3, None),
6060
(f64::SQRT_2, "SQRT_2", 5, None),
61+
(f64::TAU, "TAU", 3, Some(msrvs::TAU)),
6162
];
6263

6364
pub struct ApproxConstant {

clippy_utils/src/msrvs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ msrv_aliases! {
1515
1,53,0 { OR_PATTERNS }
1616
1,52,0 { STR_SPLIT_ONCE }
1717
1,50,0 { BOOL_THEN }
18+
1,47,0 { TAU }
1819
1,46,0 { CONST_IF_MATCH }
1920
1,45,0 { STR_STRIP_PREFIX }
2021
1,43,0 { LOG2_10, LOG10_2 }

tests/ui/approx_const.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ fn main() {
5757

5858
let my_sq2 = 1.4142;
5959
let no_sq2 = 1.414;
60+
61+
let my_tau = 6.2832;
62+
let almost_tau = 6.28;
63+
let no_tau = 6.3;
6064
}

tests/ui/approx_const.stderr

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,21 @@ LL | let my_sq2 = 1.4142;
167167
|
168168
= help: consider using the constant directly
169169

170-
error: aborting due to 21 previous errors
170+
error: approximate value of `f{32, 64}::consts::TAU` found
171+
--> $DIR/approx_const.rs:61:18
172+
|
173+
LL | let my_tau = 6.2832;
174+
| ^^^^^^
175+
|
176+
= help: consider using the constant directly
177+
178+
error: approximate value of `f{32, 64}::consts::TAU` found
179+
--> $DIR/approx_const.rs:62:22
180+
|
181+
LL | let almost_tau = 6.28;
182+
| ^^^^
183+
|
184+
= help: consider using the constant directly
185+
186+
error: aborting due to 23 previous errors
171187

0 commit comments

Comments
 (0)