summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs/Extension.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-11-26 20:28:07 +0100
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-11-27 02:44:36 +0100
commit77c50a2b21fae8739d419ca2af0d493692ed25e9 (patch)
tree84ade22de9afb8daefb8a3c2ab15f3d1194c0dca /compiler/GHC/Hs/Extension.hs
parente2c48b98c6a201eae09b4c84e73bb77608d03ec8 (diff)
downloadhaskell-wip/ttg-void.tar.gz
TTG: replace Void/NoExtCon with DataConCantHappenwip/ttg-void
There were two ways to indicate that a TTG constructor is unused in a phase: `NoExtCon` and `Void`. This unifies the code, and uses the name 'DataConCantHappen', following the discussion at MR 7041. Updates haddock submodule
Diffstat (limited to 'compiler/GHC/Hs/Extension.hs')
-rw-r--r--compiler/GHC/Hs/Extension.hs24
1 files changed, 9 insertions, 15 deletions
diff --git a/compiler/GHC/Hs/Extension.hs b/compiler/GHC/Hs/Extension.hs
index ce28e0355d..d58bd9efbc 100644
--- a/compiler/GHC/Hs/Extension.hs
+++ b/compiler/GHC/Hs/Extension.hs
@@ -32,8 +32,6 @@ import GHC.Types.SrcLoc (GenLocated(..), unLoc)
import GHC.Utils.Panic
import GHC.Parser.Annotation
-import Data.Void
-
{-
Note [IsPass]
~~~~~~~~~~~~~
@@ -115,12 +113,12 @@ instance MapXRec (GhcPass p) where
-- wrapXRec = noLocA
{-
-Note [NoExtCon and strict fields]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Note [DataConCantHappen and strict fields]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Currently, any unused TTG extension constructor will generally look like the
following:
- type instance XXHsDecl (GhcPass _) = NoExtCon
+ type instance XXHsDecl (GhcPass _) = DataConCantHappen
data HsDecl p
= ...
| XHsDecl !(XXHsDecl p)
@@ -132,17 +130,17 @@ the following function which consumes an HsDecl:
ex :: HsDecl GhcPs -> HsDecl GhcRn
...
- ex (XHsDecl nec) = noExtCon nec
+ ex (XHsDecl nec) = dataConCantHappen nec
Because `p` equals GhcPs (i.e., GhcPass 'Parsed), XHsDecl's field has the type
-NoExtCon. But since (1) the field is strict and (2) NoExtCon is an empty data
-type, there is no possible way to reach the right-hand side of the XHsDecl
-case. As a result, the coverage checker concludes that the XHsDecl case is
-inaccessible, so it can be removed.
+DataConCantHappen. But since (1) the field is strict and (2) DataConCantHappen
+is an empty data type, there is no possible way to reach the right-hand side
+of the XHsDecl case. As a result, the coverage checker concludes that
+the XHsDecl case is inaccessible, so it can be removed.
(See Note [Strict argument type constraints] in GHC.HsToCore.Pmc.Solver for
more on how this works.)
-Bottom line: if you add a TTG extension constructor that uses NoExtCon, make
+Bottom line: if you add a TTG extension constructor that uses DataConCantHappen, make
sure that any uses of it as a field are strict.
-}
@@ -219,10 +217,6 @@ type OutputableBndrId pass =
, IsPass pass
)
--- | See Note [Constructor cannot occur]
-dataConCantHappen :: Void -> a
-dataConCantHappen = absurd
-
-- useful helper functions:
pprIfPs :: forall p. IsPass p => (p ~ 'Parsed => SDoc) -> SDoc
pprIfPs pp = case ghcPass @p of GhcPs -> pp