document the new behavior and add test for float in struct

This commit is contained in:
y21 2023-08-08 17:52:17 +02:00
parent f959ccc09b
commit b6156502af
4 changed files with 25 additions and 8 deletions

View file

@ -161,6 +161,11 @@ fn emit_redundant_guards<'tcx>(
}
/// Checks if the given `Expr` can also be represented as a `Pat`.
///
/// All literals generally also work as patterns, however float literals are special.
/// They are currently (as of 2023/08/08) still allowed in patterns, but that will become
/// an error in the future, and rustc already actively warns against this (see rust#41620),
/// so we don't consider those as usable within patterns for linting purposes.
fn expr_can_be_pat(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
for_each_expr(expr, |expr| {
if match expr.kind {