summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-11-21 18:50:40 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-25 01:05:46 -0500
commite33412d078c544b19b88cd19bfb3b13a71099378 (patch)
treed9f549f41f93d58fd30768ce4b884aa50495d7a7 /compiler/GHC
parent7c65687e5b14eb2f496c25198ddf761546bc4675 (diff)
downloadhaskell-e33412d078c544b19b88cd19bfb3b13a71099378.tar.gz
Misc cleanup
* Remove `getTag_RDR` (unused), `tidyKind` and `tidyOpenKind` (already available as `tidyType` and `tidyOpenType`) * Remove Note [Explicit Case Statement for Specificity]. Since 0a709dd9876e40 we require GHC 8.10 for bootstrapping. * Change the warning to `cmpAltCon` to a panic. This shouldn't happen. If it ever does, the code was wrong anyway: it shouldn't always return `LT`, but rather `LT` in one case and `GT` in the other case. * Rename `verifyLinearConstructors` to `verifyLinearFields` * Fix `Note [Local record selectors]` which was not referenced * Remove vestiges of `type +v` * Minor fixes to StaticPointers documentation, part of #15603
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Builtin/Names.hs3
-rw-r--r--compiler/GHC/Core.hs5
-rw-r--r--compiler/GHC/Core/TyCo/Rep.hs6
-rw-r--r--compiler/GHC/Core/TyCo/Tidy.hs9
-rw-r--r--compiler/GHC/Core/TyCon.hs6
-rw-r--r--compiler/GHC/Core/Type.hs18
-rw-r--r--compiler/GHC/HsToCore/Quote.hs8
-rw-r--r--compiler/GHC/Iface/Type.hs6
-rw-r--r--compiler/GHC/Tc/Errors/Hole.hs6
-rw-r--r--compiler/GHC/Tc/Gen/Head.hs8
-rw-r--r--compiler/GHC/Tc/Module.hs2
-rw-r--r--compiler/GHC/Tc/Validity.hs4
12 files changed, 23 insertions, 58 deletions
diff --git a/compiler/GHC/Builtin/Names.hs b/compiler/GHC/Builtin/Names.hs
index a1cb4fbcb5..89dbfa5f30 100644
--- a/compiler/GHC/Builtin/Names.hs
+++ b/compiler/GHC/Builtin/Names.hs
@@ -767,12 +767,11 @@ toList_RDR = nameRdrName toListName
compose_RDR :: RdrName
compose_RDR = varQual_RDR gHC_BASE (fsLit ".")
-not_RDR, getTag_RDR, dataToTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
+not_RDR, dataToTag_RDR, succ_RDR, pred_RDR, minBound_RDR, maxBound_RDR,
and_RDR, range_RDR, inRange_RDR, index_RDR,
unsafeIndex_RDR, unsafeRangeSize_RDR :: RdrName
and_RDR = varQual_RDR gHC_CLASSES (fsLit "&&")
not_RDR = varQual_RDR gHC_CLASSES (fsLit "not")
-getTag_RDR = varQual_RDR gHC_BASE (fsLit "getTag")
dataToTag_RDR = varQual_RDR gHC_PRIM (fsLit "dataToTag#")
succ_RDR = varQual_RDR gHC_ENUM (fsLit "succ")
pred_RDR = varQual_RDR gHC_ENUM (fsLit "pred")
diff --git a/compiler/GHC/Core.hs b/compiler/GHC/Core.hs
index 2e41f9932b..cc7320f531 100644
--- a/compiler/GHC/Core.hs
+++ b/compiler/GHC/Core.hs
@@ -114,7 +114,6 @@ import GHC.Utils.Misc
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
-import GHC.Utils.Trace
import Data.Data hiding (TyCon)
import Data.Int
@@ -1601,9 +1600,7 @@ cmpAltCon (DataAlt _) DEFAULT = GT
cmpAltCon (LitAlt l1) (LitAlt l2) = l1 `compare` l2
cmpAltCon (LitAlt _) DEFAULT = GT
-cmpAltCon con1 con2 = warnPprTrace True (text "Comparing incomparable AltCons" <+>
- ppr con1 <+> ppr con2) $
- LT
+cmpAltCon con1 con2 = pprPanic "cmpAltCon" (ppr con1 $$ ppr con2)
{-
************************************************************************
diff --git a/compiler/GHC/Core/TyCo/Rep.hs b/compiler/GHC/Core/TyCo/Rep.hs
index bb7280dd0d..31c8813e10 100644
--- a/compiler/GHC/Core/TyCo/Rep.hs
+++ b/compiler/GHC/Core/TyCo/Rep.hs
@@ -713,10 +713,8 @@ data TyCoBinder
instance Outputable TyCoBinder where
ppr (Anon af ty) = ppr af <+> ppr ty
ppr (Named (Bndr v Required)) = ppr v
- -- See Note [Explicit Case Statement for Specificity]
- ppr (Named (Bndr v (Invisible spec))) = case spec of
- SpecifiedSpec -> char '@' <> ppr v
- InferredSpec -> braces (ppr v)
+ ppr (Named (Bndr v Specified)) = char '@' <> ppr v
+ ppr (Named (Bndr v Inferred)) = braces (ppr v)
-- | 'TyBinder' is like 'TyCoBinder', but there can only be 'TyVarBinder'
diff --git a/compiler/GHC/Core/TyCo/Tidy.hs b/compiler/GHC/Core/TyCo/Tidy.hs
index 96cbed6ade..97d3adf8e0 100644
--- a/compiler/GHC/Core/TyCo/Tidy.hs
+++ b/compiler/GHC/Core/TyCo/Tidy.hs
@@ -8,12 +8,10 @@ module GHC.Core.TyCo.Tidy
-- * Tidying type related things up for printing
tidyType, tidyTypes,
tidyOpenType, tidyOpenTypes,
- tidyOpenKind,
tidyVarBndr, tidyVarBndrs, tidyFreeTyCoVars, avoidNameClashes,
tidyOpenTyCoVar, tidyOpenTyCoVars,
tidyTyCoVarOcc,
tidyTopType,
- tidyKind,
tidyCo, tidyCos,
tidyTyCoVarBinder, tidyTyCoVarBinders
) where
@@ -215,13 +213,6 @@ tidyTopType :: Type -> Type
tidyTopType ty = tidyType emptyTidyEnv ty
---------------
-tidyOpenKind :: TidyEnv -> Kind -> (TidyEnv, Kind)
-tidyOpenKind = tidyOpenType
-
-tidyKind :: TidyEnv -> Kind -> Kind
-tidyKind = tidyType
-
-----------------
-- | Tidy a Coercion
--
diff --git a/compiler/GHC/Core/TyCon.hs b/compiler/GHC/Core/TyCon.hs
index 24807945cc..e267932e14 100644
--- a/compiler/GHC/Core/TyCon.hs
+++ b/compiler/GHC/Core/TyCon.hs
@@ -680,10 +680,8 @@ instance OutputableBndr tv => Outputable (VarBndr tv TyConBndrVis) where
ppr_bi (AnonTCB VisArg) = text "anon-vis"
ppr_bi (AnonTCB InvisArg) = text "anon-invis"
ppr_bi (NamedTCB Required) = text "req"
- -- See Note [Explicit Case Statement for Specificity]
- ppr_bi (NamedTCB (Invisible spec)) = case spec of
- SpecifiedSpec -> text "spec"
- InferredSpec -> text "inf"
+ ppr_bi (NamedTCB Specified) = text "spec"
+ ppr_bi (NamedTCB Inferred) = text "inf"
instance Binary TyConBndrVis where
put_ bh (AnonTCB af) = do { putByte bh 0; put_ bh af }
diff --git a/compiler/GHC/Core/Type.hs b/compiler/GHC/Core/Type.hs
index cf671657b0..85cc635791 100644
--- a/compiler/GHC/Core/Type.hs
+++ b/compiler/GHC/Core/Type.hs
@@ -222,12 +222,10 @@ module GHC.Core.Type (
-- * Tidying type related things up for printing
tidyType, tidyTypes,
tidyOpenType, tidyOpenTypes,
- tidyOpenKind,
tidyVarBndr, tidyVarBndrs, tidyFreeTyCoVars,
tidyOpenTyCoVar, tidyOpenTyCoVars,
tidyTyCoVarOcc,
tidyTopType,
- tidyKind,
tidyTyCoVarBinder, tidyTyCoVarBinders,
-- * Kinds
@@ -3541,22 +3539,10 @@ tyConAppNeedsKindSig spec_inj_pos tc n_args
_ -> emptyFV
source_of_injectivity Required = True
- -- See Note [Explicit Case Statement for Specificity]
- source_of_injectivity (Invisible spec) = case spec of
- SpecifiedSpec -> spec_inj_pos
- InferredSpec -> False
+ source_of_injectivity Specified = spec_inj_pos
+ source_of_injectivity Inferred = False
{-
-Note [Explicit Case Statement for Specificity]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-When pattern matching against an `ArgFlag`, you should not pattern match against
-the pattern synonyms 'Specified' or 'Inferred', as this results in a
-non-exhaustive pattern match warning.
-Instead, pattern match against 'Invisible spec' and do another case analysis on
-this specificity argument.
-The issue has been fixed in GHC 8.10 (ticket #17876). This hack can thus be
-dropped once version 8.10 is used as the minimum version for building GHC.
-
Note [When does a tycon application need an explicit kind signature?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are a couple of places in GHC where we convert Core Types into forms that
diff --git a/compiler/GHC/HsToCore/Quote.hs b/compiler/GHC/HsToCore/Quote.hs
index 42d2742bec..6fdd87a0e3 100644
--- a/compiler/GHC/HsToCore/Quote.hs
+++ b/compiler/GHC/HsToCore/Quote.hs
@@ -2675,7 +2675,7 @@ repH98DataCon con details
arg_tys <- repPrefixConArgs ps
rep2 normalCName [unC con', unC arg_tys]
InfixCon st1 st2 -> do
- verifyLinearConstructors [st1, st2]
+ verifyLinearFields [st1, st2]
arg1 <- repBangTy (hsScaledThing st1)
arg2 <- repBangTy (hsScaledThing st2)
rep2 infixCName [unC arg1, unC con', unC arg2]
@@ -2705,8 +2705,8 @@ repGadtDataCons cons details res_ty
-- denotes a linear field.
-- This check is not performed in repRecConArgs, since the GADT record
-- syntax currently does not have a way to mark fields as nonlinear.
-verifyLinearConstructors :: [HsScaled GhcRn (LHsType GhcRn)] -> MetaM ()
-verifyLinearConstructors ps = do
+verifyLinearFields :: [HsScaled GhcRn (LHsType GhcRn)] -> MetaM ()
+verifyLinearFields ps = do
linear <- lift $ xoptM LangExt.LinearTypes
let allGood = all (\st -> case hsMult st of
HsUnrestrictedArrow _ -> not linear
@@ -2718,7 +2718,7 @@ verifyLinearConstructors ps = do
repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)]
-> MetaM (Core [M TH.BangType])
repPrefixConArgs ps = do
- verifyLinearConstructors ps
+ verifyLinearFields ps
repListM bangTypeTyConName repBangTy (map hsScaledThing ps)
-- Desugar the arguments in a data constructor declared with record syntax.
diff --git a/compiler/GHC/Iface/Type.hs b/compiler/GHC/Iface/Type.hs
index 407b474bac..2427bba019 100644
--- a/compiler/GHC/Iface/Type.hs
+++ b/compiler/GHC/Iface/Type.hs
@@ -862,10 +862,8 @@ pprIfaceTyConBinders suppress_sig = sep . map go
-- The above case is rare. (See Note [AnonTCB InvisArg] in GHC.Core.TyCon.)
-- Should we print these differently?
NamedTCB Required -> ppr_bndr (UseBndrParens True)
- -- See Note [Explicit Case Statement for Specificity]
- NamedTCB (Invisible spec) -> case spec of
- SpecifiedSpec -> char '@' <> ppr_bndr (UseBndrParens True)
- InferredSpec -> char '@' <> braces (ppr_bndr (UseBndrParens False))
+ NamedTCB Specified -> char '@' <> ppr_bndr (UseBndrParens True)
+ NamedTCB Inferred -> char '@' <> braces (ppr_bndr (UseBndrParens False))
where
ppr_bndr = pprIfaceTvBndr bndr suppress_sig
diff --git a/compiler/GHC/Tc/Errors/Hole.hs b/compiler/GHC/Tc/Errors/Hole.hs
index 00e948bd10..d1c727da35 100644
--- a/compiler/GHC/Tc/Errors/Hole.hs
+++ b/compiler/GHC/Tc/Errors/Hole.hs
@@ -484,12 +484,10 @@ pprHoleFit (HFDC sWrp sWrpVars sTy sProv sMs) (HoleFit {..}) =
hang display 2 provenance
where tyApp = sep $ zipWithEqual "pprHoleFit" pprArg vars hfWrap
where pprArg b arg = case binderArgFlag b of
- -- See Note [Explicit Case Statement for Specificity]
- (Invisible spec) -> case spec of
- SpecifiedSpec -> text "@" <> pprParendType arg
+ Specified -> text "@" <> pprParendType arg
-- Do not print type application for inferred
-- variables (#16456)
- InferredSpec -> empty
+ Inferred -> empty
Required -> pprPanic "pprHoleFit: bad Required"
(ppr b <+> ppr arg)
tyAppVars = sep $ punctuate comma $
diff --git a/compiler/GHC/Tc/Gen/Head.hs b/compiler/GHC/Tc/Gen/Head.hs
index 821b118ded..9fbd972f8a 100644
--- a/compiler/GHC/Tc/Gen/Head.hs
+++ b/compiler/GHC/Tc/Gen/Head.hs
@@ -483,7 +483,7 @@ tcInferRecSelId (FieldOcc sel_name lbl)
= do { thing <- tcLookup sel_name
; case thing of
ATcId { tct_id = id }
- -> do { check_naughty occ id
+ -> do { check_naughty occ id -- See Note [Local record selectors]
; check_local_id id
; return id }
@@ -1034,11 +1034,11 @@ errors in a polymorphic situation.
If this check fails (which isn't impossible) we get another chance; see
Note [Converting strings] in Convert.hs
-Local record selectors
-~~~~~~~~~~~~~~~~~~~~~~
+Note [Local record selectors]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Record selectors for TyCons in this module are ordinary local bindings,
which show up as ATcIds rather than AGlobals. So we need to check for
-naughtiness in both branches. c.f. TcTyClsBindings.mkAuxBinds.
+naughtiness in both branches. c.f. GHC.Tc.TyCl.Utils.mkRecSelBinds.
-}
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs
index e2a53c4f39..dca730f6f0 100644
--- a/compiler/GHC/Tc/Module.hs
+++ b/compiler/GHC/Tc/Module.hs
@@ -2708,7 +2708,7 @@ https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0179-printi
reverse :: forall a. [a] -> [a]
-- foo :: forall a f b. (Show a, Num b, Foldable f) => a -> f b -> String
- > :type +v foo @Int
+ > :type foo @Int
forall f b. (Show Int, Num b, Foldable f) => Int -> f b -> String
Note that Show Int is still reported, because the solver never got a chance
diff --git a/compiler/GHC/Tc/Validity.hs b/compiler/GHC/Tc/Validity.hs
index de007d0fac..c5dc68469f 100644
--- a/compiler/GHC/Tc/Validity.hs
+++ b/compiler/GHC/Tc/Validity.hs
@@ -433,7 +433,7 @@ checkTySynRhs ctxt ty
; expand <- initialExpandMode
; check_pred_ty emptyTidyEnv dflags ctxt expand ty })
else addErrTcM ( emptyTidyEnv
- , TcRnIllegalConstraintSynonymOfKind (tidyKind emptyTidyEnv actual_kind)
+ , TcRnIllegalConstraintSynonymOfKind (tidyType emptyTidyEnv actual_kind)
) }
| otherwise
@@ -923,7 +923,7 @@ forAllEscapeErr env tvbs theta tau tau_kind
-- NB: Don't tidy the sigma type since the tvbs were already tidied
-- previously, and re-tidying them will make the names of type
-- variables different from tau_kind.
- = (env, TcRnForAllEscapeError (mkSigmaTy tvbs theta tau) (tidyKind env tau_kind))
+ = (env, TcRnForAllEscapeError (mkSigmaTy tvbs theta tau) (tidyType env tau_kind))
{-
Note [Type variables escaping through kinds]