From 8b51fcbd67ca17a6dcc2f9e5a29176f836bf11d2 Mon Sep 17 00:00:00 2001
From: Sebastian Graf <sebastian.graf@kit.edu>
Date: Wed, 29 Apr 2020 16:44:11 +0200
Subject: [PATCH] PmCheck: Only call checkSingle if we would report warnings

---
 compiler/GHC/HsToCore/Match.hs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/compiler/GHC/HsToCore/Match.hs b/compiler/GHC/HsToCore/Match.hs
index 60b694ff9d77..55f2709cf9ec 100644
--- a/compiler/GHC/HsToCore/Match.hs
+++ b/compiler/GHC/HsToCore/Match.hs
@@ -859,8 +859,10 @@ matchSinglePatVar var ctx pat ty match_result
     do { dflags <- getDynFlags
        ; locn   <- getSrcSpanDs
 
-                    -- Pattern match check warnings
-       ; checkSingle dflags (DsMatchContext ctx locn) var (unLoc pat)
+       -- Pattern match check warnings
+       ; if isMatchContextPmChecked dflags FromSource ctx
+            then checkSingle dflags (DsMatchContext ctx locn) var (unLoc pat)
+            else pure ()
 
        ; let eqn_info = EqnInfo { eqn_pats = [unLoc (decideBangHood dflags pat)]
                                 , eqn_orig = FromSource
-- 
GitLab