Skip to content

Commit d13ce19

Browse files
authoredFeb 5, 2024
Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillot
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing rust-lang/rfcs#3535. Closes #41620 by removing the lint. rust-lang/reference#1456 updates the reference to match.
2 parents 7836678 + 1d94cc3 commit d13ce19

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed
 

Diff for: ‎tests/ui/expect_tool_lint_rfc_2383.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ mod rustc_ok {
2020
pub fn rustc_lints() {
2121
let x = 42.0;
2222

23-
#[expect(illegal_floating_point_literal_pattern)]
24-
match x {
25-
5.0 => {}
26-
6.0 => {}
27-
_ => {}
28-
}
23+
#[expect(invalid_nan_comparisons)]
24+
let _b = x == f32::NAN;
2925
}
3026
}
3127

@@ -38,13 +34,9 @@ mod rustc_warn {
3834
pub fn rustc_lints() {
3935
let x = 42;
4036

41-
#[expect(illegal_floating_point_literal_pattern)]
37+
#[expect(invalid_nan_comparisons)]
4238
//~^ ERROR: this lint expectation is unfulfilled
43-
match x {
44-
5 => {}
45-
6 => {}
46-
_ => {}
47-
}
39+
let _b = x == 5;
4840
}
4941
}
5042

Diff for: ‎tests/ui/expect_tool_lint_rfc_2383.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this lint expectation is unfulfilled
2-
--> $DIR/expect_tool_lint_rfc_2383.rs:35:14
2+
--> $DIR/expect_tool_lint_rfc_2383.rs:31:14
33
|
44
LL | #[expect(dead_code)]
55
| ^^^^^^^^^
@@ -8,31 +8,31 @@ LL | #[expect(dead_code)]
88
= help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]`
99

1010
error: this lint expectation is unfulfilled
11-
--> $DIR/expect_tool_lint_rfc_2383.rs:41:18
11+
--> $DIR/expect_tool_lint_rfc_2383.rs:37:18
1212
|
13-
LL | #[expect(illegal_floating_point_literal_pattern)]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
LL | #[expect(invalid_nan_comparisons)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^
1515

1616
error: this lint expectation is unfulfilled
17-
--> $DIR/expect_tool_lint_rfc_2383.rs:116:14
17+
--> $DIR/expect_tool_lint_rfc_2383.rs:108:14
1818
|
1919
LL | #[expect(clippy::almost_swapped)]
2020
| ^^^^^^^^^^^^^^^^^^^^^^
2121

2222
error: this lint expectation is unfulfilled
23-
--> $DIR/expect_tool_lint_rfc_2383.rs:124:14
23+
--> $DIR/expect_tool_lint_rfc_2383.rs:116:14
2424
|
2525
LL | #[expect(clippy::bytes_nth)]
2626
| ^^^^^^^^^^^^^^^^^
2727

2828
error: this lint expectation is unfulfilled
29-
--> $DIR/expect_tool_lint_rfc_2383.rs:130:14
29+
--> $DIR/expect_tool_lint_rfc_2383.rs:122:14
3030
|
3131
LL | #[expect(clippy::if_same_then_else)]
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3333

3434
error: this lint expectation is unfulfilled
35-
--> $DIR/expect_tool_lint_rfc_2383.rs:136:14
35+
--> $DIR/expect_tool_lint_rfc_2383.rs:128:14
3636
|
3737
LL | #[expect(clippy::overly_complex_bool_expr)]
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)