about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-07-05 17:56:43 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-07-05 18:10:34 +0200
commitd019c71df9c88c7ee19065cb6699008e55d51610 (patch)
tree29dc4cbb4ea149572dd2e9f0d9221596c53324e4 /compiler
parent5249414809d40fe22eca0c36105a2f71b9006e04 (diff)
downloadrust-d019c71df9c88c7ee19065cb6699008e55d51610.tar.gz
rust-d019c71df9c88c7ee19065cb6699008e55d51610.zip
Fix double warning about illegal floating-point literal pattern
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
index 369fff00456..cb9c89324d6 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
@@ -272,12 +272,14 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
 
         let kind = match cv.ty.kind() {
             ty::Float(_) => {
-                tcx.struct_span_lint_hir(
-                    lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
-                    id,
-                    span,
-                    |lint| lint.build("floating-point types cannot be used in patterns").emit(),
-                );
+                if self.include_lint_checks {
+                    tcx.struct_span_lint_hir(
+                        lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
+                        id,
+                        span,
+                        |lint| lint.build("floating-point types cannot be used in patterns").emit(),
+                    );
+                }
                 PatKind::Constant { value: cv }
             }
             ty::Adt(adt_def, _) if adt_def.is_union() => {